maxima

Solve multiple equations


I'm trying to use solve() to get two variables for a power function.

It looks to me, according to the documentation, that I can do the following:

solve ([b*8^a=6,b*18^a=2], [a,b]);

I use the following notation for a power function:

f(x) = b * x^a

Let's say that I have two points (8, 6) and (18, 2) and the graph goes through both points.

In wxMaxima I tried to do:

%i1 solve ([b*8^a=6,b*18^a=2], [a,b]);
%o1 []

Now, I know that I can use define formulas to find a and b, but that is rather long compared to the above. Am I missing some setting for solve()?

Below is my current way to get to get the calculation rule for a power function:

findA: a=(log(y_2/y_1)/log(x_2/x_1));

findB: b = y_1/x_1^a;

[x_1=8,y_1=6,x_2=18,y_2=2];

subst (%, findA), numer;
a=-1.354755645675727

subst ([x_1=8,y_1=6,x_2=18,y_2=2,a=-1.354755645675727], findB), numer;
b=100.37313960722

Solution

  • I'll use the log function to transform the equations into something solve can handle.

    (%i2) e: [b*8^a=6, b*18^a=2];
                            a          a
    (%o2)                 [8  b = 6, 18  b = 2]
    (%i3) log(e);
                      a                    a
    (%o3)       [log(8  b) = log(6), log(18  b) = log(2)]
    

    I need to encourage Maxima to simplify log further.

    (%i4) log(e), logexpand = true;
                      a                    a
    (%o4)       [log(8  b) = log(6), log(18  b) = log(2)]
    

    Hmm, need to try still harder.

    (%i5) log(e), logexpand = super;
    (%o5) [log(b) + log(8) a = log(6), log(b) + log(18) a = log(2)]
    

    Okay, that looks solvable. I'll try solve again.

    (%i6) solve (%o5, [a, b]);
    (%o6)                          []
    

    Oh, I see it's a function of log(b). I can tell solve to consider log(b) as a variable to solve for.

    (%i7) solve (%o5, [a, log(b)]);
                log(6) - log(2)
    (%o7) [[a = ----------------, log(b) = 
                log(8) - log(18)
                                     log(2) log(8) - log(6) log(18)
                                     ------------------------------]]
                                            log(8) - log(18)
    

    Great, I got a solution, now I'll look at the numerical value.

    (%i8) float (%);
    (%o8) [[a = - 1.354755645675727, log(b) = 4.608894637671451]]