Search code examples
maxima

Simplify equation after solving


In Maxima I put:

   q_d: 1000-5*p_d;
   q_s: -250+2*p_s;
   p_d: (1+t)*p_s;
   eq:q_d = q_s;
   solve(eq,p_s);
   EC: 10*q_d + 0.01 * (q_d**2);

get the result

p_s=1250/(5*t+7)

0.01*(1000-5*p_s*(t+1))^2+10*(1000-5*p_s*(t+1))

How do I further simplify EC in term of 't' only?


Solution

  • One way to go about this is to express all the relations you listed as equations, and then solve the equations for the variables you want to eliminate, then you get expressions in terms of t which you can substitute into EC to get a result only in terms of t.

    (%i2) e1: q_d = 1000-5*p_d;
    (%o2)                  q_d = 1000 - 5 p_d
    (%i3) e2: q_s = -250+2*p_s;
    (%o3)                   q_s = 2 p_s - 250
    (%i4) e3: p_d = (1+t)*p_s;
    (%o4)                   p_d = p_s (t + 1)
    (%i5) e4: q_d = q_s;
    (%o5)                       q_d = q_s
    (%i6) solns: solve ([e1, e2, e3, e4], [q_d, q_s, p_d, p_s]);
                    1250 t - 750          1250 t - 750
    (%o6) [[q_d = - ------------, q_s = - ------------,
                      5 t + 7               5 t + 7
                                       1250 t + 1250         1250
                                 p_d = -------------, p_s = -------]]
                                          5 t + 7           5 t + 7
    

    Now in %o6 I have a list of equations for the variables to be eliminated.

    (%i7) EC: 10*q_d + 0.01 * (q_d**2);
                                   2
    (%o7)                  0.01 q_d  + 10 q_d
    

    I'll substitute into EC to get a result in terms of t only.

    (%i8) subst (solns[1], EC);
                                   2
                0.01 (1250 t - 750)    10 (1250 t - 750)
    (%o8)       -------------------- - -----------------
                              2             5 t + 7
                     (5 t + 7)
    

    I'll use ratsimp to simplify the result.

    (%i9) ratsimp (%);
    
    rat: replaced 0.01 by 1/100 = 0.01
                               2
                        46875 t  + 68750 t - 58125
    (%o9)             - --------------------------
                                2
                            25 t  + 70 t + 49