B Trapezoidal Rule , number of segments

1. Feb 16, 2016

omar yahia

in the trapezoidal rule
is it ok to use a number of segments that is not integer ?

i ask this because in an exam i had , i was asked to use a step of h=0.4
and the interval was from x=1 to x=2
and you know that ," h " is the step ," n " is the number of segments , "a" and "b" are the limits of the integration , so ,
h=(b-a)/n
0.4=1/n
n=2.5 ??! is this ok ?
when i was dealing with "n"=integer , i was able to say that the number of points are n+1
for example
when n=2 segments ------> i have 3 points , x1 ,x2 ,x3
but now with n=2.5 , what are my points ??
thanks

2. Feb 16, 2016

RUber

I have not heard of anybody doing this before and it is not normally recommended.
I suppose you could try to do it with $x_1 = 1, x_2 = 1.4, x_3 = 1.8, x_4 = 2.2$, and simply define your function to be zero outside your interval 1<x< 2.
If you wanted to spread out the error, you could even go to $x_1 = .9, x_2 = 1.3, x_3 = 1.7, x_4 = 2.1$.

Most likely, it was a typo. Maybe h = .04 or h = .25 was what they were thinking.

3. Feb 16, 2016

omar yahia

indeed , it is probably a typo , i think i'll just skip it
i appreciate it that you replied , thank you :)

4. Apr 9, 2016

BreCheese

If you have the Δx, or as you put it, the "step" you don't need "n" to calculate the area using the trapezoidal rule.
in short, Δx=(b-a)/n.
The trapezoidal rule is as follows
Δx[½f(x0)+f(x1)+f(x2)+...+f(xn-1)+½f(xn)] ; where 0, 1, 2, n-1, n are subscripts of x (I just don't know how to use LaTeX). Where your first term, (x0) is your "a" value in the interval (a,b). The next term (x1) is a+Δx. The next term (x2) is (x1)+Δx. The next term (x3) is (x2)+Δx.
Essentially, you just keep adding your Δx, or as you put it, "step" until (xn) equals "b" in the interval (a,b).
Now follow the trapezoidal rule and plug all these "x" values into the function, making sure to multiply the first and last terms in the trapezoidal rule by ½.
Don't forget to multiply your summation by Δx (as stated by the rule)

Did this help?