| Karim Belabas on Fri, 16 Aug 2013 10:15:28 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: a^2/a^2 not simplified |
* Henri.Cohen@math.u-bordeaux1.fr [2013-08-16 09:37]:
> At \p 19 (for instance), if I write
>
> res=((5.421010862427522171 E-20 + 0.E-19*I)*a^4 + (5.000000000000000000 + 0.E\
> -18*I)*a^2 + (5.421010862427522171 E-20 + 0.E-19*I))/a^2
>
> and then round(res) I obtain
>
> %107 = 5*a^2/a^2
>
> I can understand why, but still this is not very nice. Two questions:
> 1) Is this a bug or a feature?
It's a bug: %107 is an invalid object. The patch below (committed to master)
fixes the problem.
> 2) How can I "simplify" %107, the simplify command does not work.
numerator(%) / denominator(%) would work.
Cheers,
K.B.
diff --git a/src/basemath/gen3.c b/src/basemath/gen3.c
index f079615..e326012 100644
--- a/src/basemath/gen3.c
+++ b/src/basemath/gen3.c
@@ -2109,9 +2109,8 @@ ground(GEN x)
for (i=2; i<lx; i++) gel(y,i) = ground(gel(x,i));
return normalize(y);
case t_RFRAC:
- y = cgetg(3, t_RFRAC);
- gel(y,1) = ground(gel(x,1));
- gel(y,2) = ground(gel(x,2)); return y;
+ av = avma;
+ return gerepileupto(av, gdiv(ground(gel(x,1)), ground(gel(x,2))));
case t_VEC: case t_COL: case t_MAT:
y = cgetg_copy(x, &lx);
for (i=1; i<lx; i++) gel(y,i) = ground(gel(x,i));
--
Karim Belabas, IMB (UMR 5251) Tel: (+33) (0)5 40 00 26 17
Universite Bordeaux 1 Fax: (+33) (0)5 40 00 69 50
351, cours de la Liberation http://www.math.u-bordeaux1.fr/~kbelabas/
F-33405 Talence (France) http://pari.math.u-bordeaux1.fr/ [PARI/GP]
`