A simple 3D animation created with Maxima.

One of the things which I find myself doing quite often is, to be undertaking some sort of task on the computer(s), that I know is possible, but, not knowing in advance what the correct syntax and semantics are, to perform this task. This tends to take me on some sort of search on the Web, and I’ll find that other people have undertaken similar tasks, but not, a task with the same combination of parameters, as my task.

Thus, Web pages can be found according to which 2D animations have been created using a free, open-source Computer Algebra System named “Maxima”. Other Web pages may explain how to create various types of (static) 3D plots. But there may just be lacking examples out there, on how to create the 3D plot, but to animate it.

Using Maxima, there may be more than one way, such as, to keep refreshing the 3D plot over a time interval. But I find that such solutions tend to be second-rate, because of their use of busy-wait loops, as well as the possibility that they may otherwise be wasteful of computing power. I think that the best way, perhaps, to get Maxima to generate an animated 3D plot, could be, in the form of an animated GIF File (of course, as long as there isn’t an excess of frames to this animation).

Thus, the recipe that seems to work is as such:

 


load(draw)$

scenes: []$

for i thru 20 do (
    scenes: append(scenes,
            [gr3d(explicit(sin(%pi*(x+(i/10)))*cos(%pi*y),
                x, -1, 1, y, -1, 1))]
        )
)$

draw(
    delay = 10,
    file_name = "wavy",
    terminal = 'animated_gif,
    scenes
)$

 

The script outputs a file named ‘wavy.gif’ in the same folder, as whatever folder it was originally stored in. In some cases, the GIF File may appear in the user’s home directory, or even, in a temporary directory that’s difficult to find, unless the user also gives a full-path name for the file.

And, this is the GIF File that results:

wavy

 

Caution:

My most recent posting had to do, with a version of Maxima that had been ported to Android. The example above will not work with that version of Maxima. In fact, I can really only be sure that this feature works under Linux, which is the O/S that Maxima was mainly designed to run on. Any directives to ‘plot()’ or ‘draw()’ open a separate GNU-Plot window, which behaves in the predictable way under Linux, including the user’s ability to rotate the 3D plots interactively. AFAIK, commands to change to a non-default ‘terminal’ (for drawing and/or plotting) will fail on other platforms.

But, There is also a Windows or Mac alternative to using this platform, which mainly presents itself in the application ‘wxMaxima’. Here, the functions ‘wxdraw2d()’ and ‘wxdraw3d()’ replace those that open a separate window, and both embed their results in the wxMaxima worksheet. In order to make this more versatile, wxMaxima also offers the functions ‘with_slider_draw()’, ‘with_slider_draw3d()’, ‘wxanimate_draw()’, and ‘wxanimate_draw3d()’.

Potential ‘wxMaxima’ users will find the documentation for how to script that Here.

Continue reading A simple 3D animation created with Maxima.

In certain situations, Maxima can actually solve a sextic equation.

For readers who don’t know, a sextic equation is a polynomial of the 6th degree. As the subject line suggests, recent versions of Maxima can find symbolic solutions to those, if used correctly, and, if the sextic actually has ‘an exact, analytical solution’, which is also referred to sometimes as ‘a symbolic solution’.

Whether these analytical solutions are actually more useful than numeric approximations, remains an unanswered question.

What has happened to me is, that I’ve tried to use the method shown below, to cause Maxima to display the solution, and that due to what amounted to a typo, I had given it a polynomial which was visually similar to the one shown, but which was also different in some small way, so that the only solution which Maxima displayed, was the original polynomial, thus implying that Maxima was not able to solve an altered one. The reason this happened is easy to explain…

Not all polynomials of the 6th degree actually have an analytical solution. If given an example that does not, Maxima will fail to display one. All polynomials of the 4th degree actually have an analytical solution, but it may easily be too complex for consumer-grade Computer Algebra Systems (CAS) to output. But, by the time the user is asking a CAS to solve a cubic, he should be able to expect this form of a solution to be output.

The sextic below is actually the product of two cubics, which also explains why Maxima was able to solve it. The reader will need to enable JavaScript:

  • From my site, And
  • From MathJax.org,

To be able to view the worksheet:

 


 

(Updated 7/04/2020, 13h30… )


Continue reading In certain situations, Maxima can actually solve a sextic equation.

A better way to use “Maxima” to solve cubic equations…

One of the facts which I’ve pointed out in earlier postings was, that if I give the free Computer Algebra System (‘CAS’) named ‘Maxima’, a cubic equation to solve, as in, to find the exact analytical solutions to, it will fail to produce intelligible output, if the usage was naive.

More specifically, cubic equations exist that have 3 distinct, real, irrational roots, and which a ‘CAS’ should be able to solve, just because their general solution is publicly known. That solution boils down, to deriving a second cubic, which is called a ‘depressed cubic equation’, and then performing a trigonometric substitution. (:1)

A fact which I’ve also known for some time is that, especially if a person is using a free or open-source CAS, then in some cases its behaviour has not been made particularly user-friendly, in that work needs to be done by the user, to set up his or her problem for the ‘CAS’ to solve. This latter observation casts a shadow of doubt, over the question of whether a ‘CAS’ will ultimately lead experienced Mathematicians to new discoveries in Algebra, or whether this can only reduce the workload in certain situations.

In this posting I’m going to show, how ‘Maxima’ can be coerced into giving correct answers, by users who know how. What I tend to use is a Graphical Front-End to ‘Maxima’, that is itself named ‘wxMaxima’, but which has equal capabilities, except for the abilities to typeset its solutions, as well as to export its Worksheets to PDF as well as HTML format, using LaTeX.

The following embedded worksheet will only display properly in the reader’s browser, if

  • The reader has allowed JavaScript from my blog to run on his browser, and
  • The reader has also allowed JavaScript to run from a CDN named ‘mathjax.org’.

 

 


What’s observable here is the fact that the package ‘odes’ can be loaded, which is mainly used to solve Ordinary Differential Equations, and that afterwards, the function ‘solvet()’ can be used, even to solve certain polynomials – better than what Maxima can solve on its own, with the built-in ‘solve()’ function. (:3)

(Updated 6/14/2020, 0h30… )

Continue reading A better way to use “Maxima” to solve cubic equations…

Noticing when SageMath is using IPython, instead of Maxima.

One of the subjects of my recent postings, has been a Computer Algebra System called “SageMath”, which I was able to install on my Debian / Stretch (Debian 9) computer named ‘Plato’. One of the distinctions which I left slightly blurred about this, is the distinction between Computer Algebra, and Numerical Tools. The former refers to the ability of a computer to manipulate symbols, in the way Algebra manipulates them, but to solve equations which Humans might just find tedious or too time-consuming to solve. This can lead to answers that are theoretically exact, but which can sometimes be useless because the numerical equivalent is only available indirectly.

Numerical Tools are more numerous under Linux, and offer theoretically inexact solutions to equations, simply because the numerical answers have a limited number of decimal places after the point or comma. Yet, the numerical answers can sometimes be much more useful than Algebraic answers, for reasons that I think are self-explanatory.

SageMath offers both. In order to do Algebra, SageMath uses “Maxima” as its back-end. And under Debian Linux, installing SageMath actually installs a separate version of Maxima, which users are not supposed to use directly.

Continue reading Noticing when SageMath is using IPython, instead of Maxima.