[Math] Finding value of (y) of logarithmic equation given (x)

logarithmsMATLABmaxima-softwarenonlinear systemoctave

I have an logarithmic equation
$$\left[ r=a\,e^{b\,\theta} \right] $$

And I plot it to visualise it (see plot below).
I can tell by the plot when (t=0), x1=0, y=1 (point AA)
but how can I find out numerically what (y2) point BB will be when x2=.5 (the red dot on the plot (point BB)) by using an equation.

image

Eq Solve for a
$$\left[ a={{r}\over{e^{b\,\theta}}} \right] $$

Eq to Solve for b
$$\left[ b={{\log \left({{r}\over{a}}\right)}\over{\log e\,\theta
}} \right] $$

Eq to Solve for theta
$$\left[ \theta={{\log \left({{r}\over{a}}\right)}\over{b\,\log e
}} \right] $$

I tried solving the equations using maxima but it came back with a large list of logs instead of a one numerical value.

kill(all);
r:.5; a:1; b:-5.7; theta:theta; solve(a*e^(b*theta)=r,theta);
tex(''%);

I'm still at a loss as to how to find (y2) at point BB when (x2=.5) (y2=?)

Ps: I'll be using octave 3.8.1 to calculate these values which is like matlab but I'm just trying to get the
equations worked out correctly.

Best Answer

Say you're trying to solve for $\theta$ (i.e., $x_2$) in $ r = a e^{b \theta}$ and are unable to find an analytical solution. You can use numerical root-finding. In Matlab and Octave fzero (documentation) solves for roots/zeros of simple univariate functions. The first step is to re-write your equation as $ 0 = a e^{b \theta}-r$. Then, with th0 as an initial guess, you can solve for a root via:

a = 1;
b = -5.7;
r = 0.5;
th0 = 1;
f = @(th)a*exp(b*th)-r;
[th_sol,fval,exitflag] = fzero(f,th0)

This returns 0.121604768519289 for th_sol. In this case, this is equivalent to the analytical solution $\theta = \text{log}(r/a)/b$.

Of course if you're solving for $y_2$ (i.e., $r$), you don't need to do anything special. Just evaluate:

a = 1;
b = -5.7;
th = 0.5;
r = a*exp(b*th)
Related Question