How to add "erf()" part to the ode solution?

조회 수: 1 (최근 30일)
Ali Deniz
Ali Deniz 2022년 10월 19일
댓글: Ali Deniz 2022년 10월 20일
Hi,
I have the ODE : y' = -x+2+10*e^(10*(x-1)^2)
I have numeric solution of below:
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:
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.

채택된 답변

Torsten
Torsten 2022년 10월 19일
편집: Torsten 2022년 10월 19일
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)
sol = 
fplot(sol,[0 6])
  댓글 수: 3
Les Beckham
Les Beckham 2022년 10월 19일
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
Ali Deniz
Ali Deniz 2022년 10월 20일
Thank you very much.
-Ali

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by