How to numerically solve differential equs with MAPLE ?

In summary: I'm really a novice with Maple. This is not allowed on this forum. If you want to share your code, you can post it in a separate thread and invite others to help translate it to Maple.
  • #1
Barnak
63
0
I need help with the Maple maths software, which I don't know very well. I need to numerically solve a system of three second order differential equations, specifically with Maple. I have to write a code which numerically solves the Newton's equation, using some initial conditions, and then show the numerical trajectory as a 3D plot. How am I supposed to do that?

More specifically, consider the following three coupled differential equations:

[itex]\frac{d^2 x(t)}{dt^2} = F_x(x(t), y(t), z(t))[/itex]

[itex]\frac{d^2 y(t)}{dt^2} = F_y(x(t), y(t), z(t))[/itex]

[itex]\frac{d^2 z(t)}{dt^2} = F_z(x(t), y(t), z(t))[/itex]

where [itex]F_x(x, y, z)[/itex], [itex]F_y(x, y, z)[/itex] and [itex]F_z(x, y, z)[/itex] are three specific functions (which should be specified in the Maple code). The initial conditions are also given:

[itex]x(0) = C_1[/itex],
[itex]y(0) = C_2[/itex],
[itex]z(0) = C_3[/itex],
[itex]v_x(0) = C_4[/itex],
[itex]v_y(0) = C_5[/itex],
[itex]v_z(0) = C_6[/itex].

Here, the six constants [itex]C_i[/itex] are arbitrary, but they should be specified as some real numbers in the Maple code.

How to program Maple so it can solves the previous equations and show the trajecory in some 3D graph ? I need a complete and explicit code to do this, because I'm really a novice with Maple. :cry:

In the particular case of Mathematica (a rival of Maple), I know how to do it. The following code gives the complete solution to my problem, except that I need the Maple code which can do the same. How to translate this code to Maple language ? Please, be specific. The answer will certainly help a lot of other people!

Code:
Pos[ x_, y_, z_] := {x, y, z}

r[x_, y_, z_] := Sqrt[x^2 + y^2 + z^2]

Velocity[t_] := {x'[t], y'[t], z'[t]}MagnMoment := {0, 0, 1}

MagneticField[ x_, y_, z_] := 3 (MagnMoment.Pos[x, y, z]) Pos[x, y, z]/r[x, y, z]^5 - MagnMoment/r[x, y, z]^5

MagneticCoupling := 0

GravitationCoupling := 1

FrictionCoupling := 0.005

GravitationalForce[t_] := - GravitationCoupling Pos[x[t], y[t], z[t]]/r[x[t], y[t], z[t]]^3

MagneticForce[t_] := MagneticCoupling Cross[Velocity[t], MagneticField[x[t], y[t], z[t]]]

Friction[t_] := - FrictionCoupling Velocity[t]

Force[t_] := GravitationalForce[t] + MagneticForce[t] + Friction[t]

Fx[t_] := {1, 0, 0}.Force[t]
Fy[t_] := {0, 1, 0}.Force[t]
Fz[t_] := {0, 0, 1}.Force[t]

Time1 := 0
Time2 := 200

X0 := 3
Y0 := 0.1
Z0 := 5
Vx0 := -0.5
Vy0 := 0
Vz0 := 0

Trajectory = NDSolve[{

x''[t] == Fx[t],

y''[t] == Fy[t],

z''[t] == Fz[t],

x[0] == X0,
y[0] == Y0,
z[0] == Z0,

x'[0] == Vx0,
y'[0] == Vy0,
z'[0] == Vz0

}, {x,y,z}, {t,Time1,Time2}, Method -> ExplicitRungeKutta, MaxSteps->10000]

To trace the trajectory in 3D, the Mathematica code is bellow :
Code:
PTmin := (x /. Trajectory)[[1]][[1]][[1]][[1]]
PTmax := (x /. Trajectory)[[1]][[1]][[1]][[2]]

ParametricPlot3D[Evaluate[{x[t], y[t], z[t]} /. Trajectory], {t, PTmin, PTmax}, PlotPoints -> 10000]
 
Last edited:
Physics news on Phys.org
  • #2
Nobody here ? Is this forum dead ?
 
  • #3
  • #4
Why have you "trashed" Maple ? I'm curious (as a Mathematica user), since I'm yet unable to get help on this topic. Is Maple a not-so-good-math software, compared to Mathematica ?
 
  • #5
I did not "trash" Maple. I'm migrating to new hardware and things are a mess right now. People fiercely argue about which X is better for almost every X. I don't need to go there.

Ten or twenty years ago someone did a huge amount of work to compare half a dozen computer algebra systems. He concluded that for anyone of these you needed up to thousands of hours of intense work to become an expert and that being an expert in one did not provide you much expertise in using another one.

I could try to tell you how to translate your Mathematica, but I don't want to take the chance of being wrong when I cannot compare the output from both to make sure there are no errors. Sorry.
 
  • #6
maple code for this problem is not going to be much different from the code you have written for mathematica...instead in maple its much easier..
i don't know providing the complete solution to the problems is allowed here or not..
 
  • #7
Ok. Thanks anyway.

Any other able to translate the code above, Mathematica -> Maple ?

I have the feel it should be relatively easy, since this is just about solving numerically Newton's equations with some initial conditions. The forces functions are just arbitrary, but may be usefull to show some "popular" physics (gravitation from a planet, a Lorentz magnetic force from a dipolar magnetic field, and a friction force). The graphical outputs are very cool, when you change the various parameters (three constants).
vishal007win said:
i don't know providing the complete solution to the problems is allowed here or not..

Huh ? Why not ??

The Mathematica code given above is from myself. I need the proper Maple syntax to make a conversion.
 
Last edited:
  • #9
People have (rarely) discussed compilers that would translate one computer algebra system to another. The conclusion always seems to be that for very simple things this would be feasible, but when you start getting near the subtle sometimes bizarre details of anyone of the systems that the translation becomes far more difficult and likely impossible to ensure that it can be done exactly correctly and that it would be impossible to tell the user exactly how much had been correctly translated.
 
  • #10
The following code is *almost* working ! However, I'm getting an error and I suspect there's something missing (what about the time interval for the resolution ?). Please help !:rolleyes:

Code:
PDEtools[declare]((x, y, z)(t), prime = t);
r(x, y, z) := sqrt(x^2 + y^2 + z^2);
Vitesse(t) := [x'(t), y'(t), z'(t)];

MomentMagn := [0, 0, 1];
ChampMagnetique(x, y, z) := 3 dotprod(MomentMagn, [x, y, z]) * [x, y, z]/r(x, y, z)^5 - MomentMagn/r(x, y, z)^3;

CouplageMagnetique := 0;
CouplageGravitation := 1;
CouplageFrottement := 0.005;

ForceGravitationnelle(t) := - CouplageGravitation * [x(t), y(t), z(t)]/r(x(t), y(t), z(t))^3;
ForceMagnetique(t) := CouplageMagnetique * crossprod(Vitesse(t), ChampMagnetique(x(t), y(t), z(t)));
Frottement(t) := - CouplageFrottement * Vitesse(t);
Force(t) := ForceGravitationnelle(t) + ForceMagnetique(t) + Frottement(t);

EquationsNewton := (diff(diff(x(t), t), t) = dotprod([1, 0, 0], Force(t)), diff(diff(y(t), t), t) = dotprod([0, 1, 0], Force(t)), diff(diff(z(t), t), t) = dotprod([0, 0, 1], Force(t)]);

Temps1 := 0;
Temps2 := 200;

ConditionsInitiales := [X0 = 3, Y0 = 0.1, Z0 = 5, Vx0 = -0.5, Vy0 = 0, Vz0 = 0];
Trajectoire = dsolve(EquationsNewton, ConditionsInitiales, [x(t), y(t), z(t)], type = numeric);

The compilation gives me this error message :
x(t) will now be displayed as x
y(t) will now be displayed as y
z(t) will now be displayed as z
derivatives with respect to t of functions of one variable will now be

displayed with '
Error, (in RealRange) invalid arguments
Error, (in dsolve/numeric/process_input) missing differential equations and initial or boundary conditions in the first argument: EquationsNewton
 
Last edited:

Related to How to numerically solve differential equs with MAPLE ?

1. What is MAPLE and how can it help me solve differential equations?

MAPLE is a computer algebra system that is commonly used by scientists and mathematicians to solve complex mathematical problems, including differential equations. It has powerful numerical and symbolic computation capabilities that make it an ideal tool for solving differential equations.

2. Can MAPLE solve all types of differential equations?

Yes, MAPLE has the ability to solve a wide range of differential equations, including ordinary differential equations (ODEs), partial differential equations (PDEs), and boundary value problems (BVPs). It also has built-in functions for solving specific types of equations, such as linear and non-linear equations.

3. How do I input a differential equation into MAPLE?

To input a differential equation into MAPLE, you can use the "dsolve" function. This function takes in the differential equation and any initial conditions or boundary conditions, and returns a solution in the form of an equation or a numerical solution.

4. How accurate are the numerical solutions obtained from MAPLE?

The accuracy of the numerical solutions obtained from MAPLE depends on several factors, such as the complexity of the equation, the precision settings used, and the type of numerical method used. Generally, MAPLE provides highly accurate solutions, but it is recommended to check the results for consistency and sensitivity to initial conditions.

5. Can I visualize the solutions of differential equations using MAPLE?

Yes, MAPLE has a built-in plotting function that allows you to visualize the solutions of differential equations in 2D or 3D. You can also use this function to plot the behavior of a solution over a specific time interval or to compare multiple solutions.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
275
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
307
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
481
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • Calculus and Beyond Homework Help
Replies
8
Views
288
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
Back
Top