oldk1331 wrote:
>
> In "sqrt2", instead of factoring expression manually, we can use existing
> "froot":
OK. But this and previous patch really should go as one. So please
commit as a single change.
>
> --- a/src/algebra/solvefor.spad
> +++ b/src/algebra/solvefor.spad
> @@ -64,14 +64,10 @@
> -- we will return both roots later.
> sqrt2(s : F) : F ==
> if F is Expression RR then
> - smpsqfr := squareFree numer s
> - a : F := coerce("*"/[f.factor^(f.exponent quo 2) for f in
> factorList smpsqfr])
> - b : F := coerce("*"/[f.factor^(f.exponent rem 2) for f in
> factorList smpsqfr])
> - u : RR := retract(coerce(unit smpsqfr)@F)
> - sqfru := squareFree u
> - ua := "*"/[f.factor^(f.exponent quo 2) for f in factorList
> sqfru]
> - ub := "*"/[f.factor^(f.exponent rem 2) for f in factorList
> sqfru]
> - ua*a*sqrt(ub*b)
> + K ==> Kernel F
> + PP ==> SparseMultivariatePolynomial(RR, K)
> + res := froot(s, 2)$PolynomialRoots(IndexedExponents K, K,
> RR, PP, F)
> + res.coef * (res.radicand)^(1/res.exponent)
> else
> s^(1/2)
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/fricas-devel/CAGBJN93gf%3Du2J8MkDi3QPvNC7wVn2BHAfEnXUcM6-UHM_7DZWA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>
> --0000000000004e2b0f05867325e0
> Content-Type: text/html; charset="UTF-8"
> Content-Transfer-Encoding: quoted-printable
>
> <div dir=3D"auto">In "sqrt2", instead of factoring expression man=
> ually, we can use existing "froot":<br>
> <br>
> --- a/src/algebra/solvefor.spad<br>
> +++ b/src/algebra/solvefor.spad<br>
> @@ -64,14 +64,10 @@<br>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-- we will return both roots later.<br>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sqrt2(s : F) : F =3D=3D<br>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if F is Expression RR then<=
> br>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 smpsqfr :=3D squar=
> eFree numer s<br>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 a : F :=3D coerce(=
> "*"/[f.factor^(f.exponent quo 2) for f in factorList smpsqfr])<br=
> >
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 b : F :=3D coerce(=
> "*"/[f.factor^(f.exponent rem 2) for f in factorList smpsqfr])<br=
> >
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 u : RR :=3D retrac=
> t(coerce(unit smpsqfr)@F)<br>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 sqfru :=3D squareF=
> ree u<br>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ua :=3D "*&qu=
> ot;/[f.factor^(f.exponent quo 2) for f in factorList sqfru]<br>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ub :=3D "*&qu=
> ot;/[f.factor^(f.exponent rem 2) for f in factorList sqfru]<br>
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ua*a*sqrt(ub*b)<br=
> >
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 K =3D=3D> Kerne=
> l F<br>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 PP =3D=3D> Spar=
> seMultivariatePolynomial(RR, K)<br>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 res :=3D froot(s, =
> 2)$PolynomialRoots(IndexedExponents K, K, RR, PP, F)<br>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 res.coef * (res.ra=
> dicand)^(1/res.exponent)<br>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0else<br>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0s^(1/2)<br></=
> div>
>
> <p></p>
>
> -- <br />
> You received this message because you are subscribed to the Google Groups &=
> quot;FriCAS - computer algebra system" group.<br />
> To unsubscribe from this group and stop receiving emails from it, send an e=
> mail to <a href=3D"mailto:[email protected]">fricas=
> [email protected]</a>.<br />
> To post to this group, send email to <a href=3D"mailto:fricas-devel@googleg=
> roups.com">[email protected]</a>.<br />
> To view this discussion on the web visit <a href=3D"https://groups.google.c=
> om/d/msgid/fricas-devel/CAGBJN93gf%3Du2J8MkDi3QPvNC7wVn2BHAfEnXUcM6-UHM_7DZ=
> WA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.=
> google.com/d/msgid/fricas-devel/CAGBJN93gf%3Du2J8MkDi3QPvNC7wVn2BHAfEnXUcM6=
> -UHM_7DZWA%40mail.gmail.com</a>.<br />
> For more options, visit <a href=3D"https://groups.google.com/d/optout">http=
> s://groups.google.com/d/optout</a>.<br />
>
> --0000000000004e2b0f05867325e0--
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/E1hGT1U-0005hp-O8%40hera.math.uni.wroc.pl.
For more options, visit https://groups.google.com/d/optout.