Configuring Maxima output as an improper fraction?
Subject: Configuring Maxima output as an improper fraction?
From: van Nek
Date: Fri, 30 Jan 2009 17:27:36 +0100
Hi Luke,
for better readability in an e-mail I use
(%i1) display2d:false$
I guess you are dealing with positive numbers. So the following works for positive numbers.
(%i2) x: 23/7$
(%i3) f(x):= [floor(x), mod(x,1)]$
(%i4) f(x);
(%o4) [3,2/7]
If this representation fits your needs you can format your results with such a function. The
computation backwards is done by an apply "+" or by accessing the list entries via
%[1]+%[2].
(%i5) apply("+",%);
(%o5) 23/7
If you really want to print the "+" here is a quick hack:
(%i6) :lisp(defun $unsimplified_plus (a b) `((mplus simp) ,b ,a))
$UNSIMPLIFIED_PLUS
(%i6) f(x):= unsimplified_plus(floor(x), mod(x,1))$
(%i7) f(x);
(%o7) 3+2/7
This unsimplified "+" can be reevaluated by two single quotes:
(%i8) ''%;
(%o8) 23/7
And there is another one:
(%i9) f(x):= sconcat(floor(x), "+", mod(x,1))$
(%i10) f(x);
(%o10) "3+2/7"
This is a string. (In the default - display2d:true - mode you won't see the quotes.)
(%i11) eval_string(%);
(%o11) 23/7
HTH
Volker van Nek
Am 29 Jan 2009 um 13:21 hat Luke Scharf geschrieben:
> Is there a way to configure Maxima to output the result as an improper
> fraction?
>
> For instance, if I enter 3/4+3/4, then it outputs 3/2. Since I'm doing
> arithmetic for a woodworking project, it would be easier if it would
> output as 1+1/2. Or 1+4/8 would be super-useful, too. Is there a way
> to make Maxima to do that?
>
> Many thanks!
> -Luke
>
> P.S. Please CC me -- I'm not subscribed to the list.
>
> P.P.S. I'm impressed with Maxima -- after using Mathematica and Matlab,
> I'm thrilled to find a mature open-source computer algebra system! With
> wxMaxima, I'll certainly be recommending it to many people!
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima