On Tue, 19 Jul 2011 at 14:47 +0200, Simon Weitzhofer wrote:
> my name is Simon Weitzhofer and I'm working on the GeoGebra project
> (www.geogebra.org), a educational mathematic software. We are going to use
> the java version of reduce for the next version of GeoGebra and now I ran
> into a problem with expanding an expression.
>
> The goal is to expand the term 1.2*x*(x+1). The expected result is
> 1.2*x^2+1.2*x. With switch pri set to on the result is 1.2*x*(x + 1), with
> switch pri off the result is (:rd: . 1.2)*x^2 + (:rd: . 1.2)*x. (rounded is
> set to on and roundall, numval to off).
> Any idea how to get rid of the :rd: thing or another way to expand this
> expression?
(:rd: . 1.2) is the internal representation of the rounded number 1.2. The
expression is expanded correctly, but printed incorrectly, ie. it is a bug in
the part of the printer that is exercised when the switch pri is off.
I have a preliminary correction for this; it isn't really tested right now, but
apparently solves your problem. Redefine the procedure xprint as
symbolic procedure xprint(u,flg);
% U is a standard term.
% Flg is a flag which is true if a term has preceded this term.
% Procedure prints the term and returns NIL.
begin scalar v,w;
v := tc u;
u := tpow u;
if (w := kernlp v) and w neq 1
then <<v := quotf(v,w);
if minusf w
then <<oprin 'minus; w := !:minus w; flg := nil>>>>;
if flg then oprin 'plus;
if w and w neq 1
then <<if domainp w then maprin w else prin2!* w; oprin 'times>>;
xprinp u;
if v neq 1 then <<oprin 'times; xprinf(v,red v,nil)>>
end;
by adding this code to your input.
I will test this further before committing the update.
(To other developers: given that the value of variable w can be an arbitrary
domain element, shouldn't the comparisons of w to 1 better be done by
calling !:onep on it?)
Regards,
Rainer
