# [Maxima] Timing comparison for diffeq program in c++, Maple and Maxima

Dennis Darland dennis.darland at yahoo.com
Thu Aug 9 17:51:21 CDT 2012

```I got bfloats to work with trig function. Same answer with Maple and Maxima anyway with 50 digits. C++ doesn't have that, but I suppose there are probably libraries for C++. Would take some work to implement in omnisode. The built-in help was more useful than the manual had been.

Dennis J. Darland
dennis.darland at yahoo.com
http://dennisdarland.com/
http://dennisdarland.com/dennisdaze/
http://dennisdarland.com/philosophy/
http://sode.sourceforge.net/
"According to the World Health Organization, the warming of the planet caused an additional 140,000 deaths in 2004, as compared with the number of deaths there would have been had average global temperatures remained as they were during the period 1961 to 1990. This means that climate change is already causing, every week, as many deaths as occurred in the terrorist attacks on September 11, 2001"
-- Peter Singer _Practical Ethics, Third Edition_, p. 216.

--- On Thu, 8/9/12, Richard Fateman <fateman at eecs.berkeley.edu> wrote:

> From: Richard Fateman <fateman at eecs.berkeley.edu>
> Subject: Re: [Maxima] Timing comparison for diffeq program in c++, Maple and Maxima
> To: "Dennis Darland" <dennis.darland at yahoo.com>
> Cc: maxima at math.utexas.edu, "Rupert Swarbrick" <rswarbrick at gmail.com>
> Date: Thursday, August 9, 2012, 11:33 AM
> On 8/9/2012 7:18 AM, Dennis Darland
> wrote:
> > I am using just basic math like you say. In maple I can
> use higher precision floating point by setting "Digits".
> (Though it only seems to work up to about 32 digits). I
> expected to be able to do something similar in Maxima.
> Maxima does have "big floats". I tried them, but, as far as
> I could tell, they did not support trig functions, etc. (You
> only get about 16 digits and a lot of warning messages).
> bigfloats work with trig functions, but the compiler works
> on (declared)
> machine floats.
>
> >    If  big floats can me made to support
> trig functions, etc., I would like to know about it.
> Sure. don't compile that part.
> >   I plan to look also for a c++ library
> for extended precision floating point numbers.
> There are libraries for quad double and also arbitrary
> precision like MPFR.
> I doubt that these are really the first port of call for
> improving the
> code for this application (solving ODEs)
> >   I am also interested in what is called
> "interval arithmetic."
> Same comment.
> >
> > I also used Maxima as well as Maple as it is more
> affordable, and I like to support open source. I am not
> trying to criticize Maple or Maxima, only to ascertain the
> facts. It is interesting that c++ is so much faster, in that
> it makes solving some problems more practical.
> If your program is oriented toward producing C code, then it
> is quite
> reasonable to
> expect that the C code it produces will run fastest with a C
> compiler,
> and simulating
> this environment on Maxima or Maple can be quite slow unless
> those
> programs can
> take advantage of the knowledge that "everything is simply a
> number"  and no
> symbolic computation at all should happen.
> >
> > The program was debugged in Maple and Maxima together.
> Both, in some cases gave better error messages than the
> other. I doubt I could have debugged it in c or c++, which
> most likely have crashed instead of giving an error message.
> (The code to generate c or c++ is not released yet, as I am
> just beginning to test it, but it seems to work OK so far)
> >
> > The reason I started subscripts at 1 was Dr Chang's
> work started subscripts at 1, and thus it was a lot easier.
> I used the formulas from his draft of a book he started. He
> was working in FORTRAN, but my program is not at all a
> translation of his program. (He wrote as program in FORTRAN
> which generated a FORTRAN program,) His program is beyond my
> comprehension.  Also other languages I may want to use
> in the future may not permit "0" subscripts. I doubt I will
> ever support FORTRAN.
> >
> > Dennis J. Darland
> > dennis.darland at yahoo.com
> > http://dennisdarland.com/
> > http://dennisdarland.com/dennisdaze/
> > http://dennisdarland.com/philosophy/
> > http://sode.sourceforge.net/
> > "According to the World Health Organization, the
> warming of the planet caused an additional 140,000 deaths in
> 2004, as compared with the number of deaths there would have
> been had average global temperatures remained as they were
> during the period 1961 to 1990. This means that climate
> change is already causing, every week, as many deaths as
> occurred in the terrorist attacks on September 11, 2001"
> > -- Peter Singer _Practical Ethics, Third Edition_, p.
> 216.
> >
> >
> > --- On Thu, 8/9/12, Rupert Swarbrick <rswarbrick at gmail.com>
> wrote:
> >
> >> From: Rupert Swarbrick <rswarbrick at gmail.com>
> >> Subject: Re: [Maxima] Timing comparison for diffeq
> program in c++, Maple and Maxima
> >> To: maxima at math.utexas.edu
> >> Date: Thursday, August 9, 2012, 7:32 AM
> >> Dennis Darland <dennis.darland at yahoo.com>
> >> writes:
> >>> I ran a timing test comparison for c++, Maple
> and
> >> Maxima.
> >>> All three programs generated by omnisode - a
> set of
> >> Ruby programs.
> >>> Set time limit to 1 minute.
> >>> Maximum iteration was sufficient to solve
> entire
> >> problem.
> >>> Problem was sin.ode for all three.
> >>> Output was redirected to file only - none to
> screen
> >>> Results:
> >>> c++ solved entire problem in 23 seconds
> (140001
> >> iterations)
> >>> Maple performed 11542 iterations in 60 seconds
> >>> Maxima performed 372 iterations in 60 seconds
> >>> That amounts to:
> >>> c++ 6,087 iterations/second
> >>> Maple 192 iterations/second
> >>> Maxima 6.2 iterations/second
> >>> c++ is almost 32 times faster than Maple which
> is
> >> almost 31 times faster than Maxima.
> >>> So c++ is almost 982 times faster than Maxima.
> >>>
> >>> http://sode.sourceforge.net/
> >> Right, I just tried to look up the Maxima code
> you're
> >> generating and
> >> found things like [1]. Since I'm clearly not going
> >> through that
> >> carefully, and I presume no-one else is either, can
> you
> >> explain exactly
> >> what you're measuring?
> >>
> >> Your code looks to me like a C/FORTRAN program
> translated
> >> to
> >> Maxima. Unsurprisingly, it runs very slowly. What
> are you
> >> actually
> >> trying to do? What capabilities of Maple or Maxima
> are you
> >> using other
> >> than basic arithmetic?
> >>
> >> Or should we interpret your message as
> >>
> >>    "Writing bare-metal calculations in
> Maple and running
> >> them is
> >>     marginally less slow that
> writing them in
> >> Maxima and running
> >>     them. But it would have
> been easier to do
> >> it in C anyway"
> >>
> >>   ?
> >>
> >>
> >> Rupert
> >>
> >> [1] http://sode.sourceforge.net/omniresults/special_cases_007/diffeq.tan_sqrt_lin.mxt.txt
> >>
> >> -----Inline Attachment Follows-----
> >>
> >> _______________________________________________
> >> Maxima mailing list
> >> Maxima at math.utexas.edu
> >> http://www.math.utexas.edu/mailman/listinfo/maxima
> >>
> > _______________________________________________
> > Maxima mailing list
> > Maxima at math.utexas.edu
> > http://www.math.utexas.edu/mailman/listinfo/maxima
>
>
```