Ask Your Question
0

numerical_integral throwing an error

asked 2013-09-23 21:24:38 +0100

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

2 Answers

Sort by ยป oldest newest most voted
1

answered 2020-02-27 17:07:12 +0100

Karn3003 gravatar image

If we use h(x) instead of h in expression it is working fine.

print numerical_integral(h(x), 1, 2)

edit flag offensive delete link more
1

answered 2013-09-23 22:01:11 +0100

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 22:01:33 +0100 )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 22:33:37 +0100 )edit

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

kcrisman gravatar imagekcrisman ( 2013-09-24 09:59:00 +0100 )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 21:24:38 +0100

Seen: 400 times

Last updated: Sep 23 '13