How to add "erf()" part to the ode solution?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ali Deniz
am 19 Okt. 2022
Kommentiert: Ali Deniz
am 20 Okt. 2022
Hi,
I have the ODE : y' = -x+2+10*e^(10*(x-1)^2)
I have numeric solution of below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1162108/image.jpeg)
I have a analytical solution of ODE below:
y (x)= C1 + 2*x - x^2/2 + (10^(1/2)*pi^(1/2)*erfi(10^(1/2)*(x - 1)))/2, y(0)=1
when I plot the analytical solution without "erfi()" part, the graph is below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1162113/image.jpeg)
The curve is similar to numarical solution but there is evident error. I think, this error is because of "erf" part of the analytical solution. How can I plot the analytical solution with the "erf()" part. Thank you.
0 Kommentare
Akzeptierte Antwort
Torsten
am 19 Okt. 2022
Bearbeitet: Torsten
am 19 Okt. 2022
syms x y(x)
eqn = diff(y,x) - (-x+2+10*exp(-10*(x-1)^2)) == 0;
cond = y(0)==1;
sol = dsolve(eqn,cond)
fplot(sol,[0 6])
3 Kommentare
Les Beckham
am 19 Okt. 2022
Without the symbolic toolbox:
x = linspace(0, 6, 1000);
rt = sqrt(10);
rp = sqrt(pi);
y = 2*x - x.^2/2 + (rt*rp*erf(rt))/2 + (rt*rp*erf(rt*(x-1)))/2 + 1;
plot(x,y)
grid on
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!