# Integrals in computers

• Dec 16th 2010, 04:55 AM
dervast
Integrals in computers
Hello everyone I would like to calculate the following integral using computer (because I have to calculate many of them , in different scenarios).

The integral is of the form

Integrate the
s(x)*g(x) from the interval of [a,b]

First I want to understand how to calculate the multiplication of two function before feeding them into the integral function

Regards
A
• Dec 16th 2010, 05:03 AM
Prove It
The two most common ways to evaluate integrals of products are "integration by parts" and "substitution".

I suggest you look them up.
• Dec 16th 2010, 06:35 AM
CaptainBlack
Quote:

Originally Posted by dervast
Hello everyone I would like to calculate the following integral using computer (because I have to calculate many of them , in different scenarios).

The integral is of the form

Integrate the
s(x)*g(x) from the interval of [a,b]

First I want to understand how to calculate the multiplication of two function before feeding them into the integral function

Regards
A

That is too vague please provide more context or explanation

CB
• Dec 16th 2010, 11:43 PM
dervast
Hello,
I tried to upload a pretty simplified version of what I want to calculate so to build understanding how integration works in computers.

ImageShack&#174; - Online Photo and Video Hosting

In the image you will see three plots: s(x), g1(x),g2(x)

At the bottom of the image are the two integrals that I would like to find:
s(x)*g1(x)
s(x)*g2(x).

So first I multiply the two functions and then I integrate them?
• Dec 16th 2010, 11:48 PM
CaptainBlack
Quote:

Originally Posted by dervast
Hello,
I tried to upload a pretty simplified version of what I want to calculate so to build understanding how integration works in computers.

ImageShack&#174; - Online Photo and Video Hosting

In the image you will see three plots: s(x), g1(x),g2(x)

At the bottom of the image are the two integrals that I would like to find:
s(x)*g1(x)
s(x)*g2(x).

So first I multiply the two functions and then I integrate them?

That is still too vague, do you want to use numerical integration methods, do you want an analytic/exact result, ...

CB
• Dec 17th 2010, 12:01 AM
dervast
Numerical integration :)
• Dec 17th 2010, 01:44 AM
HallsofIvy
Then I can see no problem with the multiplication. You have values of f(x) and g(x) at various points- just multiply them together to get f(x)g(x). Yes, you "multiply then then integrate them". That is what "$\displaystyle \int f(x)g(x)dx$" means!

What integration algorithm are you using, Simpson's rule?
• Dec 18th 2010, 07:39 AM
CaptainBlack
Quote:

Originally Posted by HallsofIvy
Then I can see no problem with the multiplication. You have values of f(x) and g(x) at various points- just multiply them together to get f(x)g(x). Yes, you "multiply then then integrate them". That is what "$\displaystyle \int f(x)g(x)dx$" means!

What integration algorithm are you using, Simpson's rule?

There is a technical difficulty in that one of the functions is a saltus function (a step function), which means that most numerical integration schemes become inefficient. The best policy would be to decompose the integrals into a sum of integrals over the intervals on which the saltus function is a constant.

CB
• Jan 12th 2011, 06:07 AM
dervast
Quote:

Originally Posted by CaptainBlack
There is a technical difficulty in that one of the functions is a saltus function (a step function), which means that most numerical integration schemes become inefficient. The best policy would be to decompose the integrals into a sum of integrals over the intervals on which the saltus function is a constant.

CB

Actually for fun sake I tried numerical integration and if step function has only few steps (like 5-10) I get good results... but when the function has like 800steps then I get errors. thus I would like to ask you for a reference
--> that explain the difference between numerical,analytic/extact integration, and anything else that has to do with calculating integrals in computers.

I will also try the solution Captain Black suggested to decompose the integrals into a sum of integrals and I ll post back again.

Regards and Happy new Year!
Alex

EDIT: One more thing I noticed a step function is not continuous thus can not be integrated. Is that right?
• Jan 12th 2011, 01:09 PM
CaptainBlack
Quote:

Originally Posted by dervast

EDIT: One more thing I noticed a step function is not continuous thus can not be integrated. Is that right?

No a piecewise continuous function is integrable.

CB
• Jan 17th 2011, 04:36 AM
dervast