Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
104 views

Tutorial Prob Ans

The document contains solutions to 5 tutorial problems involving differential equations: 1) Finds the solution to an IVP by hand and compares to a numerical solution using Euler's method. 2) Solves a linear IVP analytically and numerically using improved Euler, comparing values and graphs. 3) Solves an IVP using dsolve and RKF45, plotting the solutions. 4) Uses a series method to solve a BVP and graphs the solution. 5) Solves a BVP analytically using dsolve and numerically on a grid, outputting the solution in list and array form.

Uploaded by

vignanaraj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views

Tutorial Prob Ans

The document contains solutions to 5 tutorial problems involving differential equations: 1) Finds the solution to an IVP by hand and compares to a numerical solution using Euler's method. 2) Solves a linear IVP analytically and numerically using improved Euler, comparing values and graphs. 3) Solves an IVP using dsolve and RKF45, plotting the solutions. 4) Uses a series method to solve a BVP and graphs the solution. 5) Solves a BVP analytically using dsolve and numerically on a grid, outputting the solution in list and array form.

Uploaded by

vignanaraj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

TUTORIAL - ANSWER

(a) Noting that the equation is separable, solve the IVP by hand.
Noting that the equation is separable, solve the IVP by hand.
Separating variables and using the technique of partial fractions, we get
3 3
y= 3x
. The use of the initial condition gives us y = .
1 KCe 1 C2 e3 x
O with DEtools :
O ode d diff y x , x = y x * y x K3 ;
O sol d dsolve ode, y 0 = 1 , y x , type = numeric, method = classical foreuler ;
O sol 0.5 ;
O sol 1 ;

(b) Choose the option in dsolve that invokes Euler's method and
solve the IVP numerically.
O
O sol d dsolve ode, y 0 = 1 , y x , type = numeric, method = classical foreuler , output
= listprocedure
O fy d subs sol, y x ;
O seq fy 1 / 10 * i , i = 0 .. 10 ;

(c) Graph the actual solution (part (a)) and the numerical
solution (part (b)) together.
O with plots :
O odeplot sol, x, y x , 0 ..3 ;
O g1 d plot 3 / 1 C2 * exp 3 * x , x = 0 ..3, color = black :
O g2 d odeplot sol, x, y x , 0 ..3 :
O display g1, g2 ;
O
dx
Consider the IVP = 5 x K6 eKt, x 0 = 1 .
dt
(a) Find the actual solution of this linear equation IVP.
(b) Solve the IVP numerically using the improved Euler method.
(c) Compare values of the actual solution and the numerical solution for t = 1, 2, 2.5, 3, and 4.
(d) Graph the actual solution and the numerical solution together for t in the interval [0, 2.5].
(e) Comment on what you see in parts (c) and (d).

Solution:(a) The general solution of the ODE is x t = eKt CC e5 t


and the actual solution of the IVP
occurs when C = 0: x t = eKt .

(b)
O ode d diff x t , t = 5 * x t K6 * exp Kt ;
O SOL d dsolve ode, x 0 = 1 , x t , type = numeric, method = classical impoly ;
(c) Let's compare values of our actual solution x(t) = exp(-t)
and our numerical solution SOL:

(c) Let's compare values of our actual solution x(t) = exp(-t) and our numerical solution SOL:
O evalf(exp(-1));

O rhs(SOL(1)[2]);

When t = 1, the values of x(t) and SOL are close. Let's compare them when t = 2:
O evalf(exp(-2));

O rhs(SOL(2)[2]);

When t = 2.5, we get


O evalf(exp(-2.5));

O rhs(SOL(2.5)[2]);

When t = 3 and t = 4, we see even greater gaps between the actual and the approximate
solutions:
O evalf(exp(-3));

O rhs(SOL(3)[2]);

O evalf(exp(-4));

O rhs(SOL(4)[2]);

(d) Let's look at the graphs of the actual and the numerical solutions.

O with(plots):
O g1:=plot(exp(-t), t=0..2.5, color=black):
O g2:=odeplot(SOL,[t,x(t)],0..2.5):
O display({g1,g2});

3) Consider the IVP y + a(x)y + b(x)y = xsin(2x), y(0) = 0, y


(0) = 1
(a) Solve the equation using dsolve without using initial
conditions.
(b) Replace a(x) with 4, b(x) with 3 and solve using Runge-
Kutta-Fehlberg fourth-fifth order method, abbreviated rkf45.
Solution :
O restart;
O ode2 d y''Ca x y'Cb x y = x$sin x
O dsol2 d dsolve ode2
O ode3 d subs a x = 4, b x = 3, ode2
O dsol3 d dsolve ode3, y 0 = 0, D y 0 = 1 , y x ;
O sol d dsolve ode3, y 0 = 0, D y 0 = 1 , y x , type = numeric, method = rkf45, output
= listprocedure
O f1 d subs sol, y x ;
O seq f1 1 / 10 * i , i = 0 .. 10
O with plots :
O odeplot sol, x, y x , 0 ..3 ;
O
O

4) Consider y + (1 x)y + 5xy = cos(1-x), y(0) =1, y (0) = -1


(a)Use a series method to find the general solution of the BVP
(b) Graph the solution
Solution:
O ode4 d y''C 1 Kx y'C5 xy = cos 1 Kx
O ans := dsolve ode4, y 0 = 1, D y 0 =K1 , y x , type ='series' ;
O

(5) Consider the BVP ,


(a) Solve the equation using dsolve and get the output using
listprocedure.
(b) Obtain the solution at x = 0 .. 2 step size 0.2
(c) Solve the equation using array output for x = 0 .. 2 step size
0.25
Solution:

O restart;
d2 2 Cy x 2 y x
O deq2 := y x C =1
dx2 1 Cy x 2
O bc2 := y 0 = 0, y 2 = 3; dsol2 := dsolve deq2, bc2 , numeric, output = listprocedure
O fy := subs dsol2, y x ;
i
O seq fy , i = 0 ..10
10
O dsol3 d dsolve deq2, bc2 , numeric, output = array 0, 0.25, 0.5, 0.75, 1
O

You might also like