On Thu, Dec 04, 2008 at 04:08:15AM -0800, Scott wrote:
> 
> How can I translate a formula output by sympy into one that is scipy
> friendly?

Here is my attempt with the attached file:

  In [1]: run test.py

  In [2]: F0??
  [...]
  def F0(dof,d_dof,U,dt):
      args = tuple(dof) + tuple(d_dof) + (U, dt)
      return f0(*args)

  In [3]: F0([1,2,3,4], [5,6,7,8], 9, 10)
  Out[3]: -281.64999999999998

  In [4]: %timeit F0([1,2,3,4], [5,6,7,8], 9, 10)
  100000 loops, best of 3: 11.2 µs per loop


I hope that helps.

By,

  Friedrich

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

from sympy import var, lambdify

var("""h1 theta1 v_h1 v_theta1 delta_h
       delta_theta delta_v_h delta_v_theta U dt""".split())

term = -delta_v_h/2 - delta_v_theta/20 + dt*(
        -2*h1/25 - delta_h/25 -
        3*U*(v_theta1 + delta_v_theta/2)/50 -
        U*(v_h1 + delta_v_h/2)/20 - U**2*(theta1 + delta_theta/2)/20 )

args = (h1, theta1, v_h1, v_theta1, delta_h,
        delta_theta, delta_v_h, delta_v_theta, U, dt)
f0 = lambdify(args, term)

def F0(dof,d_dof,U,dt):
    args = tuple(dof) + tuple(d_dof) + (U, dt)
    return f0(*args)

Reply via email to