Ask Your Question

Error: list' object is not callable

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

this post is marked as community wiki

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

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-02-11 14:14:26 +0200

tmonteil gravatar image

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.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools


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

Seen: 943 times

Last updated: Feb 11 '17