Question: Homework 1 0 : ODE Algorithms ( due by email before the lecture on Mon, April 2 2 ) Write your own rk 2 method.

Homework 10: ODE Algorithms
(due by email before the lecture on Mon, April 22)
Write your own rk2 method. Design your method for a general ODE; this means making the derivative function f(t,x) a separate method.
Use your rk22 solver in a program that solves the equation of motion (a second-order ODE) for a charged particle moving in a variable external electric field within an anharmonic trapping potential given by:
md2xdt2=Fext(x,t)-kxp-1
where p=4 and Fext=-qEx2; assume q=m=k=1 and E=5 for simplicity and assume that the motion starts at x(0)=0 with the particle velocity x'(0)=1.
3. Plot the position of the particle x(t) for the first 10 seconds of motion to 10). Find the turning points of the motion ( min and max of the position, x(t)).
4. Solve the same equation using the rk4 and rk45 solvers (use the code in the course textbook and/or implementation in SciPy). Plot the three solutions (rk2, rk4, and rk45) in one figure and the relative error of rk2 vs rk4(or rk45) in another figure.
5. Time the three methods and report their execution times.
Homework 1 0 : ODE Algorithms ( due by email

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!