Hi. On Fri, Nov 11, 2011 at 3:53 AM, vweber <[email protected]> wrote: > Dear all > > Few questions: > > 1) exectuting that >> x = symbols('x') >> z=1.0*x**(-1.0) >> print fcode(simplify(z)) > > gives > >> 1.0d0*x**-1.0d0 > > which is not fortran standard.. I would expect 1.0d0/x or x**(-1) or > in the worst case x**(-1.0d0). How can I get a better output?
This is a bug. There is an issue for it at http://code.google.com/p/sympy/issues/detail?id=2823. The suggestions here may help you work around it. Or, a better solution would be to fix the bug. It is probably not difficult, you just need to add a condition in the code printer to add parenthese for negative powers. Aaron Meurer > > 2) executing that >> x = symbols('x') >> z=x**2 >> print fcode(simplify(diff(z))) > > gives > >> 2*x > > I would like to get 2.0d0*x instead, any hints? > > 3) executing >> x = symbols('x') >> z=1.0*x**(1.0/3.0) >> print fcode(simplify(z)) > > gives > >> 1.0d0*x**0.333333333333333d0 > > but I would like to keep the exponent as a fraction (ie > x**(1.0d0/3.0d0)) > > Thanks > > V > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
