Thanks, Ondrej.  In my case the coefficients are the result of a series of 
calculations earlier in the notebook.  They are symbolic up until the call 
to dsolve, but I am substituting values in right before the dsolve because 
it takes several minutes to return a solution otherwise (and gives a very 
complicated solution over a segmented domain).

I let it run to completion symbolically and tried substituting into the 
result and I do get something that looks more reasonable.  I can also run 
it through lambdify and plot the result.  So despite the slow computation, 
at least it looks like I can continue what I'm doing.

Any idea why the huge integers though?  I seem to remember somewhere that 
Sympy will try to convert floats to rationals under certain conditions.  Is 
that what's happening?  Can I turn that behavior off?

Any insight into why it won't evalf or lamdify if I substitute before 
dsolve rather than after?

Thanks, again!

On Saturday, April 4, 2015 at 9:27:07 PM UTC-7, G B wrote:
>
> Still wrestling with dsolve...  Below is a call with an arbitrary 
> differential equation.  Any idea why dsolve is returning terms with these 
> enormous integers?  All of the coefficients are floats in this case.  The 
> expression is impervious to .n() (as mentioned in my earlier question). 
>  Converting to a numpy function to evaluate the results works, but throws 
> an exception when called.
>
> I can't seem to get past this point in the analysis.  Any idea how I can 
> get this into a form I can continue working with?
>
> A=symbols(r'A',cls=Function)
> t=symbols(r't')
> Eq4=-123456.78*A(t)-9876.54*A(t).diff(t)-0.00032*A(t).diff(t,2)+1357908.64
> soln=dsolve(Eq4)
> print(soln.n())
>
> A(t) == C1*exp(125*t*(-33935533038108675 - 
> sqrt(1151618536954453541512853661417481))/274877906944) + 
> C2*exp(125*t*(-33935533038108675 + 
> sqrt(1151618536954453541512853661417481))/274877906944) + 10.999060885923
>
>
> fn=lambdify(t,soln.rhs,'numpy')
>
>
> fn(3.2)
>
>
> ---------------------------------------------------------------------------AttributeError
>                             Traceback (most recent call 
> last)<ipython-input-42-bde0572cbbe1> in <module>()----> 1 fn(3.2)
> //anaconda/lib/python3.4/site-packages/numpy/__init__.py in 
> <lambda>(_Dummy_73)
> AttributeError: 'int' object has no attribute 'sqrt'
>
>

-- 
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/6f3572d3-07dd-40b3-a3a9-7673eddf1c87%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to