Yes, I agree... I had hoped to draw Roger out on what he had in mind
when including those
statements in _his_ sinh function which I quoted below. The cosh
function also has non-productive
if statements.
I suspect he included them to be instructive in some way; maybe the
essay had included comments
about them which he later removed.
Thanks, both,
Mike
On 29/04/2019 21:47, Devon McCormick wrote:
As an experiment, I compared three versions of "sinh": the one we've been
discussing, then a version with the first "if." removed and another with
both removed. For about 2000 random arguments, they all return the same
value. Not conclusive but indicative that the lines have no effect, as one
might guess from looking at the code.
On Mon, Apr 29, 2019 at 4:17 PM Raul Miller <[email protected]> wrote:
Um... sure?
sinh=: DP&$: : (4 : 0) " 0
if. x>10^.|y do. (1r2*_1^0>y)*x exp |y end.
if. 1<|y do. -:-/x exp y,-y end.
e=. 0.1^x
n=. e (>i.1:) y (^%!@]) 1+2*i.>.0.5*y^.e
+/(x:!.0 y) (^%!@]) 1+2x*i.n
)
Your if statements (when triggered) calculate values and then discards
them.
If, for example, you changed that to:
sinh=: DP&$: : (4 : 0) " 0
if. x>10^.|y do. (1r2*_1^0>y)*x exp |y return.end.
if. 1<|y do. -:-/x exp y,-y return.end.
e=. 0.1^x
n=. e (>i.1:) y (^%!@]) 1+2*i.>.0.5*y^.e
+/(x:!.0 y) (^%!@]) 1+2x*i.n
)
Then your if statements would be computing values which are the result
of your sinh.
Or, if you just removed those two lines, your code would produce the
same results it currently produces (with the slight possibility of
eliminating some runtime error cases).
(I've not attempted to look at your code for numerical accuracy, I am
just commenting on its structure.)
I hope this makes sense?
Thanks,
--
Raul
On Mon, Apr 29, 2019 at 1:33 PM 'Mike Day' via Programming
<[email protected]> wrote:
As may be seen, Roger Hui felt unable to advise re my private enquiry
on one of his essays
in the J Wiki. Anyone else feel like commenting on the apparently
unproductive lines of
code?
Thanks,
Mike
-------- Forwarded Message --------
Subject: Re: extended precision essay
Date: Wed, 24 Apr 2019 19:00:47 -0700
From: Roger Hui <[email protected]>
To: Mike Day <[email protected]>
Hi Mike. Thanks for you msg. I am heavily engaged in other matters now,
so if you want to have a more timely answer I suggest you query
[email protected] <mailto:[email protected]>.
On Tue, Apr 23, 2019 at 6:58 AM Mike Day <[email protected]
<mailto:[email protected]>> wrote:
Dear Roger,
I've been trying to use material from your Essay on extended
precision
functions at
https://code.jsoftware.com/wiki/Essays/Extended_Precision_Functions#Utilities
and am puzzled by apparently unproductive code in the hyperbolic
functions,
eg
sinh=: DP&$: : (4 : 0) " 0
if. x>10^.|y do. (1r2*_1^0>y)*x exp |y end.
if. 1<|y do. -:-/x exp y,-y end.
e=. 0.1^x
n=. e (>i.1:) y (^%!@]) 1+2*i.>.0.5*y^.e
+/(x:!.0 y) (^%!@]) 1+2x*i.n
)
I would expect the if statements either
to modify or produce values for use later in the function
or
to have a "return." before the "end."
Not at all important, but I'd welcome your ideas when you have time.
Very sad about John Scholes. I'd guess you enjoyed your
collaboration
at Dyalog,
Best Wishes
Mike
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm