Pick any exercise in 8.8 of the calculus textbook. Solve and post your solution. If you have issues doing so, discuss them.
Approximate the value of the given definite integral by using the first 4 non-zero terms of the integrand’s Taylor series.
The function \(sin(x^2)\) does not have an elementary antiderivative, so the indefinite integral cannot be solved analytically.
This is known as the Fresnel Integral \(S(x)\) , which is discussed here: https://en.wikipedia.org/wiki/Fresnel_integral .
As shown in Example 8.8.6 on page 492, we know that
\[\begin{aligned} sin(x) &= \sum\limits_{n=0}^{\infty}(-1)^n\frac{x^{2n+1}}{(2n+1)!} \\ &= x-\frac{x^3}{3!}+\frac{x^5}{5!}-\frac{x^7}{7!}+... \end{aligned}\] .
Therefore, \[\begin{aligned} sin(x^2) &= \sum\limits_{n=0}^{\infty}(-1)^n\frac{(x^2)^{2n+1}}{(2n+1)!} \\ &= x^2 - \frac{x^6}{3!} + \frac{x^{10}}{5!} - \frac{x^{14}}{7!}+... \\ \end{aligned}\] .
We can integrate the Taylor series term-by-term, to obtain
\[\begin{aligned} \int\limits_0^{\sqrt{\pi}} sin{\left(x^2\right)} dx &= \int\limits_0^{\sqrt{\pi}} \sum\limits_{n=0}^{\infty}(-1)^n\frac{(x^2)^{2n+1}}{(2n+1)!} dx\\ &= \int\limits_0^{\sqrt{\pi}} \sum\limits_{n=0}^{\infty}(-1)^n\frac{(x)^{4n+2}}{(2n+1)!} dx\\ &= \left. \sum\limits_{n=0}^{\infty}(-1)^n\frac{(x)^{4n+3}}{(4n+3)\cdot(2n+1)!} \right|_0^{\sqrt{\pi}} \\ &= (-1)^0\frac{(x)^{4\cdot 0 + 3}}{(4\cdot 0 +3)\cdot(2\cdot 0+1)!} + (-1)^1\frac{(x)^{4\cdot 1 + 3}}{(4\cdot 1 +3)\cdot(2\cdot 1+1)!} \\ &\quad\quad+ \left.(-1)^2\frac{(x)^{4\cdot 2 + 3}}{(4\cdot 2 +3)\cdot(2\cdot 2+1)!} + (-1)^3\frac{(x)^{4\cdot 3 + 3}}{(4\cdot 3 +3)\cdot(2\cdot 3+1)!}+... \right|_0^{\sqrt{\pi}}\\ &= \left.\frac{x^3}{3} - \frac{x^7}{7 \cdot 3!} + \frac{x^{11}}{11 \cdot 5!} - \frac{x^{15}}{15 \cdot 7!}+... \right|_0^{\sqrt{\pi}}\\ &= \frac{{\sqrt{\pi}}^3}{3} - \frac{{\sqrt{\pi}}^7}{7 \cdot 3!} + \frac{{\sqrt{\pi}}^{11}}{11 \cdot 5!} - \frac{{\sqrt{\pi}}^{15}}{15 \cdot 7!}+...-0 \\ &\approx 1.8561 - 1.3085 + 0.4109 - 0.0708 \\ &\approx 0.8877 \end{aligned}\] .
fresnel_S <-function(x,n=10){
# create an empty array
thisterm = array()
thissum = 0
# Note that we need to start the loop from i=0
for (i in 0:n) {
numerator = (-1)^i * x^(4*i+3)
denominator = (4*i+3) * factorial((2*i+1))
# there is no array[0] in R, so the array index needs to be i+1
thisterm[i+1] = numerator/denominator
thissum = thissum + thisterm[i+1]
print(paste(i, round(thisterm[i+1],9), round(thissum,9)))
}
fresnel_S <- thissum
}
# Compute the result of the first 4 terms
result4 <- fresnel_S(sqrt(pi),n=3)## [1] "0 1.856109332 1.856109332"
## [1] "1 -1.308504631 0.547604701"
## [1] "2 0.410913461 0.958518162"
## [1] "3 -0.070811248 0.887706914"
## [1] 0.887706914
The sum of the first 4 terms of the integral is 0.887706914 .
## [1] "0 1.856109332 1.856109332"
## [1] "1 -1.308504631 0.547604701"
## [1] "2 0.410913461 0.958518162"
## [1] "3 -0.070811248 0.887706914"
## [1] "4 0.007663147 0.895370061"
## [1] "5 -0.000567989 0.894802072"
## [1] "6 0.000030611 0.894832683"
## [1] "7 -0.000001253 0.89483143"
## [1] "8 0.00000004 0.894831471"
## [1] "9 -0.000000001 0.894831469"
## [1] "10 0 0.894831469"
## [1] 0.894831469
The sum of the first 11 terms of the integral is 0.894831469, at which point the series has converged.