# How to write and evaluate indefinite integrals

## Description

The antiderivative of a function is expressed using an indefinite integral, as in

$\int f(x)\;dx.$

How can we write and evaluate indefinite integrals using software?

## Using SymPy, in Python

View this solution alone.

This answer assumes you have imported SymPy as follows.

1
2
from sympy import *                   # load all math functions
init_printing( use_latex='mathjax' )  # use pretty math output


Let’s choose an example formula whose antiderivative we will compute.

1
2
3
var( 'x' )
formula = 3*sqrt(x)
formula


$\displaystyle 3 \sqrt{x}$

Use the Integral function to build a definite integral without evaluating it. The second parameter is the variable with respect to which you’re integrating.

1
Integral( formula, x )


$\displaystyle \int 3 \sqrt{x}\, dx$

Use the integrate function to perform the integration, showing the answer.

1
integrate( formula, x )


$\displaystyle 2 x^{\frac{3}{2}}$

1
integrate( formula, x ) + var('C')  # same, but with a constant of integration


$\displaystyle C + 2 x^{\frac{3}{2}}$

See a problem? Tell us or edit the source.

## Opportunities

This website does not yet contain a solution for this task in any of the following software packages.

• R
• Excel
• Julia

If you can contribute a solution using any of these pieces of software, see our Contributing page for how to help extend this website.