Ask Your Question
0

numerical_integral throwing an error

asked 2013-09-23 14:24:38 -0500

anonymous user

Anonymous

Hi.

Can anyone explin why the following is producing an error please. First integral works, the second fails.

g(x) = 2*x

print numerical_integral(g, 1, 2)

(3.0, 3.3306690738754696e-14)

h(x) = x

print numerical_integral(h, 1, 2)

Traceback (most recent call last):

ValueError: free variable: x |--> x

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-09-23 15:01:11 -0500

kcrisman gravatar image

Ironically, h(x) = x is too simple. See Trac 15219.

edit flag offensive delete link more

Comments

Of course, the workaround is just to do `numerical_integral(x, 1, 2)`. But we can fix this!

kcrisman gravatar imagekcrisman ( 2013-09-23 15:01:33 -0500 )edit

The following also fails, presumably for the same reason. i(x) = 1*x print numerical_integral(i, 1, 2)

piper gravatar imagepiper ( 2013-09-23 15:33:37 -0500 )edit

Correct, since internally Sage/Ginac makes 1*x = x.

kcrisman gravatar imagekcrisman ( 2013-09-24 02:59:00 -0500 )edit

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2013-09-23 14:24:38 -0500

Seen: 56 times

Last updated: Sep 23 '13