Skip to main content
Mathematics LibreTexts

7.5: Integration using Computer Algebra

  • Page ID
    83956
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)

    Recall that the fundamental theorem of calculus states that if \(F(x)\) is a function with its derivative equal to \(f(x)\) on the region \(a \le x \le b\text{,}\) then \(\int_a^b f(x)dx=F(b)-F(a)\text{.}\) We say \(\int_a^b f(x)dx\) is the definite integral of \(f(x)\) from \(a\) to \(b\text{.}\) If \(f(x)\) is a derivative of \(F(x)\text{,}\) then \(F(x)\) is an anti-derivative of \(f(x)\text{,}\) and any anti-derivative of \(f(x)\) has the form \(F(x) + c\text{,}\) for some constant \(c\text{.}\) We use the symbol \(\int f(x)dx\text{,}\) without limits of integration, for the indefinite integral.

    In section 7.1 we looked at approximating definite integrals with a Riemann sum that added up the area of a bunch of rectangles. In section 7.2 we saw that the fundamental theorem of calculus lets us use an antiderivative or indefinite integral to evaluate a definite integral. In sections 7.3 and 7.4 we saw how to compute indefinite integrals by hand for a limited number of functions. In this section we will look at how to use computer software at a web site to find antiderivatives.

    We start with Wolfram|Alpha, available at (http://www.wolframalpha.com>. We can give Wolfram|Alpha the question we want solved in plain English. In our case we would like to find the antiderivative of \(x^n\) with respect to \(x\text{.}\)

    clipboard_e742b60f496e72b429ece5e493e88393c.png

    The Alpha provides an answer.

    clipboard_e8b44ab5d852222f71e7049effaf91c9f.png

    Note that the response tells us the question the Wolfram|Alpha is answering. That helps us check that we have been properly understood. We may find it useful to give a formula without the extra words.

    clipboard_e02de52c1ad99c3845c015b9d087ed9db.png

    The interface is fairly robust. It understands the convention that the variable for math problems is typically \(x\text{,}\) so it will generally guess that x is our variable if we don't specify the variable with respect to which we are integrating.

    clipboard_e62fd0295140930c870a1542e141329db.png

    It is worth noting that Wolfram|Alpha is connected with Mathematica, so it will understand questions in Mathematica syntax. On the right side to the screen there is a link for related links. In particular, there will be a link for the related command in Mathematica.

    clipboard_e7037518d9fccb366e51bba08a8e0838c.png

    Following that link gives more information on the syntax of the Mathematica command. We generally don't need to know the syntax, but it is useful if we want to use specific options.

    clipboard_ed3c75b6671248a079801bd0809bfeb05.png

    We should note that Wolfram|Alpha will easily find antiderivatives that we would find very hard to do or beyond the scope of this class.

    clipboard_e4bcdc5790df6ae764224327aada06ea7.png

    The output also has a link for showing steps on complicated problems.

    clipboard_ecdf0cc31d36682c6aac26794d3acfeae.png

    The show steps link only works on the paid version of Alpha. However we can find other tools by searching for integral calculator. Such a search reveals symbolab, ( https://www.symbolab.com/solver/defi...ral-calculator>, which we also used in chapter 4.

    clipboard_e3b7091b0c6a98abd068bcd5106a7acd8.png

    In chapter 4, we found a derivative calculator. Similarly we can find an integral calculator (http://www.integral-calculator.com/> that will show steps. For problems of at the level of difficulty we have been doing, Wolfram|Alpha also produces plots of the integral.

    clipboard_e8bee3ee3f99ac09721398afa7c316f00.png

    Definite integrals - One of the reasons we wanted to find antiderivatives was to be able to use them to evaluate definite integrals. We can ask Wolfram|Alpha for the definite integral directly. In that case, Wolfram|Alpha will give the numeric answer and will also produce the relevant graph. (Symbolab will also do definite integrals.)

    clipboard_e634f7c935cc7695211e9a3af884731e4.png

    This is particularly useful when finding the antiderivative is beyond the scope of this course. Consider for example if we want to find the area under a portion of a curve that has the shape of a normal curve.

    clipboard_e2b2f87ecb435740e4974bef547b219f9.png

    Another example when we can easily set up integrals we cannot solve by hand occurs when we are trying to find the current value of a revenue stream. A value, \(V\text{,}\) that we get \(t\) years in the future, has a present value of \(V exp(-r t)\) where \(r\) is an investment return rate. Thus the current value of a revenue stream, \(V(t)\text{,}\) from time \(a\) to time \(b\text{,}\) is \(\int_a^b V(t)*e^{(-r*t)} dt\text{.}\) However we only have a rule for finding the antiderivative when \(V(t)\) is either a constant or exponential function. With a CAS program it is straightforward to compute such integrals for a broad range of value stream functions.

    clipboard_e4b0f10b7dd2fe703d5657d4dce3cd8ac.png

    If you are going to use Wolfram|Alpha in doing work, you should realize that the terms of use of the site require you to appropriately cite Wolfram|Alpha. (This is standard academic procedure.) Your citation should include that date that you got your answer from the site. The results above were obtained on Feb 29, 2012.

    In business situations, we are rarely asked to simply find an integral. Instead, finding an integral is generally part of a larger problem. Thus we often use CAS for part of a problem.

    Initial value problems - We often want to choose a particular antiderivative of a function. We typically do this when we have the value of the antiderivative for some value. We simply plug that value into the general antiderivative and solve for \(C\text{.}\)

    Example 7.5.1: Finding the Antiderivative, then the Constant.

    The rate of change profit with respect to quantity is given by \(P' (q)=-q^2+5q+50\) and the break-even point occurs when \(q=5\text{.}\) Find the formula for profit as a function of \(q\text{.}\) Find the maximum profit.

    Solution

    We can do this by putting together things we have already done. First we use Wolfram|Alpha to find an antiderivative.

    clipboard_e686cd6fe10e2f71180dd57e5ae85d971.png

    Thus we know \(P(q)=\frac{1q^3}{3}+\frac{5q^2}{2}+50q+C\) for some constant \(C\text{.}\) We also know \(P(5)=0\text{.}\) We now plug the function, without the \(C\text{,}\) into Excel and evaluate at \(q=5\text{.}\)

    clipboard_eaf4d7b32fe3fa4f673922f2174b2fbf0.png

    We make C the negative of our answer and modify our function accordingly. We now use solver to maximize the function.

    clipboard_ee49a3aa8cf7fcc4bfc97dd789cea37d4.png

    Thus the maximum profit is $145.83, and it occurs when \(q=10\text{.}\)

    Example 7.5.2: The Previous Example in One Step.

    The rate of change profit with respect to quantity is given by \(P' (q)=-q^2+5q+50\) and the break-even point occurs when \(q=5\text{.}\) Find the formula for profit as a function of \(q\text{.}\) Find the maximum profit.

    Solution

    We can also do this with Wolfram|Alpha setting up the boundary value problem. We give the alpha bot the derivative we want integrated and the fixed value of the original function. (Notice that the answer does not include a +C, since we have computed a particular constant.)

    clipboard_e3adf61c962d59488d0859c4ca1616a5a.png
    clipboard_e67d4c73e64c4345b788a88507c873cfa.png

    We then ask Alpha to maximize the function.

    clipboard_eb7e1f41e31998ec60fd83a184dec61da.png

    This gives the same answer of $145.83.

    This first example could easily have been done by hand. We can repeat the process with an example that could not be easily been by hand.

    Example 7.5.3: A More COmplicated Initial Value Problem.

    The rate of change of profit with respect to quantity is given by \(P' (q)=q^2 \exp(-q/10)-q/10\) and a break-even point occurs when \(q = 5\text{.}\) Find the formula for profit as a function of \(q\text{.}\) Find the maximum profit.

    Solution

    In structure, this example is very similar to the first example. However, where in the first example, the function would have been easy to do by hand, in this case, the problem is very hard to do by hand. We use Wolfram/Alpha to find the antiderivative.

    clipboard_e5e91e0c9559a56db023f479d7e175f08.png

    \[ P(q) = exp(-q/10)*(-10*q^2-200*q-2000)-q^2/20+C. \nonumber \]

    We then use Excel to find \(C\text{,}\) noting that if we use \(P(q)\) without the \(C\text{,}\) then \(C\) is the value of \(–P(5) = 1972.474\text{.}\)

    clipboard_e8273fe30d2bf92106b33fbb5c37c47ce.png

    We plug in 5 and note \(P(5) = 0 = C-1972.474\text{,}\) thus \(C = 1972.474\text{.}\) We use solver to maximize and find the maximum profit of $1675.17 occurs at \(q=64.72775\text{.}\)

    clipboard_eae4907470ff046d10697e6bb371de889.png

    Riemann sums - We can also use Alpha to do Riemann sums. We need to give a starting and ending point and the number of intervals.

    Example 7.5.4: Riemann sums with Wolfram|Alpha.

    Find the current value of a revenue stream \(V(t)=2000+5t\) for 10 years with an investment rate of \(r=1.03\text{,}\) assuming payments are made daily.

    Solution

    We approximate the current value with the integral

    \[ CurrentValue=\int_{start}^{stop} r^{-t} V(t)dt= \int_0^{10} 1.03^{-t} (2000+5t)dt. \nonumber \]

    What we really want is the Riemann sum with one interval per day. Over 10 years we have 3652 days.

    clipboard_e71e800ff71d9e84c6246f58e261bd7df.png
    clipboard_e49b4523fcc33c63933bbc999d5aec349.png

    If we assume payments start at the beginning of the first day we would use the left endpoint method.

    Exercises: Integration using Computer Algebra Problems

    class="

    For 1-10, find the antiderivative of the given function

    Exercise 1:

    \[ f(x)=x \ln(x) \nonumber \]

    Answer

    \[ \int x \ln(x)dx=\frac{1}{4} x^{2}(2\ln(x)-1) +c \nonumber \]

    Exercise 2:

    \[ f(t)=e^{.07t} (-t^2+3t+5) \nonumber \]

    Exercise 3:

    \[ f(t)=t^2 e^(-0.06t) \nonumber \]

    Answer

    \[ \int t^2 e^{-0.06 t} dt= e^{-0.06t} (-9259.26 - 555.556 t - 16.6667 t^2)+c \nonumber \]

    Exercise 4:

    \[ f(x)=\ln(x) \nonumber \]

    Exercise 5:

    \[ f(t)=(t+1) e^{-0.06t} \nonumber \]

    Answer

    \[ \int (t+1) e^{-0.06t}\ dt =e^(-0.06t) (-294.444 - 16.6667 t)+c \nonumber \]

    Exercise 6:

    \[ f(x)=\frac{1}{(1+2x)(3+x)(5+6x) } \nonumber \]

    Exercise 7:

    \[ f(x)=\frac{1}{\sqrt{1+x^2}} \nonumber \]

    Answer

    \[ \int \frac{1}{\sqrt{1+x^2}}\ dx= \sinh^{-1}(x)+c \nonumber \]

    Exercise 8:

    \[ f(x)=\frac{1}{(3+2x)^2} \nonumber \]

    Exercise 9:

    \[ f(x)=\frac{5}{9+x^2 } \nonumber \]

    Answer

    \[ \int \frac{5}{9+x^2 }\ dx = \left(\frac{5}{3}\right)\tan^{-1}\left(\frac{x}{3}\right)+c \nonumber \]

    Exercise 10:

    \[ f(x)=\frac{1}{(5x+4)^2 (7x+9)} \nonumber \]

    For problems 11-16 evaluate the definite integral.

    Exercise 11:

    \[ \int_0^{10} t^2 e^{-0.06t} dt \nonumber \]

    Answer

    \[ \int_0^{10} t^2 e^{-0.06t} dt \approx 214.03 \nonumber \]

    Exercise 12:

    \[ \int_1^{10}\frac{dt}{t} \nonumber \]

    Exercise 13:

    \[ \int_1^8(x-1)(x-8) dx \nonumber \]

    Answer

    \[ \int_1^8(x-1)(x-8) dx \approx -57.167 \nonumber \]

    Exercise 14:

    \[ \int_0^{10}t^2 e^{.05(10-t)} dt \nonumber \]

    Exercise 15:

    \[ \int_0^2 e^{-x^2} dx \nonumber \]

    Answer

    \[ \int_0^2 e^{-x^2} dx \approx 0.882081 \nonumber \]

    Exercise 16:

    \[ \int_9^{16} \frac{1}{\sqrt{2\pi}} e^{-(x-10)^2} dx \nonumber \]

    For problems 17-20 do the initial value problem.

    Exercise 17:

    \[ P' (q)=-q^2+3q+5\hbox{ and }P(3)=5.\hbox{ Find } P(q) \nonumber \]

    Answer

    \[ P(q)=\frac{1}{6} (-2q^3+9q^2+30q-87) \nonumber \]

    Exercise 18:

    \[ F' (t)=t^2 e^{-0.1t} \hbox{ and } F(10)=2. \hbox{ Find } F(t). \nonumber \]

    Exercise 19:

    \[ P' (q)=\sqrt{q^2+5q+7} \hbox{ and } P(0)=7. \hbox{ Find } P(q). \nonumber \]

    Answer

    \[ P(q) = (56 - 50 \sqrt{157} + (4q+10) \sqrt{7 + 5 q + q^2} \nonumber \]

    \[ - 3 \sinh^{-1}\left(\frac{25}{\sqrt{3}}\right)+ 3 \sinh^{-1}\left(\frac{5 + 2 q}{\sqrt{3}}\right))/8 \nonumber \]

    Exercise 20:

    \[ P' (q)=-(q^2+2q+3)^2 \hbox{ and } P(10)=-7. \hbox{ Find } P(q). \nonumber \]

    Exercise 21:

    I have an investment that produces income at a rate of \(P(t)=5000+100t\text{.}\) I assume the present value of an asset decreases continuously at a rate of 2% per year for the length of time I have to wait for the asset. What is the present value of the first 7 years of return from my investment?

    Answer

    \[ \int_0^7(5000+100t) (.98)^t dt\approx 34868.6 \nonumber \]

    Exercise 22:

    My oil well is producing revenue at a rate of \(P(t)=5000(0.09^t)\text{.}\) I assume the present value of an asset decreases continuously at a rate of 3% per year for the length of time I have to wait for the asset. What is the present value of the first 10 years of return from my investment?

    Exercise 23:

    The rate of marginal profit is \(MP(q)=100-12\ln(q)\) and a break-even point occurs at \(q=100\text{.}\) Find the quantity that produces the most profit and the amount of profit generated at that point.

    Answer

    We have maximal profit when \(MP(q)=0\text{,}\) or when \(q=e^8=2981\text{.}\)

    Using WolframAlpha to solve the initial value problem we get

    \[ P(q)=16(7q-700+75ln(100))-12q ln(q) \nonumber \]

    \[ P(2981)= 16(7*2981-700+75ln(100))-12*2981 ln(2981)=42021.7 \nonumber \]

    Exercise 24:

    Our marginal cost function is \(MC(q)=10q \ln(q)\) and the startup costs are $23,000. Produce a cost function.


    This page titled 7.5: Integration using Computer Algebra is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Mike May, S.J. & Anneke Bart via source content that was edited to the style and standards of the LibreTexts platform.