I have to write application which solves task presented below. I only know some c# so I will stick to it. It is some kind of homework but I am asking for help with understanding this and advice for implementation. Take natural n>=1 and real a>1 differential problem y′(x)=f(x,y(x)),y(1)=0 where f(x,y)=sqrt(y+1)+x solve for [1,a] with step h=a−1/n with Euler and Heun methods. Compare results with exact solution y(x)=x^2−1 by finding maximum error of each method.
kaltEvallwsr
Answered question
2022-11-13
I have to write application which solves task presented below. I only know some c# so I will stick to it. It is some kind of homework but I am asking for help with understanding this and advice for implementation.
Take natural and real differential problem
where solve for with step with Euler and Heun methods.
Compare results with exact solution by finding maximum error of each method.
Answer & Explanation
hocelwsmjc
Beginner2022-11-14Added 16 answers
You are being asked to write a program that allows a user to select between the Euler and Heun (Improved Euler) Method and allows the user to input two parameters, and .
These two parameters affect the output of the program and the results of the calculations.
The Euler Method is given by:
The algorithm to code up is: Input Input
For
For example:
This yields:
When you compare this to the actual result, you get:
For the Heun Method, you need only change the iteration formula to:
Repeating the same example as above, yields:
Error (a much better result).
Of course, you can play around with and once you have it coded up and see the impacts of changing those two parameters on the results, which is intended to teach you about numerical algorithms and errors with them.
Lastly, you need to work the maximum error based on all of the given information and the maximum error of each algorithm and the parameters and , but I'll leave that to you.