From \"Differential Equations With Matlab\", Hunt ODE 45 integrates the system o
ID: 3108779 • Letter: F
Question
From "Differential Equations With Matlab", Hunt
ODE 45 integrates the system of differential equations y'=f(t,y) from t0 to tf with initial conditions y0. Each row in the solution array y corresponds to a value returned in column vector t.
The error function erf of x is erf(x)=2/squareroot pi integral^x_0 e^-t^2 dt. erf(x) erf(x) returns the error function evaluated for each elementof x. Solve nonstiff differential equations - medium order method [t, y]= ode45 (ode fun.tspan, y 0) [t, y]= ode45 (odefun.tspan, y0, options) [t, y, te, ye, ie]= ode45 (odefun.tspan, y0, options) sol = ode45(___) The function erf, discussed in Chapter 5 and in Problem 8 in this set, is the solution to the initial value problem dy/dt=2/squareroot pi e^-t^2, y(0)=0, so if we solve this initial value problem numerically we get approximate values for the built-in function erf. Use ode45, employing the accuracy options discussed in Chapter 7, to calculate values for erf(0.1), erf(0.2), ..., erf(l) having at least 10 correct digits. Present your results in a table. In a second column print the values of erf(x) for x = 0.1, 0.2, ..., 1, obtained by using the built-in function erf. Compare the two columns of values.Explanation / Answer
matlab code :
clc;
clear all;
close all;
format long
tspan=0:0.1:1;
y0=0;
[t,y]=ode45(@(t,y) 2/sqrt(pi)*exp(-t^2),tspan,y0);
g=erf(tspan)';
Result:
t value using ode45 using erf(x)
0 0 0
0.100000000000000 0.112462907543300 0.112462916018285
0.200000000000000 0.222702581918710 0.222702589210478
0.300000000000000 0.328626754034792 0.328626759459127
0.400000000000000 0.428392351926769 0.428392355046668
0.500000000000000 0.520499877142764 0.520499877813047
0.600000000000000 0.603856092483087 0.603856090847926
0.700000000000000 0.677801197390138 0.677801193837418
0.800000000000000 0.742100969623544 0.742100964707661
0.900000000000000 0.796908218073471 0.796908212422832
1.000000000000000 0.842700793289598 0.842700792949715
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.