<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><p class="MsoNormal" style="font-size: 16px; margin: 0cm; font-family: Aptos, sans-serif; caret-color: rgb(33, 33, 33); color: rgb(33, 33, 33);"><span lang="EN-US" style="font-size: 11pt; line-height: 1.2;">Hans</span></p><p class="MsoNormal" style="font-size: 16px; margin: 0cm; font-family: Aptos, sans-serif; caret-color: rgb(33, 33, 33); color: rgb(33, 33, 33);"><span lang="EN-US" style="font-size: 11pt; line-height: 1.2;"> </span></p><p class="MsoNormal" style="font-size: 16px; margin: 0cm; font-family: Aptos, sans-serif; caret-color: rgb(33, 33, 33); color: rgb(33, 33, 33);"><span lang="EN-US" style="font-size: 11pt; line-height: 1.2;">The calculation of ln() is based on arctan<b>h</b>() (not arctan(), sorry for the typo)</span></p><p class="MsoNormal" style="font-size: 16px; margin: 0cm; font-family: Aptos, sans-serif; caret-color: rgb(33, 33, 33); color: rgb(33, 33, 33);"><span lang="EN-US" style="font-size: 11pt; line-height: 1.2;">Unfortunately, arctan() is not as “easy” as ln(). The range reduction gets more complex.</span></p><p class="MsoNormal" style="font-size: 16px; margin: 0cm; font-family: Aptos, sans-serif; caret-color: rgb(33, 33, 33); color: rgb(33, 33, 33);"><span lang="EN-US" style="font-size: 11pt; line-height: 1.2;"> </span></p><p class="MsoNormal" style="font-size: 16px; margin: 0cm; font-family: Aptos, sans-serif; caret-color: rgb(33, 33, 33); color: rgb(33, 33, 33);"><span style="font-size: 11pt; line-height: 1.2;">br</span></p><p class="MsoNormal" style="font-size: 16px; margin: 0cm; font-family: Aptos, sans-serif; caret-color: rgb(33, 33, 33); color: rgb(33, 33, 33);"><span style="font-size: 11pt; line-height: 1.2;">Jörg</span></p><div><br class="Apple-interchange-newline">
</div>
<div><br><blockquote type="cite"><div>Am 23.05.2024 um 13:43 schrieb Hans Klaver <hklaver@dds.nl>:</div><br class="Apple-interchange-newline"><div><div>Hi Jörg,<br><br>You wrote: <br><br><blockquote type="cite">Thx for pointing out.<br>Find a very minor improvement below:<br><br>PROCEDURE ln*(x: REAL): REAL;<br>(* ln(x) = 2*arctanh( (x-1)/(x+1) )<br> around 0, arctan() is almost linear with slope 1<br>*)<br>CONST<br>c1 = 1.4142135; (* sqrt(2) *)<br>c2 = 0.6931472; (* ln(2) *)<br>c3 = 0.89554059;<br>c4 = 1.82984424;<br>c5 = 1.65677798;<br>VAR e: INTEGER;<br>BEGIN<br>ASSERT(x > 0.0); UNPK(x, e); (* x in 1 .. 2 *)<br>IF x > c1 THEN x := x*0.5; INC(e) END; (* x in 0.7 .. 1.4)<br>x := (x - 1.0)/(x + 1.0); (* x in -0.17 .. 0.17 *)<br>x := FLT(e)*c2 + x*(c3 + c4/(c5 - x*x))<br>RETURN x END ln;<br></blockquote><br>Beautiful!<br><br>Thanks. You managed to find an even more elegant form for ln().<br><br>But please note that there is an unclosed comment in the above code.<br><br>You mention the arctan() function, which reminds me of one episode in which I corresponded with Niklaus Wirth, about typos in his online book 'Programming in Oberon (a Tutorial)', later called 'Programming, A Tutorial'. I asked him if he had left out the function procedure arctan deliberately in his definition of Math.Mod (p. 46). He replied: "I did it intentionally, because I find that arctan is rarely used anyway". <br><br>I was shocked. To me it was as if someone left out the icosahedron from the list of Platonic solids "because it is rarely used anyway"! <br><br>The list of standard mathematical functions in programming languages has a long tradition (going back to FORTRAN, and Algol-60), and all these early languages were thought out by mathematicians or physicists, so I thought there was a good *mathemetical* reason to have arctan in the list.<br><br>Wirth was a pragmatic programmer, and for him obviously it was no problem at all to leave arctan out. But he was not extremely thorough, because arctan is still mentioned in 'Programming, A Tutorial', on p. 15 ;-)<br><br>I'm not a mathematician, but in my humble opinion Math.Mod without arctan is lacking. And maybe there are good computer science reasons to include more mathematical functions in it (as proposed in the Oakwood Guidelines).<br><br>Regards,<br><br>Hans<br><br>--<br>Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems<br>https://lists.inf.ethz.ch/mailman/listinfo/oberon<br></div></div></blockquote></div><br></body></html>