P_Sampras

10 Reputation

5 Badges

11 years, 294 days

MaplePrimes Activity


These are questions asked by P_Sampras

Below is my code for solving a solution of three first order ODEs using the 4th-order Runge-Kutta method.

I have been able to successfully plot the solutions of each of the ODEs (x,y,z) against time t, however I am struggling to produce a plot in the three dimensional phase domain of x,y,z. Could anybody suggest what commands to use as everything I have tried (plot, plot3d, implicitplot3d etc) has produced an error. 

h:= 0.01:
N:= 200:
x:=Vector(N+1):

Hi,

I have a second order differential equation

d2y/dt2 = -6.478831125*sin(y)

to be solved numerically. I've successfully been able to solve it using the 4th order Runge-Kutta method, however it is not properly written as a procedure and I'm unsure of how to do this.

So far I have:

R:= -6.478831125
z[0]:= 0:
y[0]:= Pi/2:
h:= 0.01:
t:= 10:
for i from 0 to t-1 by 1 do
c0:= evalf(h*R*sin(y[i])):
k0:= evalf(h*(z[i])):

I am attempting to write a procedure for the numerical integration methods of the composite trapezoidal rule and Simpson's 1/3 rule, however the results that are being produced when I try to test the procedure are differing to the computed integral using the int command.

Here is my attempt so far:

 

> f:= x -> cos(x)*exp(-x/4):


> CompTrap:= proc(f,a,b,n)
local i, aa, h;
h:= (b-a)/n;
aa:= f(a)+f(b);

for i from 1 to n by 1 do

Page 1 of 1