Ask Your Question

# Error: list' object is not callable

asked 2017-02-11 06:33:43 +0200 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

## 1 Answer

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

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2017-02-11 06:33:43 +0200

Seen: 634 times

Last updated: Feb 11 '17