Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
0

numerical_integral throwing an error

asked 11 years ago

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

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 5 years ago

Karn3003 gravatar image

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

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

Preview: (hide)
link
1

answered 11 years ago

kcrisman gravatar image

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

Preview: (hide)
link

Comments

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

kcrisman gravatar imagekcrisman ( 11 years ago )

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

piper gravatar imagepiper ( 11 years ago )

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

kcrisman gravatar imagekcrisman ( 11 years ago )

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: 11 years ago

Seen: 403 times

Last updated: Sep 23 '13