The polar coordinates
and can be converted to the Cartesian coordinates and using the trigonometry functions:
It follows that a figure specified in
can be plotted by ‘plot2d’ as a parametric curve:
It is possible to plot two or more parametric curves together:
An alternate is the ‘draw2d’ function, it draws graphic objects created by the ‘polar’ function:
Fig. 4 shows a graceful geometric curve that resembles a butterfly. Its equation is expressed in polar coordinates by
It is possible to combine two or more plots into one picture.
For example, we solve the following initial-value problem
and plot the analytic solution in Fig. 1.
We can also solve
numerically and plot the discrete data points:
Fig. 3 is the result of combining Fig.1 and Fig. 2.
It validates the numerical solution obtained by ‘rk’: the two figures clearly overlapped.
Besides ‘ode2’, ‘contrib_ode’ also solves differential equations.
While ‘ode2’ fails:
This is an example taking from page 4 of Bender and Orszag’s “
Advanced Mathematical Methods for Scientists and Engineers“. On the same page, there is another good example:
is a constant.
Using ‘contrib_ode’, we have
It seems that ‘contrib_ode’ is a better differential equation solver than ‘ode2’:
Even though it is not perfect:
From the examples, we see the usage of ‘contrib_ode’ is the same as ‘ode2’. However, unlike ‘ode2’, ‘contrib_ode’ always return a
list of solution(s). It means to solve either initial-value or boundary-value problem, the solution of the differential equation is often lifted out of this list first:
Exercise Solve the following differential equations without using a CAS:
(hint: Riccati Equation)
As far as I know, ‘bc2’, Maxima’s built-in function for solving two-point boundary value problem only handles the type:
For example, solving
But ‘bc2’ can not be applied to
since it is not the type of (*). However, you can roll your own:
An error occurs on the line where the second boundary condition is specified. It attempts to differentiate the solution with respect to
under the context that . i.e.,
which is absurd.
The correct way is to express the boundary conditions using ‘at’ instead of ‘ev’:
The following works too as the derivative is obtained before using ‘ev’:
Nonetheless, I still think using ’at’ is a better way: