|
|
Re: Ask for help: how to let mathematica output Fortran code with fewest float operations?
Posted:
Jan 13, 2013 11:13 AM
|
|
On 1/13/2013 12:32 AM, Tang Laoya wrote: > When the test.f90 is outputted, the first solution of x is: >> >>x = a/3. + (-6 + 2*a**2)/(3.*2**0.6666666666666666*(-36*a + 20*a**3 +
Sqrt(4*(-6 + 2*a**2)**3 + (-36*a + 20*a**3 - 216*b)**2) - 216*b)**0.3333333333333333) -
(-36*a + 20*a**3 + Sqrt(4*(-6 + 2*a**2)**3 + (-36*a + 20*a**3 - 216*b)**2) -
216*b)**0.3333333333333333/(6.*2**0.3333333333333333)
.............. in maxima, optimize(%)
block([%1,%2,%3,%4,%5], %1:2*a^2-6, %2:-36*a, %3:20*a^3, %4:-216*b, %5:(%4+sqrt((%4+%3+%2)^2+4*%1^3)+%3+%2)^0.33333333333333,
x = -0.13228342099735*%5+0.20998684164915*%1/%5+a/3)$
There is also a (separate) program to convert Maxima expressions to something like looks like Fortran, with ** instead of ^, and continuation lines.
Maxima can be downloaded from sourceforge, free.
|
|