# Error: list' object is not callable

This post is a wiki. Anyone with karma >750 is welcome to improve it.

I am trying to run the following code :

x = var('x')
y = function('y')(x)
de= x*x*diff(y,x,2)+x*diff(y,x)+((12)*x*x-4)*y == 0
val_test=desolve(de,y,contrib_ode=true)
a=val_test(4)
a.n()

But a.n() shows "Error: list' object is not callable".

edit retag close merge delete

Sort by ยป oldest newest most voted

val_test is a Python list containing a single symbolic expression:

sage: val_test
[y(x) == _K1*bessel_J(2, -2*sqrt(3)*x) + _K2*bessel_Y(2, -2*sqrt(3)*x)]

If you want to access this expression, you can do:

sage: val_test[0]
y(x) == _K1*bessel_J(2, -2*sqrt(3)*x) + _K2*bessel_Y(2, -2*sqrt(3)*x)

If you want to get its right hand side, you can do:

sage: val_test[0].right_hand_side()
_K1*bessel_J(2, -2*sqrt(3)*x) + _K2*bessel_Y(2, -2*sqrt(3)*x)

If you want to evaluate it at x=4, you can do:

sage: val_test[0].right_hand_side().substitute(x=4)
_K1*bessel_J(2, -8*sqrt(3)) + _K2*bessel_Y(2, -8*sqrt(3))

But note that K1 and K2 should be probably defined first, by the initial conditions of your ODE.

more