Define vector valued function of a vector of symbolic variables?

asked 2014-11-22 11:24:55 -0500

strangerland gravatar image

I have a gradient where each component may have a different number of symbolic arguments and get the following error when I run:


(lam0(x1 - 1.00000000000000) - log(x0) + log(-x0 + 1), lam0x0 - log(x1) + log(-x1 + 1), x0*x1 - x0 + 0.500000000000000)
(lam0, x0, x1)
(lam0, x0, x1)
(x0, x1)
Error in lines 8-8
Traceback (most recent call last): File "/projects/5511fe15-8085-4d1d-bdc7-c6bf6c99e693/.sagemathcloud/", line 865, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> File "sage/symbolic/expression.pyx", line 4382, in sage.symbolic.expression.Expression.__call__ (build/cythonized/sage/symbolic/expression.cpp:24669) File "sage/symbolic/ring.pyx", line 760, in sage.symbolic.ring.SymbolicRing._call_element_ (build/cythonized/sage/symbolic/ring.cpp:8970) ValueError: the number of arguments must be less than or equal to 2

I need to be able to to be able to define this as a vector valued function of a vector so that I can evaluate it using the entire argument set (lam0, x0, x1) where the missing arguments are ignored for the corresponding component. This is so I can def a function for scipy.optimize like:

def F(s):
  for ii in range(len(gradL)):
  return tmp
ssoln = scipy.optimize.broyden1(F, [.5,.5,.5], f_tol=1e-14)

I can't figure out how to accomplish this. Thanks for any help in advance.


edit retag flag offensive close merge delete


See!top... for discussion that seems to have solved this.

kcrisman gravatar imagekcrisman ( 2014-11-22 20:35:13 -0500 )edit