Ask Your Question

strangerland's profile - activity

2017-04-29 08:26:07 -0600 received badge  Popular Question (source)
2016-08-14 18:07:52 -0600 received badge  Famous Question (source)
2015-12-01 05:08:52 -0600 received badge  Taxonomist
2015-08-21 08:02:17 -0600 received badge  Popular Question (source)
2015-08-21 08:02:17 -0600 received badge  Notable Question (source)
2014-11-22 11:24:55 -0600 asked a question Define vector valued function of a vector of symbolic variables?

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

gradL
(gradL[0]).arguments()
(gradL[1]).arguments()
(gradL[2]).arguments()
s=[3,.5,.3]
(gradL[0])(s)
(gradL[1])(
s)
(gradL[2])(*s)

(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)
-2.10000000000000
2.34729786038720
Error in lines 8-8
Traceback (most recent call last): File "/projects/5511fe15-8085-4d1d-bdc7-c6bf6c99e693/.sagemathcloud/sage_server.py", 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):
  tmp=[]
  for ii in range(len(gradL)):
    tmp.append((gradL[ii])(*s))
  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.

-Steve

2013-04-06 09:14:48 -0600 answered a question field extensions in python

this basically worked but I had to

load "/home/stephen/sage/example.sage"

thanks for the help

2013-04-06 05:57:22 -0600 asked a question field extensions in python

You can define a field extenion at the sage prompt with

QC.<j>; = QQ.extension(x^2+1)

however this same line in a python script yields a syntax error

def mytest(): 
    QC.<j> = QQ.extension(x^2+1);
    return

Traceback (most recent call last):
...
def mytest(): QC.<j> = QQ.extension(x**_sage_const_2 +_sage_const_1 ); return
                 ^
SyntaxError: invalid syntax

Note:syntax error point to < character

eval also fails

eval('QC.&lt;j&gt; = QQ.extension(x^2+1)')

Traceback (most recent call last):
....    
QC.<j> = QQ.extension(x^2+1)
   ^
SyntaxError: invalid syntax

I also have similar problems with defining Quaternion Algebras in python

HQ.<q1,q2,q3> = QuaternionAlgebra(QC,-1,-1)

so why does QC.<j> = QQ.extension(x^2+1) work at the sage prompt and not in python or with eval(string)

Thanks, Steve