Ask Your Question
1

Problem by finding an integral

asked 2021-06-12 10:45:13 +0200

updated 2021-06-12 14:33:52 +0200

slelievre gravatar image

I have to find the integral of x*sqrt(x + 1) dx.

By hand, I found (2/3)*x*(x + 1)^(3/2) – (4/15)*(x + 1)^(5/2) + c.

By SageMath I found -(2/3)*(x + 1)^(3/2) + (2/15)*(x + 1)^(5/2).

The SageMath code is simple:

x = var('x')
f = x*sqrt(x + 1)
fi = integral(f, x)
print(latex(fi))

Which is the error?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
3

answered 2021-06-15 14:37:46 +0200

rburing gravatar image

The SageMath result (output of your code in SageMath 9.2) has coefficient a $2/5$ instead of the $2/15$ you claim:

sage: fi
2/5*(x + 1)^(5/2) - 2/3*(x + 1)^(3/2)

Then it agrees with your hand calculation, e.g. because for $z = \sqrt{x+1}$ we have $$\frac{2}{5} z^5 - \frac{2}{3} z^3= \frac{2}{3}(z^2-1)z^3 - \frac{4}{15}z^5.$$

edit flag offensive delete link more

Comments

Thank you! Thanks a lot!

Spyridon Kanavos gravatar imageSpyridon Kanavos ( 2021-06-18 08:55:21 +0200 )edit

You can accept rburing's answer by clicking the check mark next to it below its score.

slelievre gravatar imageslelievre ( 2021-06-22 01:03:13 +0200 )edit
2

answered 2021-06-16 00:29:03 +0200

slelievre gravatar image

updated 2021-06-16 18:06:27 +0200

Both answers are correct.

To see it by hand, we can use:

  • $(x + 1)^{5/2} = (x + 1) (x + 1)^{3/2} = x (x + 1)^{3/2} + (x + 1)^{3/2}$
  • $(x + 1)^{3/2} = (x + 1) (x + 1)^{1/2} = x (x + 1)^{1/2} + (x + 1)^{1/2}$

to express both as linear combinations of $(x + 1)^{1/2}$, $x (x + 1)^{1/2}$ and $x^2 (x + 1)^{1/2}$.

To see it with Sage, we can

  • ask Sage whether the two different expressions in fact agree
  • differentiate both and compare them
  • plot the functions to visually check whether they agree

Define the function to integrate:

sage: x = var('x')
sage: f = x*sqrt(x + 1)
sage: f
sqrt(x + 1)*x

Compute a primitive (aka antiderivative) with Sage:

sage: F = integral(f, x)
sage: F
2/5*(x + 1)^(5/2) - 2/3*(x + 1)^(3/2)

The primitive you computed (up to a constant):

sage: G = (2/3)*x*(x + 1)^(3/2) - (4/15)*(x + 1)^(5/2)
sage: G
-4/15*(x + 1)^(5/2) + 2/3*(x + 1)^(3/2)*x

Check that they agree:

sage: bool(F == G)
True

Check they have the same derivative:

sage: g = G.diff(x)
sage: g
sqrt(x + 1)*x

sage: ff = F.diff(x)
sage: ff
(x + 1)^(3/2) - sqrt(x + 1)

sage: bool(g == ff)
True

Or more visually, compare the plots of F and G (or f and ff):

sage: pF = plot(F, (-1, 1.6), color='firebrick')
sage: pG = plot(G, (-1, 1.6), color='steelblue')
sage: p = graphics_array([pF, pG, pF + pG])
sage: p.show(figsize=(7, 3))
Launched png viewer for Graphics Array of size 1 x 3

Plot two functions with Sage and check they are the same

edit flag offensive delete link more

Comments

Excellent! Very interesting answer. Otherwise, I have an older version: Sage 8.0

Spyridon Kanavos gravatar imageSpyridon Kanavos ( 2021-06-18 08:53:55 +0200 )edit

Oh, I see. I would recommend upgrading to Sage 9.3.

When I run Sage 8.0 I get this:

sage: x = var('x')
sage: f = x*sqrt(x + 1)
sage: f
sqrt(x + 1)*x
sage: F = integral(f, x)
sage: F
2/5*(x + 1)^(5/2) - 2/3*(x + 1)^(3/2)

Do you really get (2/15)?

slelievre gravatar imageslelievre ( 2021-06-18 09:56:44 +0200 )edit

Yeah, the problem probably has to do with the version. I uninstalled the 8.0 version and I installed the 9.3 one. Now everything is o.k. Thanks a lot!

Spyridon Kanavos gravatar imageSpyridon Kanavos ( 2021-06-21 19:36:59 +0200 )edit

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-06-12 10:45:13 +0200

Seen: 219 times

Last updated: Jun 16 '21