HP Forums

Full Version: Is there a way for the solve app to use exact figures?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there.

I am trying to solve this equation:

a^2+b^2+c^2+6=a given that b=6 and c=31.

I'm particularly having trouble trying to get the given parts of that equation to work

I know how to do this via the solve app, but I can't get exact figures with the app, and it doesn't play nice with non-linear equations.

So is there a different way solve that equation and still get exact figures?
(10-22-2020 03:03 AM)Lord_Spooglypuff Wrote: [ -> ][....]
I know how to do this via the solve app, but I can't get exact figures with the app, and it doesn't play nice with non-linear equations.

So is there a different way solve that equation and still get exact figures?

There are 2 ways I found:
Code:
exact(proot([1,-1,6^2+31^2]))
Code:
exact(QuadSolve(1,-1,6^2+31^2))
The roots are:
Code:
[(6188-390727*i)/12376,(6188+390727*i)/12376]
(10-22-2020 04:11 AM)Stevetuc Wrote: [ -> ]exact(proot([1,-1,6^2+31^2]))

2 issues:
1). you missed the +6 for the constant term.
2). approximate solutions, then apply exact, does not give exact solutions.
(some cases do work, if exact solutions are "simple" rational; but not in general)

BTW, exact is a bad name. It really meant float2rational (conversion likely *not* exact)

I don't have HP Prime, but in XCas, you can use solve (with complex ON)

XCas> eqn := subst(a^2+b^2+c^2+6-a, [b,c]=[6,31])       → a^2-a+1003
XCas> solve(eqn=0, a)       → \([{1+i\sqrt{4011} \over 2}, {1-i\sqrt{4011} \over 2}]\)
(10-22-2020 04:36 PM)Albert Chan Wrote: [ -> ]
(10-22-2020 04:11 AM)Stevetuc Wrote: [ -> ]exact(proot([1,-1,6^2+31^2]))

2 issues:
1). you missed the +6 for the constant term.
2). approximate solutions, then apply exact, does not give exact solutions.
(some cases do work, if exact solutions are "simple" rational; but not in general)

BTW, exact is a bad name. It really meant float2rational (conversion likely *not* exact)

I don't have HP Prime, but in XCas, you can use solve (with complex ON)

XCas> eqn := subst(a^2+b^2+c^2+6-a, [b,c]=[6,31])       → a^2-a+1003
XCas> solve(eqn=0, a)       → \([{1+i\sqrt{4011} \over 2}, {1-i\sqrt{4011} \over 2}]\)

Thanks Albert, I learnt something!
Knowing the limitation of proot and exact, we can use it to get exact results.
But, it required confirmations.

Example: find roots of x^2 + (1+i)*x + (3-i) = 0

XCas> [r1, r2] := proot([1, 1+i, 3-i])
→ [-0.920774266234-2.28242839495*i , -0.0792257337659+1.28242839495*i]

Quadratic roots should have a form of c ± √d = (r1+r2)/2 ± √((r1-r2)/2)²

We use the "inexact" nature of exact, to our advantage.
(If results look messy, we can use the even more "inexact" version, float2rational)

XCas> c := exact((r1+r2)/2)            → -1/(1-i) = -1/2-i/2
XCas> d := exact(((r1-r2)/2)^2)      → (-6+3i)/2 = -3+3i/2

Confimation steps:

XCas> simplify(-2*c)      → 1+i, matching linear coefficient.
XCas> simplify(c*c-d)     → 3-i, matching constant term.

→ x roots = c ± √d = (-1/2-i/2) ± √(-3+3i/2)

For quadratics, this is stupid. We get faster results applying quadratic formula.
But, it is useful for simplifying cubics and beyond.

Example: ³√(1859814842094 - 59687820010√415) = 11589 - 145√415

RHS (actually, just 11589) was originally a guess. Then we confirm it.
Using CAS on the Prime:

b:=6
c:=31
solve(a^2+b^2+c^2+6=a,a)

Result:

(1/2)*(i*sqrt(4011)+1),(1/2)*((−i)*sqrt(4011)+1)
(10-22-2020 04:36 PM)Albert Chan Wrote: [ -> ]BTW, exact is a bad name. It really meant float2rational (conversion likely *not* exact)

For what it's worth (apologies if this is too off-topic, just ignore), my notes on exact() — largely pinched from Joe Horn; all mistakes are mine — say:

The abc key in CAS for Real input, executes exact()

exact() uses a simple continued-fraction algorithm; not as good as Joe's PDQ algorithm. The accuracy of exact() is controlled by CAS Settings — Epsilon, but has limited range.

Joe says:
The exact() function in CAS has three shortcomings
- it only finds answers which are principal convergents
- it only allows the tolerance (epsilon) to lie between 10^-6 and 10^-14
- it sometimes returns incorrect answers (outside the specified tolerance)

PDQ has none of these shortcomings
It always finds the unique best answer for any target and tolerance.

PDQ: https://www.hpmuseum.org/forum/thread-61.html
Reference URL's