Search code examples
solverexponentialmaximanonlinear-functions

find exponential function given two points


I know I can solve equations in maxima using the commands below but how do I solve for two different equations.

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

I'm trying to get the equation of a exponetial function given two points. How do I go about doing this. Example point 1 is at (2,12) and point 2 is at (8,768)

Image with answer


Solution

  • Maxima needs some help to solve this problem, but it can be done. Start by expression the problem data.

    (%i1) [x1,y1]:[2,12];
    (%o1)                               [2, 12]
    (%i2) [x2,y2]:[8, 768];
    (%o2)                              [8, 768]
    (%i3) eq1:y1 = a*exp(b*x1);
                                              2 b
    (%o3)                            12 = a %e
    (%i4) eq2:y2 = a*exp(b*x2);
                                               8 b
    (%o4)                            768 = a %e
    

    Now try to solve eq1 and eq2 for a and b.

    (%i5) solve([eq1, eq2], [a, b]);
    (%o5)                                 []
    

    Hmm, that's unsatisfying. I'm guessing that Maxima could solve it if we take logarithms which make it linear.

    (%i6) log([eq1, eq2]);
                                      2 b                      8 b
    (%o6)          [log(12) = log(a %e   ), log(768) = log(a %e   )]
    

    Apply the logexpand flag to simplify. Note that % means the previous result.

    (%i7) %, logexpand;
                                      2 b                      8 b
    (%o7)          [log(12) = log(a %e   ), log(768) = log(a %e   )]
    

    Hmm, that didn't do it. There are different forms of logexpand, try another.

    (%i8) %, logexpand=super;
    (%o8)          [log(12) = 2 b + log(a), log(768) = 8 b + log(a)]
    

    OK, good. Now try to solve it.

    (%i9) solve (%, [a, b]);
    (%o9)                                 []
    

    Well, that still didn't work. But I see it's linear in log(a) so solve for that instead.

    (%i10) solve (%o8, [log(a), b]);
                         4 log(12) - log(768)        log(12) - log(768)
    (%o10)    [[log(a) = --------------------, b = - ------------------]]
                                  3                          6
    

    Great. Here are the numerical values:

    (%i11) float (%);
    (%o11)       [[log(a) = 1.09861228866811, b = 0.6931471805599454]]
    

    I'll try to simplify the exact values.

    (%i12) %o10, logexpand=super;
                         4 log(12) - log(768)        log(12) - log(768)
    (%o12)    [[log(a) = --------------------, b = - ------------------]]
                                  3                          6
    

    Hmm, that didn't work. I'll try another function:

    (%i13) radcan(%);
    (%o13)                  [[log(a) = log(3), b = log(2)]]
    

    OK, that was a little bit of work, but anyway maybe it helps.