[Jprogramming] Fwd: Re: extended precision essay
'Mike Day' via Programming
programming at jsoftware.com
Mon Apr 29 21:35:28 UTC 2019
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 <rauldmiller at gmail.com> 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
>> <programming at jsoftware.com> 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 <rogerhui.canada at gmail.com>
>>> To: Mike Day <mike_liz.day at tiscali.co.uk>
>>>
>>>
>>>
>>> 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
>>> programming at jsoftware.com <mailto:programming at jsoftware.com>.
>>>
>>>
>>>
>>> On Tue, Apr 23, 2019 at 6:58 AM Mike Day <mike_liz.day at tiscali.co.uk
>>> <mailto:mike_liz.day at tiscali.co.uk>> 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
>>
>
More information about the Programming
mailing list