You have to do evaluate=False because Pow(E, x) is automatically converted to exp() otherwise.
You can use something like expr.replace(exp, lambda x: Pow(E, x, evaluate=False)). Aaron Meurer On Sat, Apr 4, 2015 at 11:36 PM, G B <[email protected]> wrote: > If I'm understanding my problem correctly, I think I actually want it to > evaluate... Is there a way to ask sympy to find all occurrences of exp() in > an expression and replace them with Pow(E,...) or E**? > > I've tried messing with replace, but I'm not sure I've got the syntax > right... > > Alternatively, can I force evalf to drill down into the exp() arguments? > > On Saturday, April 4, 2015 at 5:37:24 PM UTC-7, Aaron Meurer wrote: >> >> Seems like another thing that >> https://github.com/sympy/sympy/issues/4898 would fix. I think the only >> way to create E**x is to use Pow(E, x, evaluate=False). >> >> The lambdify thing might be a separate bug. >> >> Aaron Meurer >> >> On Sat, Apr 4, 2015 at 5:04 PM, G B <[email protected]> wrote: >> > Hi-- >> > >> > exp() doesn't seem to evalf its arguments when evalf is called on it. >> > This >> > is probably a bug, and if so I'll file an issue. In the mean time, is >> > there >> > an easy way to get sympy to convert exp(x) expressions to E**x >> > expressions? >> > >> > exp(t*sqrt(5)).n() -> exp(t*sqrt(5)) >> > >> > E**(t*sqrt(5)).n() -> E**(2.23606797749979*t) >> > >> > I think this is causing me some trouble when converting complex >> > expressions >> > to numpy via lambdify. I'm trying to lambdify a result from dsolve that >> > includes square roots of very large integers (not sure where those large >> > integers are coming from). When I try to execute the result, I get >> > "AttributeError: 'int' object has no attribute 'sqrt'". >> > >> > I'll see if I can get the lambdify to trip up with a simple set of >> > inputs. >> > Right now this is the culmination of a 100 cell IPython notebook... >> > >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups >> > "sympy" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> > an >> > email to [email protected]. >> > To post to this group, send email to [email protected]. >> > Visit this group at http://groups.google.com/group/sympy. >> > To view this discussion on the web visit >> > >> > https://groups.google.com/d/msgid/sympy/e312e981-3e7b-4e6f-ae69-984c7e7ad9fc%40googlegroups.com. >> > For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sympy. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/20ecfb7f-0284-4f69-9d0e-4bd8cb21dbbe%40googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6%2BmAAyWD52FeLf9t4K3452nnx6Txc8%3DLKH3Nnw3s7gWcw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
