Sunday, September 22, 2019 | Toby Opferman
 

Integrals (Anti-Derivatives)

Toby Opferman
http://www.opferman.net
toby@opferman.net


				Integrals

	Integrals are also know as "Anti-Dirivatives".  As we seen in the
dirivative tutorial, we seen how to get dirivatives.  What if we want to go
backwards?


Let us look at a simple example.


Dirivative of
X^2 + X - 4 = 2X + 1

Integral(2X + 1)dx

dx means "dirivative of X" as the chain rule states.

So, We can split up integrals just like we can dirivatives.


Integral(2X)dx + Integral(1)dx

To get the Integral of 2X, we go backwards.

For any Integral aX^n The Integral is aX^(n+1)
                                      -------
                                       (n+1)


So, Integral(2X)dx =   (2X^(1+1))/(1+1) = (2X^2)/2 = X^2

Now, The integral of a constant a will always be aX Since
you can consider a to be a*X^0  so (a*X^(0+1))/(0+1) = a*X


Thus Integral (1)dx = X

And thus the answer is

X^2 + X 

Now, the original equation was

X^2 + X - 4

And this is an "Indefinate Integral"  So, we always say this.
Since there would always be 1 constant, Even if it was 0, that drops out,
Indefiniate Integrals are:

X^2 + X + C   Where C is some constant.

How do you get the constant?  The ONLY way is to know a particular situation
Such as a condition that f(0) = -4.

Then you could plug in 0 and get C = -4.  Or for any other regular
condition f(i) = k  And you could solve for C.  Otherwise, you do not know.

There is something called a Definate Integral. We will demonstrate this
on the last example

  3
Int(2x + 1)  This is where you take the Anti-Dirivative and subsititue those numbers
  1          in for X, then you subtract.



The Anitdirivative is:
 X^2 + X + C


             |3
X^2 + X + C  |   =  ((3)^2 + 3 + C) - ((1)^2 + 1 + C)
             |1
 

(9 + 3 + C) - (1 + 1 + C) = (12 + C) - (2 + C) = 12 - 2 + C - C = 10


The answer is 10. You always take the top minus the bottom.  Notice
that the function must be continous on the integral.  Also,
You can notice that the Constant "+ C" drops out.  This will always
be the case since you are subtracting top from bottom.  


Trigometric functions have special anti-dirivatives.

Int(cos(x)dx) = sin(x) + C
Int(sin(x)dx) = -cos(x) + C
Int(dx/x) = ln|x| + C


For what ever variable you use in the integral, you must have a dirivative
of it in order to get the antidirviatvie. Let us look at the following
situation.


Integral(cos^2(x)sin(x)dx)

Obviously you can't seperate multiplication or divsion like you can
addition and subtraction just like with dirivatives.  BUT, there also
is no clean method for solving this either.  There are tons of methods
some integrals are almost impossible to solve and very long.

This integral, if you notice, Dirivative of cos(x) is -sin(x)dx

We could change the problem.
U = cos(x)
DU = -sin(x)dx

There is no negative in the problem, so we have to compenstate.
You can multiply by a double negative.

Integral(-U^2 DU) And we know the integral os U^2 would be:


- U^3
------  +  C
   3


Substitute back in for U

 -cos^3(x)/3 + C



We can check this out too, by going backwards.


-cos^3(x)/3 + C   The constant drops out.


And we do the -3cos^2(x)/3   BUT, you remeber, the Chain rule.  You must multiply
by the dirivative of the inside now.

The 3's divide out

-cos^2(x)*-sin(x)

Double Negatives cancel, the diriviative of x is 1 (Using chain rule Again) so 
the answer is just

cos^3(x)sin(x) (multipled by dx if you want to use the chain rule all the way down)


If we didn't go into it much in the last tutorial, For every basic function and
rule, you must keep taking the "dirivative" of that function.  It is like a 
chain.  Here is an example.


cos^3(sin^2(2x^2))

If we want to take the dirivative, the FIRST rule would be the power rule.


aU^n = a*nU^(n-1)*U`

3cos^2(sin^2(2x^2))*(cos(sin^2(2x^2)))`

Now, onto the next dirivative (cos(sin^2(2x^2)))`

The dirivative of the cos is

cos(x) = -sin(x)dx

3cos^2(sin^2(2x^2))*(-sin(sin^2(2x^2)))*(sin^2(2x^2))`

Now, we are on the next Dirivative (sin^2(2x^2))`


aU^n = a*nU^(n-1)*U`

3cos^2(sin^2(2x^2))*(-sin(sin^2(2x^2)))*(2sin(2x^2))*(sin(2x^2))`

The next one (sin(2x^2))`

sin(x) = cos(x)dx

3cos^2(sin^2(2x^2))*(-sin(sin^2(2x^2)))*(2sin(2x^2))*(cos(2x^2))(2x^2)`


The next one (2x^2)`

aU^n = a*nU^(n-1)*U`


3cos^2(sin^2(2x^2))*(-sin(sin^2(2x^2)))*(2sin(2x^2))*(cos(2x^2))(4x)(x)`


And the dirivative of x, which is dx (can be referred to as 1 too.



3cos^2(sin^2(2x^2))*(-sin(sin^2(2x^2)))*(2sin(2x^2))*(cos(2x^2))(4x)dx

or

3cos^2(sin^2(2x^2))*(-sin(sin^2(2x^2)))*(2sin(2x^2))*(cos(2x^2))(4x)

Now, to condence

-24*cos^2(sin^2(2x^2))*sin(sin^2(2x^2))*sin(2x^2)*cos(2x^2)*x


Now, that function would be hell to get the integral of.

But, we can try.

Integral(-24*cos^2(sin^2(2x^2))*sin(sin^2(2x^2))*sin(2x^2)*cos(2x^2)*x*dx)

We can pull the constant -24 out front.

-24*Integral(cos^2(sin^2(2x^2))*sin(sin^2(2x^2))*sin(2x^2)*cos(2x^2)*x*dx)


Now, take it ONE step at a time.  First, we have x, we need to take x out.

Look that 2x^2 is everywhere in the function.

If we do U = 2x^2 DU = 4xdx  We can substitue in:

Take the x and divide a 4 out of the -24 for the 4.


-6*Integral(cos^2(sin^2(U))*sin(sin^2(U))*sin(U)*cos(U)*DU)


Now what?  Well, I see that there is a sin^2(U) in side two of the functions,
so we could subsitute:

Z = sin^2(U)  DZ = 2sin(U)cos(U)DU

Take the 2 out of the -6 And you notice that sin(U)*cos(U)*DU is the last
part of the function anyway.

-3*Integral(cos^2(Z)*sin(Z)*DZ)

Now, substitue  T = cos(Z)  DT = -sin(Z)DZ


Take the negative off the front

3*Integral(T^2*DT)


Now, you simply solve the simple equation.


3*T^3/3 + C is the answer.  Now subsitute back in

T^3 + C

Well, T = cos(Z)


cos^3(Z) + C

Z = sin^2(U)

cos^3(sin^2(U)) + C

U = 2x^2

cos^3(sin^2(2x^2)) + C


And hence we get our original equation.  In our original equation C = 0, but
we have no way of knowing that if we just took the integral and knew nothing
about the original function.


Thus, you should see how the chain rule works, and how substitution works
using reverse chain rule.


 
About Toby Opferman

Professional software engineer with over 15 years...

Learn more »
Codeproject Articles

Programming related articles...

Articles »
Resume

Resume »
Contact

Email: codeproject(at)opferman(dot)com