Let's say we have a term like 1/4 * x/sqrt(2) * x^2 / 2;
in Maxima.
As an output (without further modification) it gives x^3/2^(7/2)
.
How can I force the output format to be like x^3/(8*sqrt(2))
with usage of square roots whenever possible?
Asked
Active
Viewed 1,712 times
1

Nico
- 111
- 2
1 Answers
0
(%i1) sq2: " "(sqrt(2))$
(%i2) matchdeclare(n, lambda([n], oddp(n) and n#1))$
(%i3) defrule(r_sq2, 2^(n/2), sq2*2^((n-1)/2)) $
(%i4) e: 1/4 * x/sqrt(2) * x^2 / 2;
3
x
(%o4) ----
7/2
2
(%i5) apply1(e, r_sq2);
3
(sqrt(2)) x
(%o5) -------------
16
A rule can help to insert sqrt(2)
. In the example I use a "null" function to prevent simplification. You can also consider box
and rembox
functions or leave sq2
undefined.

slitvinov
- 5,693
- 20
- 31
-
Works fine for the example with sqrt(2). Is there also a generic approach for all sqrt(int)? – Nico Apr 04 '17 at 06:59