04-24-2021, 11:08 PM

HP49-50G Square root many digits

Of course there are plenty ways of calculating the square root.

Here is a sequence of commands included in one single program that can be used as a user-assigned key.

ROOT2

\<< "\[] 1 Arg

\[] Put below 101 if

you want 100 digits

" DROP 51 \-> digit

\<< -105 CF DUP "\v/" SWAP + SWAP DUP \v/ SWAP DUP \->STR SWAP FP \-> nb f

\<<

IF f 0 \=/

THEN nb "." POS 1 - \-> pos

\<< nb "." "" SREPL DROP DUP SIZE \-> nb1 sz1

\<< pos 2 / FP 0 ==

IF

THEN sz1 2 / FP 0 \=/

IF

THEN nb1 0 + 'nb1' STO

END

ELSE sz1 2 / FP 0 ==

IF

THEN nb1 0 + 'nb1' STO

END

END nb1

\>>

\>>

ELSE nb "." "" SREPL DROP

END

\>> DUP SIZE 2 / FP 0 == "" 0 IFTE SWAP + DUP SIZE 2 / \-> n sz

\<< { } 0 sz 1 -

FOR i n i 2 * 1 + DUP 1 + SUB OBJ\-> +

NEXT 'n' STO 0 0 0 0 1 \-> a b m s k

\<<

WHILE k digit <

REPEAT a b - 100 * 'a' STO k sz \<=

IF

THEN n k GET 'a' STO+

END 1 'k' STO+ 9 's' STO

WHILE 20 m * s + s * a >

REPEAT -1 's' STO+

END 20 m * s + s * 'b' STO 10 m * s + 'm' STO

END m \->STR \-> st

\<< st 2 50

FOR i st i digit 1 - SUB OBJ\-> 0 ==

IF

THEN 1 i 1 - SUB digit 1 - 'i' STO

END

NEXT OBJ\-> DUP2 ==

IF

THEN SWAP DROP

END

\>>

\>>

\>>

\>>

\>>

52.3 ASN

(Or 52.1 ASN or 52.2 ASN.)

We assign (ASN command) this program to the square root key 52.

Example 1

Introduce for instance 9

and LS User

Then sqrt-key (under the EVAL-key).

You get in level stack 2 sqrt(9)

3 in level stack 1

Example 2

Introduce now 9

and LS User

Then sqrt-key (under the EVAL-key).

You get in level stack 3 sqrt(900)

30 in level stack 2 (normally an approximation).

3, which represents the first "50 digits, less the redundant zeroes".

Example 3

Insure yourself that you are in exact mode.

Type 1234567891234

Then press ENTER

Then press a second time ENTER

Ptess * in order to multiply both identical numbers in the stack.

You should get 1524157878065965654042756

Now LS User

Then sqrt-key (under the EVAL-key).

You get in level stack 3

"Sqrt(1524157878065965654042756)"

In stack level 2 the approximative result 1.23456789124E12

And 1234567891234 in level 1 (the zeroes after the second digit 4 on the right are left out).

Example 4

Insure yourself that you are in exact mode.

Type as argument

1524157878065965654042757

(757 at the end, and not 756).

Now LS User

Then sqrt-key (under the EVAL-key).

You get in level stack 3

"Sqrt(1524157878065965654042756)"

In stack level 2 the approximative result 1.23456789124E12

And 1234567891234 in level 1 (the zeroes after the second digit 4 on the right are left out).

Example 4

Insure yourself that you are in exact mode.

Type as argument

1524157878065965654042757

(757 at the end, and not 756).

Now LS User

Then sqrt-key (under the EVAL-key).

You get in level stack 3

"Sqrt(1524157878065965654042757)"

In stack level 2 the approximative result 1.23456789124E12

And 12345678912340000000000004050000032806863265750682 in level 1. Note that, this time, the zeroes after the second digit 4 on the right do appear as, after them, do appear also different ≠0-digits.

Example 5

12.178 LS-User SQRT-Key

Gives

"sqrt(12.178) " in stack level 3

3.48969912743 in stack level 2

and, in stack level 1, 34896991274320484031821999216879351359311052016725

Example 6

Sqrt 1.2178

Gives, in stack level 3,"sqrt(1.2178)"

1.10353975914 in stack level 2

and, in stack level 1,

11035397591387453041375873710499307803985079728862.

Seems to work fine.

Best is to use the phone EMU48 application if you don't want to way too much for the answers.

Note that you can modify the number of digits to be calculated and shown.

Regards,

Gil Campart

Of course there are plenty ways of calculating the square root.

Here is a sequence of commands included in one single program that can be used as a user-assigned key.

ROOT2

\<< "\[] 1 Arg

\[] Put below 101 if

you want 100 digits

" DROP 51 \-> digit

\<< -105 CF DUP "\v/" SWAP + SWAP DUP \v/ SWAP DUP \->STR SWAP FP \-> nb f

\<<

IF f 0 \=/

THEN nb "." POS 1 - \-> pos

\<< nb "." "" SREPL DROP DUP SIZE \-> nb1 sz1

\<< pos 2 / FP 0 ==

IF

THEN sz1 2 / FP 0 \=/

IF

THEN nb1 0 + 'nb1' STO

END

ELSE sz1 2 / FP 0 ==

IF

THEN nb1 0 + 'nb1' STO

END

END nb1

\>>

\>>

ELSE nb "." "" SREPL DROP

END

\>> DUP SIZE 2 / FP 0 == "" 0 IFTE SWAP + DUP SIZE 2 / \-> n sz

\<< { } 0 sz 1 -

FOR i n i 2 * 1 + DUP 1 + SUB OBJ\-> +

NEXT 'n' STO 0 0 0 0 1 \-> a b m s k

\<<

WHILE k digit <

REPEAT a b - 100 * 'a' STO k sz \<=

IF

THEN n k GET 'a' STO+

END 1 'k' STO+ 9 's' STO

WHILE 20 m * s + s * a >

REPEAT -1 's' STO+

END 20 m * s + s * 'b' STO 10 m * s + 'm' STO

END m \->STR \-> st

\<< st 2 50

FOR i st i digit 1 - SUB OBJ\-> 0 ==

IF

THEN 1 i 1 - SUB digit 1 - 'i' STO

END

NEXT OBJ\-> DUP2 ==

IF

THEN SWAP DROP

END

\>>

\>>

\>>

\>>

\>>

52.3 ASN

(Or 52.1 ASN or 52.2 ASN.)

We assign (ASN command) this program to the square root key 52.

Example 1

Introduce for instance 9

and LS User

Then sqrt-key (under the EVAL-key).

You get in level stack 2 sqrt(9)

3 in level stack 1

Example 2

Introduce now 9

and LS User

Then sqrt-key (under the EVAL-key).

You get in level stack 3 sqrt(900)

30 in level stack 2 (normally an approximation).

3, which represents the first "50 digits, less the redundant zeroes".

Example 3

Insure yourself that you are in exact mode.

Type 1234567891234

Then press ENTER

Then press a second time ENTER

Ptess * in order to multiply both identical numbers in the stack.

You should get 1524157878065965654042756

Now LS User

Then sqrt-key (under the EVAL-key).

You get in level stack 3

"Sqrt(1524157878065965654042756)"

In stack level 2 the approximative result 1.23456789124E12

And 1234567891234 in level 1 (the zeroes after the second digit 4 on the right are left out).

Example 4

Insure yourself that you are in exact mode.

Type as argument

1524157878065965654042757

(757 at the end, and not 756).

Now LS User

Then sqrt-key (under the EVAL-key).

You get in level stack 3

"Sqrt(1524157878065965654042756)"

In stack level 2 the approximative result 1.23456789124E12

And 1234567891234 in level 1 (the zeroes after the second digit 4 on the right are left out).

Example 4

Insure yourself that you are in exact mode.

Type as argument

1524157878065965654042757

(757 at the end, and not 756).

Now LS User

Then sqrt-key (under the EVAL-key).

You get in level stack 3

"Sqrt(1524157878065965654042757)"

In stack level 2 the approximative result 1.23456789124E12

And 12345678912340000000000004050000032806863265750682 in level 1. Note that, this time, the zeroes after the second digit 4 on the right do appear as, after them, do appear also different ≠0-digits.

Example 5

12.178 LS-User SQRT-Key

Gives

"sqrt(12.178) " in stack level 3

3.48969912743 in stack level 2

and, in stack level 1, 34896991274320484031821999216879351359311052016725

Example 6

Sqrt 1.2178

Gives, in stack level 3,"sqrt(1.2178)"

1.10353975914 in stack level 2

and, in stack level 1,

11035397591387453041375873710499307803985079728862.

Seems to work fine.

Best is to use the phone EMU48 application if you don't want to way too much for the answers.

Note that you can modify the number of digits to be calculated and shown.

Regards,

Gil Campart