Post Reply 
Is there a way for the solve app to use exact figures?
10-22-2020, 03:03 AM
Post: #1
Is there a way for the solve app to use exact figures?
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?
Find all posts by this user
Quote this message in a reply
10-22-2020, 04:11 AM (This post was last modified: 10-22-2020 06:41 AM by Stevetuc.)
Post: #2
RE: Is there a way for the solve app to use 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]
Find all posts by this user
Quote this message in a reply
10-22-2020, 04:36 PM
Post: #3
RE: Is there a way for the solve app to use exact figures?
(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}]\)
Find all posts by this user
Quote this message in a reply
10-22-2020, 05:47 PM
Post: #4
RE: Is there a way for the solve app to use exact figures?
(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!
Find all posts by this user
Quote this message in a reply
10-22-2020, 07:19 PM (This post was last modified: 10-22-2020 07:34 PM by Albert Chan.)
Post: #5
RE: Is there a way for the solve app to use exact figures?
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.
Find all posts by this user
Quote this message in a reply
10-22-2020, 07:43 PM
Post: #6
RE: Is there a way for the solve app to use exact figures?
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)

Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co
Find all posts by this user
Quote this message in a reply
10-25-2020, 09:27 PM
Post: #7
RE: Is there a way for the solve app to use exact figures?
(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

Cambridge, UK
41CL/DM41X 12/15C/16C DM15/16 17B/II/II+ 28S 42S/DM42 32SII 48GX 50g 35s WP34S PrimeG2 WP43S/pilot
Casio, Rockwell 18R
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)