Idli
Idli
Idli
wxmx 1 / 29
⟶⟶⟶
2.1 Solve the equation `d²y/dx² + 4y = 0` for y(0) = 1 and plot family of curves.
depends(y, x);
[ y ( x )]
eq: diff(y, x, 2) + 4 ·y = 0;
2
d
y+4 y=0
2
dx
gs: ode2(eq, y, x);
y = %k1 sin ( 2 x ) + %k2 cos ( 2 x )
ps : ic2(gs, x=0, y = 1, diff(y,x)= b);
b sin ( 2 x )
y= + cos ( 2 x )
2
Saransh Sood 15034.wxmx 5 / 29
2.2 Solve the equation `d²y/dx² + 4x = 0` for y(0) = a and dy/dx =1 and plot the
family of curves.
depends(y, x);
[ y ( x )]
eq1: diff(y, x, 2) + 4·x = 0;
2
d
y+4 x=0
2
dx
gs1: ode2(eq1, y, x);
3
y=− 2 x + %k2 x + %k1
3
PS: ic2(gs1, x=0, y = a, diff(y,x)= 1);
3
y=− 2 x +x+a
3
Saransh Sood 15034.wxmx 6 / 29
3 3 3
2x 2x
y= − +x−1 y=x− y=− 2 x +x+1
3 3 3
wxplot2d([rhs(PS1), rhs(PS2), rhs(PS3)], [x, −3, 3], [y, −5, 5], [style, [lines, 3]]);
plot2d: some values will be clipped.
plot2d: some values will be clipped.
plot2d: some values will be clipped.
2.3 Solve the equation `d²y/dx² + 4y + x = 0` for y(0) = a and dy/dx = b and plot the
family of curves.
depends(y,x);
[ y ( x )]
eq3: diff(y,x,2) + 4·y + x = 0;
2
d
y+4 y+x=0
2
dx
sol3: ode2(eq3, y, x);
x
y = %k1 sin ( 2 x ) + %k2 cos ( 2 x ) −
4
res: ic2(sol, x=0, y=a, diff(y,x) = b);
( 4 b + 1 ) sin ( 2 x ) x
y= + a cos ( 2 x ) −
8 4
Saransh Sood 15034.wxmx 7 / 29
y=
5 sin ( 2 x ) x sin ( 2 x ) x 5 sin ( 2 x )
− y= + cos ( 2 x ) − y= + cos ( 2 x ) −
8 4 8 4 8
x sin ( 2 x ) x
y= −
4 8 4
wxplot2d([rhs(res1), rhs(res2), rhs(res3), rhs(res4)], [x,−5, 5], [style, [lines, 2]]);
2.4 Solve the equation `d²y/dx² + 3dy/dx + 2y = 0` for different values of natural
constants and plot the family of curves.
depends(y, x);
[ y ( x )]
eq4 : diff(y, x, 2)+ 3·diff(y, x)+ 2·y = 0;
2
d d
y+3 y +2 y=0
2 dx
dx
sol4: ode2(eq4, y, x);
−x −(2 x)
y = %k1 %e + %k2 %e
pcs: ic2(sol4, x=0, y=1, diff(y,x) = 4);
−x −(2 x)
y = 6 %e − 5 %e
Saransh Sood 15034.wxmx 8 / 29
⟶⟶⟶
3.1 Solve the third order equation `dy³/d³x + y = xe^xsin²x` for the values y(0)=1,
y'(0)=2, y''(0)=3 and hence obtain the curve.
Saransh Sood 15034.wxmx 9 / 29
depends(y, x);
Eq: diff(y, x, 3) + y = x·(%e^x) · (sin(x))^2;
3
d x 2
[y (x )] y + y = x %e sin ( x )
3
dx
load(odes);
So: odeL(Eq, y, x);
x/2
C:/maxima−5.47.0/share/maxima/5.47.0/share/contrib/odes/odes.mac y = C3 %e
x/2 −x
3 x 3 x
sin + C2 %e cos + C1 %e
2 2
sol1: ev(So, C1 =1, C2= 2, C3=3);
x/2 x/2 −x
3 x 3 x
y = 3 %e sin + 2 %e cos + %e
2 2
so1: odeL_ic(Eq, y, x, [0, 1, 2, 3]);
x/2 x/2
3 x 3 x
5 %e sin %e cos −x
2 2 2 %e
y= + +
3 3 3
wxplot2d(rhs(so1), [x, −10, 10], [y, −100, 100], [style, [lines, 4]]);
plot2d: some values will be clipped.
3.2 Solve the equation `dy³/d³x + 3dy/dx - 4y = 0` as an IVP for the values y(0)=1,
y'(0)=2, y''(0)=3.
depends(y, x)$
e2: diff(y, x, 3) + 3·diff(y, x) − 4·y = 0;
Saransh Sood 15034.wxmx 10 / 29
3
d d
y+3 y −4 y=0
3 dx
dx
load(odes)$
sol : odeL(e2, y, x);
x x
− −
2 3 5 x 2 3 5 x x
y = C3 %e sin + C2 %e cos + C1 %e
2 2
s1: odeL_ic(e2, y, x, [0, 1, 2, 3]);
x x
− −
2 2
3 5 x 3 5 x
%e sin %e cos x
2 2 3 %e
y= − +
2 3 5 2 2
wxplot2d(rhs(s1), [x, −5, 5], [style, [lines, 4]]);
3.3 Solve the third order equation `dy³/d³x + y = xe^xsin²x` as an initial value
problem for values y(0)=4, y'(0)=-7 and y"(0)=23.
depends(y, x)$
e1: diff(y, x, 3) + y = x· e^x·(sin(x))^2;
3
d x 2
y + y = e x sin ( x )
3
dx
load(odes)$
gs1: odeL(e1, y, x);
x/2 x/2 −x
3 x 3 x
y = C3 %e sin + C2 %e cos + C1 %e
2 2
Saransh Sood 15034.wxmx 11 / 29
⟶⟶⟶
sol1: expand(sol);
yc: rhs(sol1);
x x x x
y = %k2 x %e + %k1 %e %k2 x %e + %k1 %e
y1: coeff(yc, %k1);
y2: coeff(yc, %k2);
r: %e^x·sin(x);
x x x
%e x %e %e sin ( x )
m: matrix([y1, y2], [diff(y1,x), diff(y2, x)]);
w: determinant(m);
x x
%e x %e x x x 2x
%e ( x %e + %e ) − x %e
x x x
%e x %e + %e
x 4x
%e
− %e
3 12
yp: u1·y1 + u2·y2;
3x
%e
4
y: yc + yp;
3x
%e 2x −x
+ %k1 %e + %k2 %e
2
kill(all)$
sin ( x ) cos ( x ) 2 2
− sin ( x ) − cos ( x )
cos ( x ) − sin ( x )
⟶⟶⟶
5.1 Solve the system of simultaneous equations `dx(t)/dt = t` and `dy(t)/dt = t²` at
value x(0) = 1 and y(0) = 2
eqx: diff(x(t), t) = t;
eqy: diff(y(t), t) = t^2;
d d 2
x ( t )= t y ( t )= t
dt dt
sol: desolve([eqx, eqy], [x(t), y(t)]);
2 3
t t
x ( t )= + x ( 0 ), y ( t )= +y(0)
2 3
atvalue(x(t), t=0, 1);
atvalue(y(t), t=0, 2);
1 2
desolve([eqx, eqy], [x(t), y(t)]);
2 3
t t
x ( t )= + 1 , y ( t )= +2
2 3
ev(sol, at(x(t), t=0) =1, at(y(t), t=0) = 2);
2 3
t t
x ( t )= + 1 , y ( t )= +2
2 3
kill(all)$
[ x ( t )= − ( t y ) + 7 t x + x ( 0 ), y ( t )= 5 t y + 2 t x + y ( 0 )]
/* 2nd way */
eqx1b: diff(x(t), t) = −y(t) + 7·x(t);
eqy1b: diff(y(t), t) = 5·y(t) + 2·x(t);
d d
x ( t )= 7 x ( t )− y ( t ) y ( t )= 5 y ( t )+ 2 x ( t )
dt dt
atvalue(x(t), t=0, 10);
atvalue(y(t), t=0, −5);
10 −5
Saransh Sood 15034.wxmx 15 / 29
/* 3rd way */
eqx1c: diff(x(t), t) = −y(t) + 7·x(t);
eqy1c: diff(y(t), t) = 5·y(t) + 2·x(t);
d d
x ( t )= 7 x ( t )− y ( t ) y ( t )= 5 y ( t )+ 2 x ( t )
dt dt
solu: desolve([eqx1c, eqy1c], [x(t), y(t)]);
6t ( 2 ( − y ( 0 ) − 5 x ( 0 ) ) + 12 x ( 0 ) ) sin ( t ) 6t
[ x ( t ) = %e + x ( 0 ) cos ( t ) , y ( t ) = %e
2
( 12 y ( 0 ) + 2 ( 2 x ( 0 ) − 7 y ( 0 ) ) ) sin ( t )
+ y ( 0 ) cos ( t ) ]
2
ev(solu, at(x(t), t=0) =10, at(y(t), t=0) = −5);
6t 6t
x ( t ) = %e ( 15 sin ( t ) + 10 cos ( t ) ) , y ( t ) = %e ( 25 sin ( t ) − 5 cos ( t ) )
kill(all)$
5.3 Solve the system of simultaneous equations `dy(t)/dt = y(t) + 2x(t)` and `dx(t)/dt
= 4y(t) + 3x(t)` at value x(0) = 1 and y(0) = 0
eqx2: diff(y(t), t) = y(t) + 2· x(t);
eqy2: diff(x(t), t) =4·y(t) + 3· x(t);
d d
y ( t )= y ( t )+ 2 x ( t ) x ( t )= 4 y ( t )+ 3 x ( t )
dt dt
atvalue(x(t), t=0, 1);
atvalue(y(t), t=0, 0);
1 0
desolve([eqx2, eqy2], [x(t), y(t)]);
5t −t 5t −t
2 %e %e %e %e
x ( t )= + , y ( t )= −
3 3 3 3
kill(all)$
⟶⟶⟶
eq: 'diff(y,x) = 1;
sol: ode2(eq, y, x);
solve(%, %c);
d
y=1 y = x + %c [ %c = y − x ]
dx
eq2: 'diff(u,y) = 1;
sol2: ode2(eq2, u, y);
solve(%, %c);
d
u=1 u = y + %c [ %c = u − y ]
dy
u − y =f(y−x);
solve(%, u);
u−y=f(y−x) [ u = f ( y − x )+ y ]
u(x, y) := f(y−x) + y;
u ( x , y ) := f ( y − x ) + y
u(0, y) = y^2;
solve(%, f(y));
2 2
f ( y )+ y = y f ( y )= y − y
f(y) := y^2 − y ;
2
f ( y ) := y − y
'u(x,y) = u(x,y);
2
u ( x , y )= ( y − x ) + x
wxplot3d(u(x,y), [x, −10, 10], [y, −10, 10]);
kill(all)$
Saransh Sood 15034.wxmx 17 / 29
u−x=f(y+x) [ u = f ( y + x )+ x ]
u(x, y) := f(y+x) + x;
u ( x , y ) := f ( y + x ) + x
u(x, 0) = x^2;
solve(%, f(x));
2 2
f ( x )+ x = x f ( x )= x − x
f(x) := x^2 − x;
2
f ( x ) := x − x
Saransh Sood 15034.wxmx 18 / 29
'u(x,y) = u(x,y);
2
u (x ,y )= (y + x ) − y
6.3 Solve the PDE `xu_x +yu_y = xe^-u` for u(x, x²) = 0
eq1:'diff(y,x)=y/x;
sol1:ode2(eq1,y,x);
solve(y=c1·x,c1);
d y y
y= y = %c x c1 =
dx x x
eq2:'diff(u,x)=%e^−u;
sol2:ode2(eq2,u,x);
solve(%e^u=x+c2,c2);
d −u u u
u = %e %e = x + %c c2 = %e − x
dx
%e^u−x=f(y/x);
solve(%,u);
u y y
%e − x = f u = log f +x
x x
u(x,y):=log(f(y/x)+x);
y
u ( x , y ) := log f +x
x
Saransh Sood 15034.wxmx 19 / 29
u(x,x^2)=0;
solve(%,(f(x)));
log(f(x )+ x )= 0 [f(x )= 1 − x ]
f(x):=1−x;
'u(x,y)=u(x,y);
y
f ( x ) := 1 − x u ( x , y ) = log − +x+1
x
wxplot3d(u(x,y),[x,−10,10],[y,−10,10]);
kill(all)$
expt: undefined: 0 to a negative exponent.
⟶⟶⟶
d y y
y= y = %c x %c =
dx x x
e2: 'diff(u, x )= u/x;
s2: ode2(e2, u, x);
solve(%, %c);
d u u
u= u = %c x %c =
dx x x
u/x = f(y/x);
solve(%, u);
u y y
=f u=x f
x x x
u(x,y) := x· f(y/x);
y
u ( x , y ) := x f
x
p: makelist(c1·x, c1, −3, 3);
7.2 Draw the characteristic curve for the first order PDE `u_x + x*u_y= 0`
eq1: 'diff(y, x) = x;
sol1: ode2(eq1, y, x);
solve(%, %c);
2 2
d x 2 y−x
y=x y= + %c %c =
dx 2 2
eq2: 'diff(u, x) = 0;
sol2: ode2(eq2, u, x);
solve(%, %c);
d
u=0 u = %c [ %c = u ]
dx
u = f((2·y − x^2)/2);
solve(%, u);
2 2
u=f 2 y−x u=f y− x
2 2
⟶⟶⟶
8.1 Find the integral surface of the PDE ux_y + uu_y = 1, so that the surface passes
through initial curve represented parameterically by x(s,0)=2s², y(s,0)=2s ,
u(s,0)=0, where s>0 is parameter.
eq1: 'diff(u,t) = 1;
sol1: ode2(eq1, u,t);
a1:subst( %c=c1, sol1);
solve(a1, c1);
Saransh Sood 15034.wxmx 23 / 29
d
u=1 u = t + %c u = t + c1 [ c1 = u − t ]
dt
eq2: 'diff(y,t)=1;
sol2:ode2(eq2,y,t);
a2:subst(%c=c2, sol2);
solve(a2, c2);
d
y=1 y = t + %c y = t + c2 [ c2 = y − t ]
dt
eq3: 'diff(x, t) = t+c1;
sol3: ode2(eq3, x, t);
a3: subst(%c = c3, sol3);
solve(a3, c3);
2 2 2
d t t 2 x − t − 2 c1 t
x = t + c1 x= + c1 t + %c x= + c1 t + c3 c3 =
dt 2 2 2
subst([t=0, x =2·s^2], a3);
subst([t=0, y=2·s], a2);
subst([t=0, u=0], a1);
2
2 s = c3 2 s = c2 0 = c1
'x = t^2/2+2·s^2;
'y = t+2·s;
'u= t;
2
t 2
x= +2 s y=t+2 s u=t
2
subst([c1=0, c2=2·s, c3=2·s^2], [a1, a2, a3]);
2
t 2
u=t,y=t+2 s,x= +2 s
2
load(draw);
C:/maxima−5.47.0/share/maxima/5.47.0/share/draw/draw.lisp
wxdraw3d(color=black,parametric(2·s^2, 2·s, 0, s, −100, 100),
title="Initial curve");
Saransh Sood 15034.wxmx 24 / 29
8.2 Find the integral surface of that PDE u_x - u_y = x + y, so that it passes through
the initial curve represented parametrically by x(s,0) = s^2, y(s,0) = -s, u(s,0) = 0,
where s > 0 is a parameter.
eq1: 'diff(u,t) = x + y;
sol1: ode2(eq1, u,t);
a1:subst( %c=c1, sol1);
solve(a1, c1);
d
u=y+x u = t ( y + x ) + %c u = t ( y + x ) + c1 [ c1 = − ( t y ) − t x + u ]
dt
eq2: 'diff(y,t)= −1;
sol2:ode2(eq2,y,t);
a2:subst(%c=c2, sol2);
solve(a2, c2);
d
y=−1 y = %c − t y = c2 − t [ c2 = y + t ]
dt
eq3: 'diff(x, t) = 1;
sol3: ode2(eq3, x, t);
a3: subst(%c = c3, sol3);
solve(a3, c3);
d
x=1 x = t + %c x = t + c3 [ c3 = x − t ]
dt
subst([t=0, x =s^2], a3);
subst([t=0, y=−s], a2);
subst([t=0, u=0], a1);
Saransh Sood 15034.wxmx 27 / 29
2
s = c3 − s = c2 0 = c1
'x = t+s^2;
'y = −s − t;
'u= −(t·( −s − t)) + t·(t + s^2);
2 2
x=t+s y=−t−s u=t (t+s )−(−t−s) t
load(draw)$
wxdraw3d(parametric_surface(t+ s^2, −t−s, t·(t+s^2)−(−s −t)· t , s, −100, 100, t, −100, 100),
title="Integral surface");
Saransh Sood 15034.wxmx 28 / 29
wxdraw3d( color=pink, parametric_surface(t+ s^2, −t−s, t·(t+s^2)−(−s −t)· t , s, −100, 100, t, −100, 100),
color=black,parametric(s^2, −s, 2·s, s, −100, 100), title="Integral surface with initial curve");
Saransh Sood 15034.wxmx 29 / 29