Ask Your Question

# Plotting an integral with a variable as a limit

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 close merge delete

## 1 Answer

Sort by ยป oldest newest most voted

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.

more

## Your Answer

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

Add Answer

## Stats

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

Seen: 2,254 times

Last updated: Nov 10 '14