Re: [fricas-devel] [PATCH] rootPower(): handle embedded roots
> > > AFAICS the correct way is to > > first perform substitutions only inside kernels and then > > apply resulting substitution list to x (like in the rootSimp case) > > Should this be the comment of this function? No. > Also, rootPower will not change the height of a kernel, right? Height can change due to simplification. Also, AFAICS there is no need to recurse to rootPower: once arguments of a kernel are handled they will not change. So it is enough to use simpler function that only handles toplevel kernels. OTOH we need to eval arguments of kernels because this may lead to some simplification which would be missed otherwise. I have now commited modified patch. -- Waldek Hebisch -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
Re: [fricas-devel] [PATCH] rootPower(): handle embedded roots
> AFAICS the correct way is to > first perform substitutions only inside kernels and then > apply resulting substitution list to x (like in the rootSimp case) Should this be the comment of this function? Also, rootPower will not change the height of a kernel, right? diff --git a/src/algebra/manip.spad b/src/algebra/manip.spad index 13ce3fe2..9556a3d8 100644 --- a/src/algebra/manip.spad +++ b/src/algebra/manip.spad @@ -376,9 +376,15 @@ x rootPower x == -for k in rootkernels tower x repeat - x := radeval(numer x, k) / radeval(denom x, k) -x + lk := tower x + nlk : List F := [] + for k in lk repeat + if is?(operator k, 'nthRoot) then + x := radeval(numer x, k) / radeval(denom x, k) + nargs := map(rootPower, argument k) + nk : K := kernel(operator k, nargs, height k) + nlk := cons(nk::F, nlk) + eval(x, lk, reverse! nlk) -- replaces (a^(1/n))^m in p by a power of a simpler radical of a if -- n and m have a common factor -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
Re: [fricas-devel] [PATCH] rootPower(): handle embedded roots
oldk1331 wrote: > > (1) -> rootPower atan(2*(x^(1/6))^3) > > 6+-+3 >(1) atan(2\|x ) > > After patch: > > (2) -> rootPower atan(2*(x^(1/6))^3) > >+-+ >(2) atan(2\|x ) > > Similar to previous rootSimp, rootPower doesn't handle > nested roots correctly: it overlooked the case when > root appears at argument. > > diff --git a/src/algebra/manip.spad b/src/algebra/manip.spad > index 13ce3fe2..1fa3a97c 100644 > --- a/src/algebra/manip.spad > +++ b/src/algebra/manip.spad > @@ -376,8 +376,13 @@ > x > >rootPower x == > -for k in rootkernels tower x repeat > - x := radeval(numer x, k) / radeval(denom x, k) > +for k in tower x repeat > + if is?(operator k, 'nthRoot) then > + x := radeval(numer x, k) / radeval(denom x, k) > + else > + nargs := map((e : F) : F +-> rootPower(e), argument k) > + nk : K := kernel(operator k, nargs, height k) > + x := eval(x, k, nk::F) > x > > -- replaces (a^(1/n))^m in p by a power of a simpler radical of a if AFAICS it still has problems: - what happens with sqrt(2*(x^(1/6))^3 + 1)? - after substitution set of kernels changes, so you will miss kernels changed by earlier substitution. AFAICS the correct way is to first perform substitutions only inside kernels and then apply resulting substitution list to x (like in the rootSimp case) -- Waldek Hebisch -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
[fricas-devel] [PATCH] rootPower(): handle embedded roots
(1) -> rootPower atan(2*(x^(1/6))^3) 6+-+3 (1) atan(2\|x ) After patch: (2) -> rootPower atan(2*(x^(1/6))^3) +-+ (2) atan(2\|x ) Similar to previous rootSimp, rootPower doesn't handle nested roots correctly: it overlooked the case when root appears at argument. diff --git a/src/algebra/manip.spad b/src/algebra/manip.spad index 13ce3fe2..1fa3a97c 100644 --- a/src/algebra/manip.spad +++ b/src/algebra/manip.spad @@ -376,8 +376,13 @@ x rootPower x == -for k in rootkernels tower x repeat - x := radeval(numer x, k) / radeval(denom x, k) +for k in tower x repeat + if is?(operator k, 'nthRoot) then + x := radeval(numer x, k) / radeval(denom x, k) + else + nargs := map((e : F) : F +-> rootPower(e), argument k) + nk : K := kernel(operator k, nargs, height k) + x := eval(x, k, nk::F) x -- replaces (a^(1/n))^m in p by a power of a simpler radical of a if -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.