MATLAB-hw2

10
Name: Thao Hoang PID: A12495313 Section: A01 TA’s name: Xiaolong (Bruce) Li Matlab Assignment 2 Exercise 2.1 a)

description

this is the questiion 2

Transcript of MATLAB-hw2

Page 1: MATLAB-hw2

Name: Thao HoangPID: A12495313

Section: A01TA’s name: Xiaolong (Bruce) Li

Matlab Assignment 2

Exercise 2.1

a)

Page 2: MATLAB-hw2

Exercise 2.2

a. The lines which DFIELD has drawn are the solutions of the differential equation at different x and y values based on the initial point that I clicked.

-2 0 2 4 6 8 10

-4

-3

-2

-1

0

1

2

3

4

x

y

y ' = (exp( - x) - y) (exp( - x) + 2 + y)

b. The utility of plotting direction fields using MATLAB will save us a lot of time than do it by hand and it is easier to see the solution at the point we need.

Exercise 2.3

If the initial value in the problem were not exactly (0,1) but near (0,1), it would not have any huge effect on the solution of this differential equation.

-2 0 2 4 6 8 10

-4

-3

-2

-1

0

1

2

3

4

x

y

y ' = x + 2 y

Exercise 2.4

Page 3: MATLAB-hw2

If the initial value were not exactly at (1,1), it would have huge effects and alteration on the solution of this differential equation. The solutions were diverged away from the horizontal line at (1,1). The solution would concave up if y>1 and concave down if y<1.

-2 0 2 4 6 8 10

-4

-3

-2

-1

0

1

2

3

4

x

y

y ' = y - 1

Exercise 2.5At A=1

At A=3

0 1 2 3 4 5 6 7 8 9 10

-4

-3

-2

-1

0

1

2

3

4

t

y

y ' = k (A - y) A = 1 k = 2

Page 4: MATLAB-hw2

At A=10

In real life, A represent the temperature of the environment.

Exercise 2.6

0 1 2 3 4 5 6 7 8 9 10

-4

-3

-2

-1

0

1

2

3

4

t

y

y ' = k (A - y) A = 3 k = 2

0 1 2 3 4 5 6 7 8 9 10

-4

-3

-2

-1

0

1

2

3

4

t

y

y ' = k (A - y) A = 9 k = 2

Page 5: MATLAB-hw2

a) The initial value problem which we must solve dy/dt = k(A-y); y(0)=-6b) A is the environment temperature, it should be A = 41.c) Since the problem doesn’t tell the unit of time. I assume it would be in hour.

According from the graph, it should be around 8 hours

d) It would take 5.5 hours if the delicious chicken breast were thawed on the kitchen counter instead, given that room-temperature is around 69°F. So, it saves us about 2.5 hours.

0 2 4 6 8 10 12 14 16 18 20

30

32

34

36

38

40

42

44

46

48

50

t

y

y ' = k (A - y) A = 41 k = 0.4

Page 6: MATLAB-hw2

Exercise 2.7

If we change the values of x' and y' from 2 and -3 to other constant values, it will change the direction of the solution.

Exercise 2.8

Exercise 2.9

x ' = 2 y ' = - 3

-2 -1 0 1 2 3 4

-4

-3

-2

-1

0

1

2

x

y

Page 7: MATLAB-hw2

Pplane

Dfiled

From the DFILED and PPLANE, we can see they give us the same solution to the differential equation. Different initial values for y(0), give us different solution.

Exercise 2.10

x ' = 1 y ' = y3 + x2

-10 -8 -6 -4 -2 0 2 4 6 8 10

-10

-8

-6

-4

-2

0

2

4

6

8

10

x

y

-10 -8 -6 -4 -2 0 2 4 6 8 10

-10

-8

-6

-4

-2

0

2

4

6

8

10

x

y

y ' = y3 + x2

Page 8: MATLAB-hw2

a) The only possible solutions is in the first quadrant when x>0 and y>0b)

c) If rabbit is x, fox is y.We should have

x ' = x (a - b y)y ' = c y (x - d)

b = 1d = 1

a = 1c = 1

-1 0 1 2 3 4 5

-1

0

1

2

3

4

5

x

y

AB

C

E D

x ' = x (a - b y)y ' = c y (x - d)

b = 1d = 1

a = 1c = 1

-1 0 1 2 3 4 5

-1

0

1

2

3

4

5

x

y