2

I have an expression that actually can be expressed in simple form by collecting the specific terms. I have problem in Maxima to substitute or simplify the expression to the known terms.

(%i1) expr:(16*h^2*v_0^2+(38*h*u_0-38*h*u_1)*v_0+25*u_1^2-50*u_0*u_1+25*u_0^2)/3;


                                            2    2                                     2                      2

                                        16 h  v_0  + (38 h u_0 - 38 h u_1) v_0 + 25 u_1  - 50 u_0 u_1 + 25 u_0

(%o1)                                   -----------------------------------------------------------------------

                                                                           3

(%i2) eq1:a1=-h*v_0+2*u_1-2*u_0;
eq2:a2=-2*(h*v_0-u_1+u_0);


(%o2)                                                       a1 = (- h v_0) + 2 u_1 - 2 u_0

(%i3) 

(%o3)                                                        a2 = - 2 (h v_0 - u_1 + u_0)

(%i4) subst([eq1,eq2],expr);


                                            2    2                                     2                      2

                                        16 h  v_0  + (38 h u_0 - 38 h u_1) v_0 + 25 u_1  - 50 u_0 u_1 + 25 u_0

(%o4)                                   -----------------------------------------------------------------------

                                                                           3

What I want is something like this

expr=c1*(a1)^q1 + c2*(a2)^q2

where c1,c2,q1,q2 are the constant that would generated by simplifying expr using known term a1,a2. How to do that? Is there any specific syntax?

Lele Mabur
  • 97
  • 7

1 Answers1

0

Can it be that it is ratsubst what you want?

(%i31) rat(ratsubst(lhs(eq1), rhs(eq1), expr), a1);
               2                                  2                      2
          16 a1  + (- 26 u_1 + 26 u_0) a1 + 13 u_1  - 26 u_0 u_1 + 13 u_0
(%o31)/R/ ----------------------------------------------------------------
                                         3
(%i32) rat(ratsubst(lhs(eq2), rhs(eq2), expr), a2);
               2                             2                    2
           4 a2  + (3 u_1 - 3 u_0) a2 + 3 u_1  - 6 u_0 u_1 + 3 u_0
(%o32)/R/  --------------------------------------------------------
                                      3

ratsubst(to, from, e) susbstitutes from to to while "rewriting" e to fit from. Note that subst is only able to substitute literallly, it cannot transform your expression. In my example above I also use rat with the second argument a1 or a2 so that it expresses both the numerator and the denominator as polynomials in a1 or a2.

Andrii
  • 11
  • 3