## Maxima – 133 – Funzioni numeriche – 5 Continuo da qui, copio dal Reference Manual, PDF scaricabile da qui, sono a p.395.

`ploteq (exp, options...)`
Plots equipotential curves for `exp`, which should be an expression depending on two variables. The curves are obtained by integrating the differential equation that define the orthogonal trajectories to the solutions of the autonomous system obtained from the gradient of the expression given. The plot can also show the integral curves for that gradient system (option `fieldlines`).

This program also requires Xmaxima, even if its run from a Maxima session in a console, since the plot will be created by the Tk scripts in Xmaxima. By default, the plot region will be empty until the user clicks in a point (or gives its coordinate with in the set-up menu or via the `trajectory_at` option).

Most options accepted by `plotdf` can also be used for `ploteq` and the plot interface is the same that was described in `plotdf`.

``````(%i1) V: 900/((x+1)^2+y^2)^(1/2)-900/((x-1)^2+y^2)^(1/2)\$

(%i2) ploteq(V,[x,-2,2],[y,-2,2],[fieldlines,"blue"])\$`````` Clicking on a point will plot the equipotential curve that passes by that point (in red) and the orthogonal trajectory (in blue).

`rk (ODE, var, initial, domain)`
`rk ([ODE1, . . . , ODEm], [v1, ..., vm], [init1, ..., initm], domain)`
The first form solves numerically one first-order ordinary differential equation, and the second form solves a system of `m` of those equations, using the 4th order Runge-Kutta method. `var` represents the dependent variable. `ODE` must be an expression that depends only on the independent and dependent variables and defines the derivative of the dependent variable with respect to the independent variable.

The independent variable is specified with `domain`, which must be a list of four elements as, for instance `[t, 0, 10, 0.1]`the first element of the list identifies the independent variable, the second and third elements are the initial and final values for that variable, and the last element sets the increments that should be used within that interval.

If `m` equations are going to be solved, there should be `m` dependent variables `v1, v2, ..., vm`. The initial values for those variables will be `init1, init2, ..., initm`. There will still be just one independent variable defined by `domain`, as in the previous case.

`ODE1, ..., ODEm` are the expressions that define the derivatives of each dependent variable in terms of the independent variable. The only variables that may appear in those expressions are the independent variable and any of the dependent variables. It is important to give the derivatives `ODE1, ..., ODEm` in the list in exactly the same order used for the dependent variables; for instance, the third element in the list will be interpreted as the derivative of the third dependent variable.

The program will try to integrate the equations from the initial value of the independent variable until its last value, using constant increments. If at some step one of the dependent variables takes an absolute value too large, the integration will be interrupted at that point. The result will be a list with as many elements as the number of iterations made. Each element in the results list is itself another list with `m+1` elements: the value of the independent variable, followed by the values of the dependent variables corresponding to that point.

To solve numerically the differential equation With initial value `x(t=0) = 1`, in the interval of `t` from `0` to `8` and with increments of `0.1` for `t`, use:

``````(%i3) results: rk(t-x^2,x,1,[t,0,8,0.1])\$

(%i4) plot2d ([discrete, results])\$`````` the results will be saved in the list `results` and the plot will show the solution
obtained, with `t` on the horizontal axis and `x` on the vertical axis.

To solve numerically the system: for `t` between `0` and `4`, and with values of `-1.25` and `0.75` for `x` and `y` at `t=0`:

``````(%i5) sol: rk([4-x^2-4*y^2,y^2-x^2+1],[x,y],[-1.25,0.75],[t,0,4,0.02])\$

(%i6) plot2d ([discrete,makelist([p,p],p,sol)], [xlabel,"t"],[ylabel,"y"])\$`````` Posta un commento o usa questo indirizzo per il trackback.