Sqrt(1 - x^2) & Sqrt(1 + x^2) functions


In the latest Datafile issue (V31 N2) Wlodek Mier-Jedrzejowicz says his best slide rule (one he actually never used as it was soon replaced by the HP-35), a top of the range model from the German company Aristo, had 30 scales on it. They included the sqrt(1 - x2) and sqrt(1 + x2) functions, which to this day, he says, are not available on calculators. Well, they can be implemented using only two steps each (four, if we count LBL and RTN) on most RPN programmable calculators, like the HP-11C, for instance. Is someone willing to present these or other solutions?


Sin(Arccos(x)) = Sqrt(1 - x^2)

Cosh(Arcsinh(x)) = Sqrt(1 + x^2)




More interesting from a numeric standpoint are 1-sqrt(1-x2) and sqrt(1+x2)-1.

- Pauli


No problem - all this can be done with two other functions that are available on HP calculators since 1979 - and today again on the 34s:

   sqrt(1+x^2) - 1                1 - sqrt(1-x^2)
= exp(ln(1+x^2)/2) - 1 = 1 - exp(ln(1-x^2)/2

x^2 x^2
LN1+x +/-
2 LN1+x
/ 2
e^x-1 /
RTN e^x-1

That's what these functions are made for. ;-)



It's true that a numerically stable formula for sqrt(1-x^2)-1 for small x can be given in terms of ln(x+1) and exp(x)-1. However, a logarithm/exp combination is a very inefficient way to compute these functions! (E.g., the algorithm for x^2 is not exponentiating twice the log. For that matter, efficient algorithms for x^2 do not simply multiply x by itself.)

A related thought: On the opposite case, when abs(x) is close to 1, say for concreteness that x=1-t for some small t, then evaluating sqrt(1-(1-t)^2) directly is numerically unstable, but never forget your algebra: rewrite in the stable form sqrt(t*(2-t)).


Alternatively, multiply through by (1 + sqrt(1-x2)) over itself. A little bit of algebra leads to this formula: 1-sqrt(1-x2) = x2 / (1 + sqrt(1-x2)) which is stable.

The same can be done for sqrt(1+x2)-1.

- Pauli


The old NOVUS 4510 Mathematician had a function (M + x2).


Yeah. I remember that too. Wonder if that was added to give the 4510 a competitive edge, features incentive over TI & HP.

Edited: 10 May 2012, 11:07 p.m.


If you go to Article 437 you will see that the function permitted efficient accumulation of the sums needed for single variable statistical analysis in a machine which did not have a built-in Sum+ capability.

Possibly Related Threads...
Thread Author Replies Views Last Post
  Possible bug with sqrt function in the HP prime Michael de Estrada 6 1,377 11-15-2013, 12:49 PM
Last Post: Michael de Estrada
  [41CL] New Extra Functions version Monte Dalrymple 0 676 11-08-2013, 04:32 PM
Last Post: Monte Dalrymple
  HP Prime: in need of help with defining functions Alberto Candel 14 2,468 10-27-2013, 10:48 AM
Last Post: Alberto Candel
  HP Prime spreadsheet functions SanS 0 1,273 10-04-2013, 04:23 AM
Last Post: SanS
  Stats functions on the HP34S Nicholas van Stigt 5 1,245 09-24-2013, 02:45 AM
Last Post: Nick_S
  Trig Functions Howard Owen 11 2,156 09-16-2013, 02:53 PM
Last Post: Fred Lusk
  50g piecewise functions Kurt Fankhauser 6 1,455 09-15-2013, 08:01 PM
Last Post: Kurt Fankhauser
  Missing functions on the HP Prime!!!??? :-( Namir 6 1,375 08-22-2013, 08:40 AM
Last Post: Gilles Carpentier
  HP41 Functions Address Table (F.A.T.) Antoine M. Couëtte 6 1,346 07-21-2013, 02:48 AM
Last Post: Antoine M. Couëtte
  Trigonometric Functions (HP-17BII) Gerson W. Barbosa 2 1,042 04-09-2013, 11:57 PM
Last Post: Gerson W. Barbosa

Forum Jump: