5

I'm using maxima software to help me simplify formulas. Usually, I can manage easily with subst, ratsubst, factor, ratsimp, ... But there are still are few formulas I find hard to simplify the way I'd like to.

  1. assuming that a > b and c > d, I'd like to simplify fractions starting with a - sign this way :

    -(a - b)/(d - c)    ->   ( a - b )/( c - d)
    

    but I don't how to do it. It seems that maxima simplifier algorithm will try to sort variables in its own way.

    I created my own maxima function to try to simplify these useless minus signs.

    no_minus(fraction):=
      block([simp:true,
         numerat:expand(-ratnumer(fraction)),
         denominat:expand(-ratdenom(fraction))],
        block([simp:false],
          numerat/denominat));
    -a/(b-x);
    no_minus(-a/(b-x));
    no_minus(-a*b*c/(b-x*b*f-f));
    

I'd expected no_minus(-a/(b-x)) would have returned a/(x-b) but it didn't.

  1. I'd like to introduce a new infix operator to denote that two expressions are approximately equal. For instance, if x is approximately equal to y. I'd like to note it

    x =~ y
    
    infix("=~").
    

How to configure the simplifier so that when the input is

2*x+3 =~ u+v;  
(%-3)/2;

the output is

x =~ (u+v-3)/2
desertnaut
  • 57,590
  • 26
  • 140
  • 166
Arthur
  • 51
  • 3

1 Answers1

6

Well, you can define simplification rules via tellsimp (and tellsimpafter, defrule, and defmatch). Maybe this is enough to get started.

(%i3) infix ("=~") $
(%i4) matchdeclare ([aa, bb, cc], all) $
(%i5) tellsimp ((aa =~ bb) * cc, (aa * cc) =~ (bb * cc)) $
tellsimp: warning: rule will treat '?mtimes' as noncommutative and nonassociative.
(%i6) tellsimp ((aa =~ bb) + cc, (aa + cc) =~ (bb + cc)) $
tellsimp: warning: rule will treat '?mplus' as noncommutative and nonassociative.
(%i7) (2*x + 3) =~ (u + v);
(%o7) (2*x+3) =~ (v+u)
(%i8) (% - 3)/2;
(%o8) x =~ ((v+u-3)/2)
Robert Dodier
  • 16,905
  • 2
  • 31
  • 48
  • Thank you, that was really a good start. I just added rbp=80 and lbp=80 to get rid of parenthesis. This is what I needed to solve my infix "approx" operator.; infix("=~"); matchdeclare([aa,bb,cc],all); tellsimp((aa =~ bb)*cc,(aa * cc) =~ (bb * cc)); tellsimp((aa =~ bb)+cc,(aa + cc) =~ (bb + cc)); (2*x+3) =~ (5*y^2+6); (%-3)/2; 2*x+3 =~ 5*y^2+6; (%-3)/2; infix("=~",80,80); 2*x+3 =~ 5*y^2+6; (%-3)/2; "=~"(2*x,3*y+4); %-4; – Arthur Apr 20 '14 at 17:08