Along the lambda lines is this suggestion:

>>> from sympy import *
>>> def myfun(x, params):
...     a, b = params
...     return x**2 + Rational(a, b)
...
>>> params=[1,2]
>>> f = lambda x: myfun(x, p)
>>> f(1)
3/2
>>> params=[3,5]
>>> f(1)
8/5

On Feb 1, 8:30 am, Scott <[email protected]> wrote:
> Is there a clever way to get from F4 to F5 other than cutting and
> pasting?

Let python emit the function for you?

>>> def emit(globs, params):
...     sg = str(globs)
...     sp = str(params)
...     return 'def F5%s:\n\tglobal %s\n\targs=tuple(dofl)[:-cons]+%s+%s\n
\treturn F3(*args)' % (sp, sg[1:-1], sg, sp)
...
>>> f5=emit(globs, params)
>>> exec f5 # you now have F5 in your namespace

I can say more if this looks like what you want. After the exec line
you have a function named F5 ready to use, i.e. you could pass F5 to a
solver:

>>> sympy.mpmath.findroot(F5,list(dof1))
etc...

BTW, I don't see where you've defined `cons`

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

Reply via email to