Ask Your Question
3

Plotting an integral with a variable as a limit

asked 2012-03-28 10:52:02 -0500

tom12519 gravatar image

updated 2014-11-10 10:24:16 -0500

tmonteil gravatar image

I want to plot a function with a variable as a limit, e.g. look at \int_0^x f(y) d y, but this seems to throw an error when Sage can't analytically integrate the function.

x,y=var('x y')
f(y)=integrate(x^x,x,1,y)
plot(f,2,10)

Returns

Traceback (click to the left of this block for traceback)
...
ValueError: free variable: x

Can anybody help with this, please? Many thanks.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2012-03-28 15:07:51 -0500

kcrisman gravatar image

The following is only a workaround, and it likely extremely slow.

sage: f(y) = integrate(x^x,x,1,y)
sage: plot(lambda y: f(y), (y,2,10))

You can see that it's slow because even

sage: plot(lambda y: f(y), (y,2,10),plot_points=10,adaptive_recursion=2)

is really slow.

If you give up on symbolic stuff, though, then

sage: plot(lambda y: numerical_integral(x^x,1,y)[0],(y,2,10))

is a good substitute. Notice that we probably still will need the lambda solution, or to define a Python function.

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

Stats

Asked: 2012-03-28 10:52:02 -0500

Seen: 1,249 times

Last updated: Nov 10 '14