# Three Unknowns and Three Equations

1. Aug 21, 2011

### Peter G.

Hi,

I am working on an investigation for school and, before proceeding (or better, before trying again) I wanted to know if this would work.

I have a graph and a proposed model with three variables:

A/1 + Be(-Mx)

x being time.

Is it possible for me to find out these three unknowns (A,B and M) if:

I set up three equations using that model for three different values of x and the y values they correspond in the graph?

Thanks

2. Aug 21, 2011

### HallsofIvy

Staff Emeritus
First, I presume that you mean A/(1+ Be(-Mx)).

Given three different values of x and y, say, $(x_0, y_0)$, $(x_1, y_1)$, and $(x_2, y_2)$, you have the three equations
$$\frac{A}{1+ Be^{-Mx_0}}= y_0$$
$$\frac{A}{1+ Be^{-Mx_1}}= y_1$$
$$\frac{A}{1+ Be^{-Mx_2}}= y_2$$

Dividing two one equation by another eliminates A giving, say,
$$\frac{1+ Be^{-Mx_1}}{1+ Be^{-x_0}}= \frac{y_0}{y_1}$$
so that $y_1(1+ Be^{-Mx_1})= y_0(1+ Be^{Mx_0})$ which we can also write as $B(y_0e^{-Mx_0}- y_1e^{-Mx_1})= y_1- y_0$
and
$$\frac{1+ Be^{-Mx_1}}{1+ Be^{-Mx_2}}= \frac{y_2}{y_1}$$
so that $y_1(1+ Be^{-Mx_1})= y_2(1+ Be^{-Mx_2})$ which we can write as
$B(y_1e^{-Mx_1}- y_2e^{-Mx_2})= y_2- y_1$
and dividing those two equations eliminates B.

I'll leave the rest to you. You might want to cast the equation in terms of hyperbolic functions rather than exponentials.

3. Aug 21, 2011

### Staff: Mentor

Brackets are cheap. No need to go so sparingly.

Can we a asume you mean: y = A/(1 + Be(-Mx)) ?

y1 = A/(1 + Be(-Mx1))
y2 = A/(1 + Be(-Mx2))
y3 = A/(1 + Be(-Mx3))

3 equations in 3 unknowns, so that should be solvable.
You might be able to set up a maths package to solve it, if it looks difficult using pencil and paper.

4. Aug 21, 2011

### Peter G.

Firstly, yes, sorry about the lack of brackets. You guys got the equation correct. I tried doing something similar to what HallsofIvy suggested but I got lost in my work halfway through. I guess I'll try and follow HallsofIvy's work closely and see if I can get to an answer or maybe try and find a math package as NascentOxygen suggested.

Thanks,
Peter G.

5. Aug 21, 2011

### Ray Vickson

What you have written is $A + B e^{-Mx}$. Did you mean $$\frac{A}{1+Be^{-Mx}} ?$$ If so , you should use brackets, like this: A/[1 + B e^(-Mx)].

RGV

6. Aug 21, 2011

### Peter G.

Ok, thanks for the advice RGV.

7. Aug 21, 2011

### Ray Vickson

HallsofIvy gave you some good advice, but he did not point out the clincher: in general, there is no simple formula to solve a problem such as
$$\frac{e^{-Mx_0}-e^{-Mx_1}}{e^{-Mx_1}-e^{-Mx_2}} = \frac{y_0 - y_1}{y_1 - y_2} .$$ In general, we must resort to a numerical method; for example, you can graph the left-hand-side for various M and try to pick off an approximate solution. Then you can correct the initial guess using various improvement methods (which you will see eventually, if you continue your studies). Alternatively, you can use a computer package to solve the problem.

RGV

8. Aug 21, 2011

### dynamicsolo

Here's a thought on fitting a logistic curve to a handful of points (I'm just trying an idea here, although someone must have written about this in the past.) This is something to try in the absence of statistical or other numerical software…

The logistic equation you are using is $y = \frac{A}{1 + Be^{-Mx}}$ , so you probably already know that its horizontal asymptotes are y = 0 and y = A .

The first two derivatives are

$$y \prime = \frac{AMBe^{-Mx}}{(1 + Be^{-Mx})^{2}}$$

and

y''$= AMB \cdot \frac{(1 + Be^{-Mx})(-Me^{-Mx}) - 2(e^{-Mx})(-MBe^{-Mx})}{(1 + Be^{-Mx})^{3}} .$

What we're interested in is the location of the point of inflection, where y'' = 0 ; the denominator of our second derivative expression is never zero, so we can determine that the numerator is zero for $e^{-Mx} = 1/B .$ (I'm writing it this way to make substitutions easier elsewhere.)

The point of inflection is the place where the (positive) slope of the curve is the largest. That maximum slope, found by substituting our result into the expression for y' , is

$$y\prime_{max} = \frac{AMB \cdot \frac{1}{B} }{ (1 + (B \cdot \frac{1}{B}))^{2} } = AM / 4 .$$

The value of the logistic function there is $y_{p.i.} = \frac{A}{( 1 + B \cdot \frac{1}{B} )} = A / 2 .$ (This last is a familiar result.)

This means that the point of inflection is "vertically" midway between the horizontal asymptotes and is located at x = (ln B) / M (solving our expression $e^{-Mx} = 1/B$ for x ). Dividing the maximum slope by (A / 2) gives us ( M / 2 ) . With M known, the x-coordinate gives us B .

How does this help us with your three points? Plot them on a standard y vs. x graph. Of course we don't know where they fall along the curve, so we'll make some kind of estimate. Find the slopes of the three line segments connecting each pair of points.

If the three slopes aren't too different from one another, we might take it that they fall along the "linear" portion of the logistic curve. Let's use the largest of these slopes as the estimate for AM / 4 . We could then take the average of the x-coordinates as the x-coordinate of the point of inflection and the average of the y-coordinates as the y-coordinate of the p.i. , A / 2 . We now have enough information to get an estimate for M , and then for B .

If it looks like the points are approaching one of the asymptotes, there will be greater difference among the three slopes you've worked out. We could then assume that the point of inflection is near the pair of points which gave the largest slope. Take the point farther away from the developing curvature as an estimate of the point of inflection and proceed as described in the previous paragraph.

I'm just suggesting this as something to try which is relatively simple to calculate. A "statistical package" will only give an estimate with sizable error bars on A, B , and M in any case, since you only have three data points to work with...

Last edited: Aug 21, 2011
9. Aug 22, 2011

### Staff: Mentor

It might be fun filling in 3 cells in a spreadsheet and guessing some initial values then perturbating them until results are near enough to a solution. Probably you have a good idea of the time-constant 1/M anyway?

10. Aug 22, 2011

### Ray Vickson

If you use Excel you can exploit the Solver tool, which used some pretty multivariable Newton methods to deal with nonlinear systems. (However, as with any tool, it helps to start from an initial approximation.) I believe some open-source spreadsheets also come with comparable packages.

RGV

RGV

11. Aug 22, 2011

### Peter G.

Hi guys,

I downloaded a free trial of Wolfram Matematica and inputed the three equations and asked it to solve. The values for the parameters fit almost perfectly the graph with the points I needed.

I would have loved to try and do it on paper following the ideas and advice you guys put forward but I am not that great of a mathematician (or simply don't have the tools in my toolbox so far!)

I do however, have more than 3 points (9 actually) and if I could use all of them I would probably get something even closer.

Thanks a lot for the ideas!

Peter G.

12. Aug 22, 2011

### Ray Vickson

If you have only three parameters A, B and M but have 9 data points, you likely cannot hope to get a perfect fit: the A,B and M that work with one set of three points may be different from the A,B and M that work with another set of three points. In cases like this we need to look at "best" fits, which are fits that come as close as possible to all the data points (where "closenesss" can have various definitions). The most common form is the *least-squares* form, in which we choose A, B and M to minimize the sum of the squared residual errors; that is, if f(x) = A/[1+B*e^(-Mx)], we want to minimize S(A,B,M) = sum{[f(x_i) - y_i]^2, i=1,...,9}. Since the parameters A, B and M enter the form of f(x) nonlinearly, we have a nonlinear least-squares problem. This can be handled by sophisticated software, or by setting the derivatives of S(A,B,M) equal to zero and solving the resulting system of nonlinear equations numerically. Here, too, a spreadsheet Solver program could be applied if you don't have access to anything else.

RGV