(35S) Short Pythagorean Triangle Solver Formula
12-07-2014, 09:43 AM (This post was last modified: 06-15-2017 01:58 PM by Gene.)
Post: #1
 Gerald H Senior Member Posts: 1,410 Joined: May 2014
(35S) Short Pythagorean Triangle Solver Formula
Short Pythagorean triangle solver.

C is the hypotenuse of a right-angled triangle.

ABS( [ A , B ] ) = C

For example, solving for A, enter
B = 3
&
C = 5
The calculator returns
A = 4.
12-08-2014, 12:45 PM
Post: #2
 Dieter Senior Member Posts: 2,398 Joined: Dec 2013
RE: HP 35S: Short Pythagorean Triangle Solver Formula
(12-07-2014 09:43 AM)Gerald H Wrote:  Short Pythagorean triangle solver.

C is the hypotenuse of a right-angled triangle.

ABS( [ A , B ] ) = C

Indeed ABS is quite handy for calculating hypotenuses or diagonals of rectangles – I often use it with the [i] key: 3 [i] 4 [ABS] directly returns 5.

But in this case ABS is not the best solution since it has no direct inverse function. Therefore the 35s cannot use one of its most powerful features: solving equations symbolically. The solution and the solving time also depend on the initial guesses provided in X and registers A, B and C.

All this is avoided if the equation is implemented the classic way:

SQ(C) = SQ(A) + SQ(B)

In this case the 35s returns the solution immediately, regardless of the contents of the stack and the data registers. Try it – it's much faster because now the 35s "knows" that in your example B equals √(C² – A²). And it will not return negative results either. ;-)

Dieter
12-08-2014, 01:44 PM (This post was last modified: 12-08-2014 02:22 PM by Gerald H.)
Post: #3
 Gerald H Senior Member Posts: 1,410 Joined: May 2014
RE: HP 35S: Short Pythagorean Triangle Solver Formula
(12-08-2014 12:45 PM)Dieter Wrote:
(12-07-2014 09:43 AM)Gerald H Wrote:  Short Pythagorean triangle solver.

C is the hypotenuse of a right-angled triangle.

ABS( [ A , B ] ) = C

Indeed ABS is quite handy for calculating hypotenuses or diagonals of rectangles – I often use it with the [i] key: 3 [i] 4 [ABS] directly returns 5.

But in this case ABS is not the best solution since it has no direct inverse function. Therefore the 35s cannot use one of its most powerful features: solving equations symbolically. The solution and the solving time also depend on the initial guesses provided in X and registers A, B and C.

All this is avoided if the equation is implemented the classic way:

SQ(C) = SQ(A) + SQ(B)

In this case the 35s returns the solution immediately, regardless of the contents of the stack and the data registers. Try it – it's much faster because now the 35s "knows" that in your example B equals √(C² – A²). And it will not return negative results either. ;-)

Dieter

Thanks for you comments.

The formula I give is surely not the best solution, is however nicely short.

Using ABS( AiB ) = C is orthographically shorter, sadly doesn't function in Solver.

Most students will, I trust, know the classical equation but might find some insight, or indeed a tingle of maths, by discovering an alternative method.

I agree with your critique of the classical way ignoring negative solutions. The occasional occurence (possibly unexpected) just may stir the learners interest to reasoning how that could happen, & I'm sure you wouldn't want to discount half of the available solutions.
12-08-2014, 10:03 PM
Post: #4
 Dieter Senior Member Posts: 2,398 Joined: Dec 2013
RE: HP 35S: Short Pythagorean Triangle Solver Formula
(12-08-2014 01:44 PM)Gerald H Wrote:  The formula I give is surely not the best solution, is however nicely short.
...
Using ABS( AiB ) = C is orthographically shorter, sadly doesn't function in Solver.

With correct syntax it does:
C = ABS(A+i*B)

The mentioned simple 3 i 4 [ABS] is a nice shortcut for direct calculations.

(12-08-2014 01:44 PM)Gerald H Wrote:  I agree with your critique of the classical way ignoring negative solutions.

Maybe I was not clear enough. The main advantage of the classic implementation is that the solver does not have to iterate to find a solution. It is able to solve the equation directly. I think this is a very nice feature of the 35s that is often overlooked.

Dieter
12-09-2014, 06:34 AM
Post: #5
 Gerald H Senior Member Posts: 1,410 Joined: May 2014
RE: HP 35S: Short Pythagorean Triangle Solver Formula
(12-08-2014 10:03 PM)Dieter Wrote:
(12-08-2014 01:44 PM)Gerald H Wrote:  The formula I give is surely not the best solution, is however nicely short.
...
Using ABS( AiB ) = C is orthographically shorter, sadly doesn't function in Solver.

With correct syntax it does:
C = ABS(A+i*B)

The mentioned simple 3 i 4 [ABS] is a nice shortcut for direct calculations.

(12-08-2014 01:44 PM)Gerald H Wrote:  I agree with your critique of the classical way ignoring negative solutions.

Maybe I was not clear enough. The main advantage of the classic implementation is that the solver does not have to iterate to find a solution. It is able to solve the equation directly. I think this is a very nice feature of the 35s that is often overlooked.

Dieter

Bravo! The complex equation is orthographically equally short & betrays my ignorance of the calculator's operation, inelegantly contains 4 operators compared with my 2.

The clarity of your comments is perspicuous.

Arnesophobia is worthy of discussion & can prove debilitating.
 « Next Oldest | Next Newest »

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