I'm doing some work with riemann mapping, and I need to create a
function that returns the complex argument of a symbolic function.
My function definition is something like f(x) = arg(-i*theta(x)^2*Gap
(x))
where theta and Gap are already defined. When I try this, I get this
error:
TypeError: Cannot evaluate symbolic expression to a numeric value.
What am I doing wrong/ what can I do to get around this.
In case you want to see it, here's all my code and the full error(line
numbers are off):
def nystrom(A,g,n,zerodiagonal = false):
f(x) = x/n
tk = vector(map(f,range(n+1)))
sj = tk
v = matrix(CDF,n+1,1,[g(i) for i in tk])
M = Matrix(CDF,n+1,n+1)
for i in range(n+1):
for j in range(n+1):
if j == i and zerodiagonal:
M[i,i] = 0
else:
M[i,j] = N(A(tk[j],sj[i]))
M2 = M + Matrix(RDF,identity_matrix(RDF,n+1))
u = (M2).solve_right(v)
print "1"
assume(x,'real')
print "2"
for i in range(n+1):
g(x) = g(x) - A(x,tk[i])*u[i][0]*2*pi/n
return g
def boundaryMapper(Ga,a,n):
Gap = derivative(Ga)
t = var('t')
s = var('s')
norm(t) = Gap(t)/abs(Gap(t))
Hconj(t) = 1/(2*i*pi) * (norm(t)/(a-Ga(t))).conjugate()
A(t,s) = 1/(2*i*pi) * (norm(s)/(Ga(s)-Ga(t))- (norm(s)/(Ga(s)-Ga
(t))).conjugate())
K(t,s) = sqrt(abs(Gap(s))) * A(t,s) * sqrt(abs(Gap(t)))
g(t) = sqrt(abs(Gap(t))) * Hconj(t)
theta = nystrom(K,g,n,zerodiagonal = true)
#return theta
return arg(-i*theta^2*Gap)
ellipse(x) = e^(i*x)-.5*e^(-i*x)
#show(parametric_plot((real(ellipse),imag(ellipse)),0,2*pi))
phi = boundaryMapper(ellipse,0,16)
print phi(x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/evlutte/.sage/sage_notebook/worksheets/admin/26/code/
47.py", line 45, in <module>
phi = boundaryMapper(ellipse,_sage_const_0 ,_sage_const_16 )
File "/home/evlutte/.sage/sage_notebook/worksheets/admin/26/code/
47.py", line 39, in boundaryMapper
return arg(-i*theta**_sage_const_2 *Gap)
File "/home/evlutte/opt/sage-3.2.3/local/lib/python2.5/site-packages/
sage/misc/functional.py", line 71, in arg
except AttributeError: return CDF(x).arg()
File "complex_double.pyx", line 293, in
sage.rings.complex_double.ComplexDoubleField_class.__call__ (sage/
rings/complex_double.c:3595)
File "parent.pyx", line 288, in
sage.structure.parent.Parent.__call__ (sage/structure/parent.c:4121)
File "coerce_maps.pyx", line 81, in
sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/
structure/coerce_maps.c:3064)
File "coerce_maps.pyx", line 76, in
sage.structure.coerce_maps._call_ (sage/structure/coerce_maps.c:2955)
File "complex_double.pyx", line 327, in
sage.rings.complex_double.ComplexDoubleField_class._element_constructor_
(sage/rings/complex_double.c:3994)
File "expression.pyx", line 838, in
sage.symbolic.expression.Expression._complex_double_ (sage/symbolic/
expression.cpp:5614)
File "expression.pyx", line 684, in
sage.symbolic.expression.Expression._eval_self (sage/symbolic/
expression.cpp:5027)
TypeError: Cannot evaluate symbolic expression to a numeric value.
--~--~---------~--~----~------------~-------~--~----~
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/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---