Ask Your Question

Plotting an integral with a variable as a limit

asked 2012-03-28 17:52:02 +0100

tom12519 gravatar image

updated 2023-01-09 23:59:35 +0100

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')


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

answered 2012-03-28 22:07:51 +0100

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


Asked: 2012-03-28 17:52:02 +0100

Seen: 2,369 times

Last updated: Nov 10 '14