0
$\begingroup$

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

1 Answers 1

1

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$.

  • 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.2012-10-24