# Numerical Analysis - Composite rule

• May 1st 2011, 03:26 PM
purakanui
Numerical Analysis - Composite rule
I am trying to find the more general composite rule of this basic rule :

Integral from 0 to 1 of a function of x = h/12[5f(0) + 8f(1) - f(2)]

This works with h = 1 on f(x) = x for example, but I cannot figure out how to get it to work if you take h = 1/2 for example. Please help! I figured this out but it doesn't seem to work.

h/12[f0+8f1+4f2+8f3+....+4fn-2+8fn-1 -fn]

Thanks
• May 1st 2011, 09:46 PM
CaptainBlack
Quote:

Originally Posted by purakanui
I am trying to find the more general composite rule of this basic rule :

Integral from 0 to 1 of a function of x = h/12[5f(0) + 8f(1) - f(2)]

Your basic quadrature rule should not depend on $h$, you probably mean:

$\int_0^1 f(x) \; dx \approx \frac{1}{12}[5f(0)+8f(1)-f(2)]$

It would also help if you posted the complete question as worded in the original

Quote:

This works with h = 1 on f(x) = x for example, but I cannot figure out how to get it to work if you take h = 1/2 for example. Please help! I figured this out but it doesn't seem to work.

h/12[f0+8f1+4f2+8f3+....+4fn-2+8fn-1 -fn]

Thanks
You build the composite rule from:

$\int_{kh}^{(k+1)h} f(x)\; dx \approx \frac{h}{12}[5f(kh)+8f((k+1)h)-f((k+2)h)]$

for $h=1/n$ and $k=0,..,n-1$

CB
• May 1st 2011, 10:34 PM
purakanui
Proper Question
Let Q(f) be the quadrature rule for Integral from 0 to h f(x)dx that involves f(0), f(h) and f(2h). Ive found Q to be the above h/12[5f0 + 8f(h) - f(2h)]. The question I am stuck on is...

Find the corresponding composite rule for integral from 0 to 1 f(x)dx.

So it says h = 1. Giving: 1/12[5f0 + 8f1 - f2]. But i do not know how to expand this using the composite rule. I thought it would give:

1/12[(5f0 + 8f1 - f2) + (5f2 + 8f3 - f4) +...+(5fn-2 + 8fn-1 - fn)]

= 1/12[5f0 + 8f1 + 4f2 + 8f3 +...+4fn-2 + 8fn-1 - fn]

But that doesn't seem to work, please help now??? Cheers
• May 2nd 2011, 12:50 AM
CaptainBlack
Quote:

Originally Posted by purakanui
Let Q(f) be the quadrature rule for Integral from 0 to h f(x)dx that involves f(0), f(h) and f(2h). Ive found Q to be the above h/12[5f0 + 8f(h) - f(2h)]. The question I am stuck on is...

Find the corresponding composite rule for integral from 0 to 1 f(x)dx.

So it says h = 1. Giving: 1/12[5f0 + 8f1 - f2]. But i do not know how to expand this using the composite rule. I thought it would give:

1/12[(5f0 + 8f1 - f2) + (5f2 + 8f3 - f4) +...+(5fn-2 + 8fn-1 - fn)]

= 1/12[5f0 + 8f1 + 4f2 + 8f3 +...+4fn-2 + 8fn-1 - fn]

But that doesn't seem to work, please help now??? Cheers

Your composite rule should start:

$\int_0^1 f(x)\; dx \approx \frac{h}{12}[(5f_0 + 8f_1 - f_2) + (5f_1 + 8f_2 - f_3) +..$
.................................. $+(5f_{n-2} + 8f_{n-1} - f_n)]$

.............. $= \frac{h}{12}[5f_0 + 13f_1 + 12f_2 + 12f_3 +...+12f_{n-1} + 7f_n - f_{n+1}]$.

Where $h=1/n$

CB