How to check if the integral of a function is correct with a scientific calculator?

13.8k Views Asked by At

As a calculus student I would like to know if there is any way to verify the "correctness" of an integral of a function using a calculator.

I mean if have something like $f(x) = \cos(2x)$, then $\int f(x) ~dx=\frac{1}{2}\sin(2x) + C$.

Now, is there anyway to check if my answer is right using a scientific calculator?

3

There are 3 best solutions below

1
On BEST ANSWER

Since you are solving for the indefinite integral of a function, you are solving for the anti-derivative. You can plug in the answer you got in any modern scientific calculator using the d/dx function and compare the results.

For example, let's say you are solving for the integral of cos(2x). You think the answer is sin(2x)/2 + C but you are not sure. All what you have to do is first, calculate the original cos(2x) using an arbitrary substitution for x (say 7) so you put cos(2*7) which is going to be ~0.136737

Now you can use the d/dx function of your calculator using the same value for x (notice that the c constant is not important):

d/dx(sin(2x)/2),x=7

your calculator is going to output ~0.136737. Since it is the same result, you did it successfully.

Quick tips:

  1. Whenever you are doing trigonometric calculus. Make absolutely sure that you are using the radian system in your calculator.

  2. If the result of the d/dx function in your calculator is so small, it is going to round it to 0. Watch out for that, you might want to use other numbers for x.

It's actually a life-saver. It's so helpful. My calculator is Casio fx-991ES PLUS for reference.

0
On

Here is a rather simple (but many times effective) method I share with my students. Say you have a function and you need to find the anti derivative. You think you found one. Let's make the integral a definite one. Choose a nice lower and upper value and plug them into your anti derivative and get an answer. Now take a graphing calculator like a TI 83/84 (just a scientific won't work) and plug in that function. Let the TI get the area under the curve with the CALC tool and compare that answer with yours. If they match, then you can bet that you got it right. For me as a student (and I am a still a student, will always be...) this has helped me a many times, in particular with eve numbered questions in books that have no answers. Sometimes an online integration tool comes up with weird (but correct) anti derivatives that differ substantially from mine (like with trig integrals) and so my method has proven to be effective...

0
On

Given two functions $F(x)$ and $f(x)$ there are two ways to check whether $F^{\prime}(x)=f(x)$. You can use numerical quadrature to show that $$\int_a^bf(x)dx=F(b)-F(a)$$ For various intervals $[a,b]$, or you can use numerical differentiation to verify that, for example $$\frac{F(x+\Delta x)-F(x-\Delta x)}{2\Delta x}=f(x)$$ For various values of $x$. Numerical integration ends up being more accurate typically than numerical differentiation, but on a non-programmable calculator numerical differentiation may be more feasible than integration. I would think that calculators are on their way out because everyone has a smartphone and in principle one could do everything on a smartphone that one could on a calculator (particularly with a calculator app), so why carry around extra hardware? Here is a little program that tests $$\begin{align}\int-2\sqrt{(2-x)^2+\frac14}dx&=(2-x)\sqrt{(2-x)^2+\frac14}\\ &+\frac14\ln\left(2-x+\sqrt{(2-x)^2+\frac14}\right)-\frac1{2\sqrt2}-\frac14\ln\left(\frac{1+\sqrt2}2\right)+C\end{align}$$ For correctness.

module testfun
   use ISO_FORTRAN_ENV, only: dp => REAL64
   implicit none
   contains
      function fun1(x)
         real(dp) fun1, x, two
         parameter(two=2)
         fun1 = (2-x)*sqrt((2-x)**2+1/two**2)+ &
            log(2-x+sqrt((2-x)    **2+1/two**2))/two**2- &
            1/(two*sqrt(two))-log((1+sqrt(two))/two)/two**2
      end function fun1
      function fun2(x)
         real(dp) fun2, x, two
         parameter(two=2)
         fun2 = -2*sqrt((2-x)**2+1/two**2)
      end function fun2
      function diff(f,x,Dx)
         real(dp) diff,x,Dx
         procedure(fun1) f
         diff = (f(x+Dx)-f(x-Dx))/(2*Dx)
      end function diff
      function simpson(f,a,b,N)
         real(dp) simpson,a,b,h
         procedure(fun1) f
         integer N, i
         h = (b-a)/N
         simpson = sum([f(a),((3-(-1)**i)*f(a+i*h),i=1,N-1),f(b)])*h/3
      end function simpson
end module testfun

program test
   use testfun
   implicit none
   real(dp) x, Dx, a, b, h
   integer N, i
   write(*,'(a)') 'Testing with differences'
   Dx = 1.0e-3_dp
   h = 0.2_dp
   do i = 1, 10
      x = i*h
      write(*,'(3(f9.6:1x))') x, fun2(x), diff(fun1,x,Dx)
   end do
   write(*,'(/a)') 'Testing with quadrature'
   N = 10000 ! N must be even.
   h = 0.2_dp
   do i = 1, 10
      a = i*h
      b = (i+1)*h
      write(*,'(4(f9.6:1x))') a, b, fun1(b)-fun1(a), simpson(fun2,a,b,N)
   end do
end program test

And its output:

Testing with differences
 0.200000 -3.736308 -3.736308
 0.400000 -3.352611 -3.352611
 0.600000 -2.973214 -2.973214
 0.800000 -2.600000 -2.600000
 1.000000 -2.236068 -2.236068
 1.200000 -1.886796 -1.886796
 1.400000 -1.562050 -1.562050
 1.600000 -1.280625 -1.280625
 1.800000 -1.077033 -1.077033
 2.000000 -1.000000 -1.000001

Testing with quadrature
 0.200000  0.400000 -0.708832 -0.708832
 0.400000  0.600000 -0.632498 -0.632498
 0.600000  0.800000 -0.557197 -0.557197
 0.800000  1.000000 -0.483417 -0.483417
 1.000000  1.200000 -0.411979 -0.411979
 1.200000  1.400000 -0.344356 -0.344356
 1.400000  1.600000 -0.283316 -0.283316
 1.600000  1.800000 -0.234080 -0.234080
 1.800000  2.000000 -0.205212 -0.205212
 2.000000  2.200000 -0.205212 -0.205212