Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Welcome. I am trying to solve numerical integration using Trapezoidal rule. I have two points a and b that I know their f(a) and f(b), respectively. Know suppose that I have a third point c having f(c). How can I determine the value of f(c), giving that I know c? Please notice that I don't know f(x), I have only straight lines on a graph.

I have tried the following formula, but was not succeeded:

f(c) = f(a) + ((c - a) / (b - a))

enter image description here

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The upper line segment is given by $$f(x) = f(a) + \frac{x-a}{b-a}\left(f(b) - f(a)\right)$$ Here is a bit of intuition behind the equation. It is perhaps a bit more interesting (and intuitive) to think of a line in terms of vectors.

If we have points $\mathbf{a}$ and $\mathbf{b}$ then the directed line segment from $\mathbf{a}$ to $\mathbf{b}$ will be given by $\mathbf{b-a}$. We wish to translate this directed line segment first to the point $\mathbf{a}$ and we achieve this by writing $$\mathbf{a} + (\mathbf{b - a})$$ Notice that this is just the point $\mathbf{b}$ as we expect. Now we can move between $\mathbf{a}$ and $\mathbf{b}$ by scaling the directed line segment from $0$ (corresponding to $\mathbf{a}$) to $1$ (corresponding to $\mathbf{b}$). Call this scaling factor $\lambda$. $$\mathbf{a} + \lambda(\mathbf{b - a})$$

Your equation is a special case of this with $\mathbf{a} = f(a)$ and $\mathbf{b} = f(b)$. The term $\frac{x-a}{b-a}$ is your scale factor which runs from $a$ to $b$.

share|improve this answer
    
Thanks. So I was missing only multiplying by f(b) - f(a) :) –  Desolator Oct 24 '12 at 4:05
1  
@Desolator: A good check is units. Imagine that the $x$ axis is one kind of unit, time (for example), and the $y$ axis is length. The correct equation has the units match, while yours does not. This is a good way to check and help find the error. Maybe your problem doesn't have units, but the same question could be asked in physics class where it might. You can use those tools, as well. –  Ross Millikan Oct 24 '12 at 4:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.