English: Compares the forward/explicit and backward/implicit Euler methods for the numerical solution of the ODE y'(x)=-200*(y-cos(x))-sin(x), y(0)=1.
With the substituton z=y-cos(x), the ODE z'=-200*z, z(0)=0, results. Numerical integration of the second ODE should always result in the constant 0. By the nonlinear substitution in the first ODE, numerical errors are introduced in every step that are magnified by the factor 200. For not too small stepsizes, this results in explosive behavior of the explicit method whereas the implicit method remains close to the exact solution.
ייחוס – יש לתת ייחוס הולם, לתת קישור לרישיון, ולציין אם נעשו שינויים. אפשר לעשות את זה בכל צורה סבירה, אבל לא בשום צורה שמשתמע ממנה שמעניק הרישיון תומך בך או בשימוש שלך.
שיתוף זהה – אם תיצרו רמיקס, תשנו, או תבנו על החומר, חובה עליכם להפיץ את התרומות שלך לפי תנאי רישיון זהה או תואם למקור.
מוענקת בכך הרשות להעתיק, להפיץ או לשנות את המסמך הזה, לפי תנאי הרישיון לשימוש חופשי במסמכים של גנו, גרסה 1.2 או כל גרסה מאוחרת יותר שתפורסם על־ידי המוסד לתוכנה חופשית; ללא פרקים קבועים, ללא טקסט עטיפה קדמית וללא טקסט עטיפה אחורית. עותק של הרישיון כלול בפרק שכותרתו הרישיון לשימוש חופשי במסמכים של גנו.http://www.gnu.org/copyleft/fdl.htmlGFDLGNU Free Documentation Licensetruetrue
הנכם מוזמנים לבחור את הרישיון הרצוי בעיניכם.
Source
Using a small C program and gnuplot.
exp_imp_euler.c
/*implizites und explizites Eulerverfahren für y'(x)=-2000*(y-cos(x))-sin(x)*/#include<stdio.h>#include<math.h>#define ALPHA 200doublef(doublex,doubley){return-ALPHA*(y-cos(x))-sin(x);}doubleexplicit(doublex,doubley,doubleh){returny+h*f(x,y);}doubleimplicit(doublex,doubley,doubleh){/* solve yp=y+h*f(xp,yp) for yp explicit solution is y=yp-h*f(xp,yp) =(1+2000*h)*yp-2000*h*cos(xp)+h*sin(xp) */doublexp=x+h;return(y+h*(ALPHA*cos(xp)-sin(xp)))/(1+ALPHA*h);}intmain(){doublex,ye,yi,h;FILE*fp=fopen("imp_euler.dat","w");x=0;ye=yi=1;h=1.2e-2;for(;x<1;x+=h){fprintf(fp,"%8.5f\t%8.5f\t%8.5f\t%8.5f\n",x,cos(x),ye,yi);ye=explicit(x,ye,h);yi=implicit(x,yi,h);}return0;}
{{Information |Description={{en|1=Compares the forward/explicit and backward/implicit Euler methods for the numerical solution of the ODE y'(x)=-200*(y-cos(x))-sin(x), y(0)=1. With the substituton z=y-cos(x), the ODE z'=-200*z, z(0)=0, results. Numerica