# Antiderivative and definite integral: integrate int Int

### 5.20.1 Antiderivative and definite integral: integrate int Int

The int and integrate commands compute a primitive or a definite integral. A difference between the two commands is that if you input quest() just after the evaluation of integrate, the answer is written with the ∫ symbol.

Int is the inert form of integrate; namely, it evaluates to integrate for later evaluation.

To find a primitive (an antiderivative):

- int (or integrate) takes one mandatory argument and one optional argument:
  - expr, an expression.
  - Optionally, x, the name of a variable (by default the value is x, so if the variable is x the second argument is unnecessary).
- int(expr ⟨,x⟩) (or integrate(expr ⟨,x⟩)) returns a primitive of expr with respect to x.

#### Examples.

- Input:
  integrate(x^2)
  Output:

  x3
  3

- Input:
  integrate(t^2,t)
  Output:

  t3
  3

To evaluate a definite integral:

- int (or integrate) takes four arguments:
  - expr, an expression.
  - x, the variable.
  - a and b, the bounds of the definite integral.
- int(expr,x,a,b) (or integrate(expr,x,a,b)) returns the exact value of the definite integral if the computation was successful or an unevaluated integral otherwise.

#### Examples.

- Input:
  integrate(x^2,x,1,2)
  Output:

  7
  3

- Input:
  integrate(1/(sin(x)+2),x,0,2*pi)
  Output:

  2
  3

  π

  √

  3

Int is the inert form of integrate, it prevents evaluation, for example to avoid a symbolic computation that might not be successful if you just want a numeric evaluation.

#### Example.

Input:

evalf(Int(exp(x^2),x,0,1))

or:

evalf(int(exp(x^2),x,0,1))

Output:

1.46265174591

Exercises.

1. Let

   f(x)=

   x
   x2−1

   +ln(

   x+1
   x−1

   )

   Find a primitive of f.
   Input:
   int(x/(x^2-1)+ln((x+1)/(x-1)))
   Output:

   x ln

   ⎛
   ⎜
   ⎜
   ⎝

   x+1
   x−1

   ⎞
   ⎟
   ⎟
   ⎠

   +

   2
   2

   ln

   ⎪
   ⎪

   x2−1

   ⎪
   ⎪

   +

   ln | ⎪ ⎪ | x2−1 | ⎪ ⎪

   2

   Alternatively, define the function f,
   Input:
   f(x):=x/(x^2-1)+ln((x+1)/(x-1))
   then:
   int(f(x))
   The output, of course, will be the same.

   Warning.
   For Xcas, log is the natural logarithm (like ln); log10 is the base-10 logarithm.

2. Compute:

   ∫

   2
   x6+2 · x4+x2

   dx

   Input:
   int(2/(x^6+2*x^4+x^2))
   Output:

   2

   ⎛
   ⎜
   ⎜
   ⎜
   ⎝

   −3 x2−2

   2 | ⎛ ⎝ | x3+x | ⎞ ⎠

   −

   3
   2

   arctanx

   ⎞
   ⎟
   ⎟
   ⎟
   ⎠

3. Compute:

   ∫

   1
   sin(x)+sin(2 · x )

   dx

   Input:
   integrate(1/(sin(x)+sin(2*x )))
   Output:

   2

   ⎛
   ⎜
   ⎜
   ⎝

   ln

   ⎛
   ⎜
   ⎜
   ⎝

   1−cosx
   1+cosx

   ⎞
   ⎟
   ⎟
   ⎠

   12

   −

   ln

   ⎪
   ⎪
   ⎪
   ⎪

   1−cosx
   1+cosx

   −3

   ⎪
   ⎪
   ⎪
   ⎪

   3

   ⎞
   ⎟
   ⎟
   ⎠