Title | Math 20d mathlab 2 |
---|---|
Author | Rain Tian |
Course | Introduction to Differential Equations |
Institution | University of California San Diego |
Pages | 13 |
File Size | 836.7 KB |
File Type | |
Total Downloads | 39 |
Total Views | 138 |
Matlab2...
Ex 2.1 (a, b) (c)>> dsolve('Dy=y/5','x') ans = C1*exp(x/5)
Ex 2.2 (a). >> f=@(x,y) (exp(-x)-y)*(exp(-x)+2+y) f= function_handle with value: @(x,y)(exp(-x)-y)*(exp(-x)+2+y) >> slopefield(f,[-10,10],[-10,10],40) >> hold on >> drawode(f,[-10,10],2,3) >> drawode(f,[-10,10],0,2) >> hold of 10
8 6
4
2
0
2
4 6
8
10 10
8
6
4
2
0
2
4
6
8
10
(b)The calculation with e is too complicated to get a value to help us imagine the solution. Direction field can fundamentally help us to visualize the solution (general).
Ex 2.3 >> f=@(x,y)x+2*y f= function_handle with value:
@(x,y)x+2*y >> slopefield(f,[-5,5],[-5,5],20) >> hold on >> drawode(f,[-5,5],0,-1/4) >> drawode(f,[-5,5],-1/4,-1/4) >> drawode(f,[-5,5],1/4,-1/4) >> drawode(f,[-5,5],0,0) >> hold of 5 4
3 2
1 0
1 2
3 4
5 5
4
3
2
1
0
1
2
3
4
5
As we can see from the plot, if the initial value is (0, -1/4), the solution would be a straight line, otherwise it is not. So initial value not being exactly (0, -1/4) would greatly afect the solution of diferential equation.
Ex 2.4 >> f=@(x,y) y-1 f= function_handle with value: @(x,y)y-1 >> slopefield(f,[-6,6],[-6,6],20) >> hold on >> drawode(f,[-6,6],1,1) >> drawode(f,[-6,6],0.9,1)
>> drawode(f,[-6,6],1,0.9) >> drawode(f,[-6,6],0.9,0.9) >> hold of 6
4
2
0
2
4
6 6
4
2
0
2
4
6
If the initial value is not (1,1), as seen from plot above, this would greatly afect the solution.
Ex 2.5 >> f=@(t,y) 2*(1-y) f= function_handle with value: @(t,y)2*(1-y) >> slopefield(f,[0,10],[-5,5],20)
5
4
3
2
1
0
1
2
3
4
5 0
1
2
3
4
5
6
7
8
9
10
5
6
7
8
9
10
Now when A=2 >> f=@(t,y) 2*(2-y) f= function_handle with value: @(t,y)2*(2-y) >> slopefield(f,[0,10],[-5,5],20) >> hold on >> slopefield(f,[0,10],[-5,5],20) >> hold on >> drawode(f,[0,10],3,3) >> drawode(f,[0,10],3,4) >> drawode(f,[0,10],5,7) 5
4
3
2
1
0
1
2
3
4
5 0
1
2
3
4
Now when A=4 >> f=@(t,y) 2*(4-y) f= function_handle with value: @(t,y)2*(4-y) >> slopefield(f,[0,10],[-5,5],20) >> hold on >> drawode(f,[0,10],3,3) >> drawode(f,[0,10],3,4) >> drawode(f,[0,10],5,7) >> hold of 5
4
3
2
1 0
1
2
3
4 5 0
1
2
3
4
5
6
7
8
9
10
As we can observe from the above plots, A should represents the temperature of surrounding environment at which the temperature of the object will eventually get to.
Ex 2.6 (1).dy/dt=0.4*(41-y) y(0)=-6 (2) A=41
(3) >> f=@(t,y) 0.4*(39-y) f= function_handle with value: @(t,y)0.4*(39-y) >> slopefield(f,[-10,40],[-20,40],50) >> hold on >> drawode(f,[-10,40],0,-6) >> hold of
40
30
20
10
0
10
20 10
5
0
5
10
15
2 0
25
30
35
40
Under the given condition, it takes around 13 hours to defrost the chicken breast.
(4) >> f=@(t,y) 0.4*(69-y) f= function_handle with value: @(t,y)0.4*(69-y) >> slopefield(f,[-10,40],[-10,70],50) >> hold on
>> drawode(f,[-10,40],0,-6)
70
60
50
40
30
20
10
0
10 1 0
5
0
5
10
1 5
20
2 5
30
3 5
40
As we can see from the graph, the curve intersects with y=39 at around t=2.5. So about 132.5=10.5 hours could be saved if the chicken breast is thawed on chicken counter instead
Ex 2.7 >> g=@(t,x,y) [2;-3] g= function_handle with value: @(t,x,y)[2;-3] >> phaseplane(g,[-5,5],[-5,5],20) >> hold on >> drawphase(g, 8, 2, 1) >> drawphase(g, 3, 5, 2) >> drawphase(g, 6, -1, -2) >> hold of
5
4
3 2
1
0
1
2
3 4
5 5
4
3
2
1
0
1
2
3
4
>> g=@(t,x,y) [4;-1] g= function_handle with value: @(t,x,y)[4;-1] >> phaseplane(g,[-5,5],[-5,5],20) >> hold on >> drawphase(g, 8, 2, 1) drawphase(g, 3, 5, 2) drawphase(g, 6, -1, -2) >> hold of 5
4
3
2
1
0
1
2
3
4
5 5
4
3
>> g=@(t,x,y) [4;3]
2
1
0
1
2
3
4
5
5
g= function_handle with value: @(t,x,y)[4;3] >> phaseplane(g,[-5,5],[-5,5],20) hold on drawphase(g, 8, 2, 1) drawphase(g, 3, 5, 2) drawphase(g, 6, -1, -2) hold of 5 4 3
2 1
0 1
2 3
4 5 5
4
3
2
1
0
1
2
3
4
5
So changing x’ and y’ to other constants values will change the overall slope rate (slope rate is associated with the multiplication of those two constant)
Ex 2.8 >> g=@(t,Y) [Y(2);-Y(1)] g= function_handle with value: @(t,Y)[Y(2);-Y(1)] >> phaseplane(g,[-10,10],[-10,10],40) >> hold onw >> drawphase(g, 20, 1, -3) >> drawphase(g, 14, 2, 5) >> drawphase(g, 10, 5, 5) >> hold of
10 8 6
4 2
0 2
4 6
8 10 10
8
6
4
2
0
2
4
6
8
10
Ex 2.9 >> f=@(x,y) x^2+y^3 f= function_handle with value: @(x,y)x^2+y^3 >> slopefield(f,[-20,20],[-20,20],40) >> hold on >> drawode(f,[-20,20],0,1) >> drawode(f,[-20,20],0,-5) >> drawode(f,[-20,20],5,5) >> drawode(f,[-20,20],0,0) >> hold of 20
15
10
5
0
5
10
15
20 20
15
10
5
0
5
10
15
20
>> g=@(t,Y) [1; Y(1)^2 + Y(2)^3]; phaseplane(g, [-10,10], [-10,10], 40) >> hold on >> drawphase(g,30,0,1) >> drawphase(g,30,0,5) >> drawphase(g,30,0,0) >> hold of 1 0 8 6 4
2 0 2
4 6 8
10 10
8
6
4
2
0
2
4
6
8
1 0
Phase portrait figure is a dynamic visualization of my directional field figure. The directional field depicts all the paths while phase portrait depicts only some t interval. Overall, the resulting curves match up.
Ex 2.10 (a)>> k=@(t,Y) [Y(1)*(1-Y(2));Y(2)*(Y(1)-1)] k= function_handle with value: @(t,Y)[Y(1)*(1-Y(2));Y(2)*(Y(1)-1)] >> phaseplane(k, [-1,5], [-1,5], 20)
5
4
3
2
1
0
1 1
0
1
2
3
4
5
Physically possible solutions only exist (in first quadrant) for both x and y greater than or equal to zero. (b) >> k=@(t,Y) [Y(1)*(1-Y(2));Y(2)*(Y(1)-1)] k= function_handle with value: @(t,Y)[Y(1)*(1-Y(2));Y(2)*(Y(1)-1)] >> phaseplane(k, [-1,5], [-1,5], 20) >> hold on >> drawphase(k,75,2,3) >> drawphase(k,75,1,2) >> drawphase(k,75,4,1) >> hold of (C)states as marked below. 5
4
3
2
1
0
1 1
0
1
2
3
4
5...