0% found this document useful (0 votes)
64 views

1st Prac PDF

This document discusses plotting the family of solutions to first order differential equations. It provides examples of using predefined functions like ode2 and desolve to find the general and particular solutions for different initial value problems. The solutions are plotted for different values of the initial constant k to visualize the family of curves.

Uploaded by

Rahul Massey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

1st Prac PDF

This document discusses plotting the family of solutions to first order differential equations. It provides examples of using predefined functions like ode2 and desolve to find the general and particular solutions for different initial value problems. The solutions are plotted for different values of the initial constant k to visualize the family of curves.

Uploaded by

Rahul Massey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1st Prac.

wxmx 1 / 4

Plotting First Order Solution Families


We'll plot the family of solutions of a first order differential quation:
y'=x² where y(0)=k

(a) Using the pre defined function ode2(works for an ode of order upto 2)

➔ eqn:'diff(y,x)=x²;
/·The equations is: y'=x²·/
sol:ode2(eqn,y,x);
/·sol is the name given to the general solution·/
sol1:ic1(sol,x=0,y=k);
/·sol1 is a particlar solution,
with default constant %c being replacedby k·/
v1:ev(sol1,k=−2);
/·random values are given to k in the next set of statements·/
v2:ev(sol1,k=−1);
v3:ev(sol1,k=1);
v4:ev(sol1,k=2);
wxplot2d([rhs(v1),rhs(v2),rhs(v3),rhs(v4)],[x,−3,3],[style,[lines,1],[lines,2],[lines,3],[lines,4]])$
d
(eqn) y = x2
dx
x3
(sol) y= + %c
3
x3 + 3 k
(sol1) y=
3
x3 − 6
(v1) y=
3
x3 − 3
(v2) y=
3
x3 + 3
(v3) y=
3
x3 + 6
(v4) y=
3

(%t32)

b) Using the pre defined function: desolve (works for an ode of any order)
1st Prac.wxmx 2 / 4

➔ kill(all)$
eqn:diff(y(x),x)=x²;
sol:desolve(eqn,y(x));
sol1:ev(sol,y(0)=k);
v1:ev(sol1,k=−2);
v2:ev(sol1,k=−1);
v3:ev(sol1,k=1);
v4:ev(sol1,k=2);
wxplot2d([rhs(v1),rhs(v2),rhs(v3),rhs(v4)],[x,−3,3],
[style,[lines,1],[lines,2],[lines,3],[lines,4]])$
d
(eqn) y( x ) = x 2
dx
x3
(sol) y( x ) = + y( 0 )
3
x3
(sol1) y( x ) = +k
3
x3
(v1) y( x ) = −2
3
x3
(v2) y( x ) = −1
3
x3
(v3) y( x ) = +1
3
x3
(v4) y( x ) = +2
3

(%t8)
1st Prac.wxmx 3 / 4

➔ kill(all)$
ratprint:false$
eqn:'diff(y,x)=9.8−0.196·y;
sol:ode2(eqn,y,x);
sol1:ic1(sol,x=0,y=k);
v1:ev(sol1,k=−2);
v2:ev(sol1,k=−1);
v3:ev(sol1,k=2);
v4:ev(sol1,k=1);
wxplot2d([rhs(v1),rhs(v2),rhs(v3),rhs(v4)],[x,−3,3],[style,[lines,1],[lines,2],[lines,3],[lines,4]])$

d
(eqn) y = 9.8 − 0.196 y
dx
49 x
− ⎛ 49 x ⎞
(sol) y = %e 250 ⎜ ⎟
⎜⎝ 50 %e 250 + %c ⎟⎠
49 x
− ⎛ 49 x ⎞
(sol1) y = %e 250 ⎜ ⎟
⎜⎝ 50 %e 250 + k − 50 ⎟⎠
49 x
− ⎛ 49 x ⎞
(v1) y = %e 250 ⎜ ⎟
⎜⎝ 50 %e 250 − 52 ⎟⎠
49 x
− ⎛ 49 x ⎞
(v2) y = %e 250 ⎜ ⎟
⎜⎝ 50 %e 250 − 51 ⎟⎠
49 x
− ⎛ 49 x ⎞
(v3) y = %e 250 ⎜ ⎟
⎜⎝ 50 %e 250 − 48 ⎟⎠
49 x
− ⎛ 49 x ⎞
(v4) y = %e 250 ⎜ ⎟
⎜⎝ 50 %e 250 − 49 ⎟⎠

(%t9)
1st Prac.wxmx 4 / 4

➔ kill(all)$
eqn:'diff(y,x)·cos(x)+y·sin(x)=2·(cos(x))³·sin(x)−1;
sol:ode2(eqn,y,x);
sol1:ic1(sol,x=0,y=k);
v1:ev(sol1,k=−2);
v2:ev(sol1,k=−1);
v3:ev(sol1,k=2);
v4:ev(sol1,k=1);
wxplot2d([rhs(v1),rhs(v2),rhs(v3),rhs(v4)],[x,−30,30],[style,[lines,1],[lines,2],[lines,3],[lines,4]])$
⎛ d ⎞ 3
(eqn) cos( x ) ⎜⎜ y ⎟ + sin( x ) y = 2 cos( x ) sin( x ) − 1
⎝ d x ⎠⎟
⎛ 1 ⎞
(sol) y = cos( x ) ⎜⎜ − − tan( x ) + %c ⎟⎟
⎜⎝ tan( x ) 2 + 1 ⎟⎠
cos( x ) tan( x ) 3 + ( − k − 1 ) cos( x ) tan( x ) 2 + cos( x ) tan( x ) − k cos( x )
(sol1) y=−
tan( x ) 2 + 1
cos( x ) tan( x ) 3 + cos( x ) tan( x ) 2 + cos( x ) tan( x ) + 2 cos( x )
(v1) y=−
tan( x ) 2 + 1
cos( x ) tan( x ) 3 + cos( x ) tan( x ) + cos( x )
(v2) y=−
tan( x ) 2 + 1
cos( x ) tan( x ) − 3 cos( x ) tan( x ) 2 + cos( x ) tan( x ) − 2 cos( x )
3
(v3) y=−
tan( x ) 2 + 1
cos( x ) tan( x ) − 2 cos( x ) tan( x ) 2 + cos( x ) tan( x ) − cos( x )
3
(v4) y=−
tan( x ) 2 + 1

(%t8)

You might also like