[Jprogramming] Cool roots
Roger Hui
rogerhui.canada at gmail.com
Wed Dec 12 07:29:59 UTC 2012
You may or may not know that p. employs some extraordinary measures which
produce more accurate results in some difficult cases. But those
extraordinary measures are not "cool". For example:
w=: p. <1+i.20 NB. Wilkinson's
polynomial<http://en.wikipedia.org/wiki/Wilkinson_polynomial>
w
2432902008176640000 _8752948036761600000 13803759753640704000
_12870931245150988800 8037811822645051776 _3599979517947607200
1206647803780373360 _311333643161390640 63030812099294896
_10142299865511450 1307535010540395 _135585182899530 11310276995381 _7561...
p. w
┌─┬──────────────────────────────────────────────────┐
│1│20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1│
└─┴──────────────────────────────────────────────────┘
On Tue, Dec 11, 2012 at 3:40 PM, Henry Rich <HenryHRich at nc.rr.com> wrote:
> None of these cute ways is very accurate in tough cases:
>
> 0j15 ": (2*a) %~ (-b) (+,-) %: (b^2) - 4*a*c [ 'a b c' =. 1e_6 1e6 1e_6
> 0.000000000000000 _1000000000000.000000000000000
>
> But p. does better:
>
> 0j15 ": 1 {:: p. c,b,a
> _1000000000000.000000000000000 _0.000000000001000
>
> Henry Rich
>
>
>
> On 12/11/2012 6:29 PM, Roger Hui wrote:
>
>> There are some cheeky (or is it cheesy?) versions:
>>
>> (2*a) %~ (-b) (+,-) %: (b^2) - 4*a*c NB. Kip Murray
>> (2*a) %~ - b (+,-) %: (b^2) - 4*a*c
>> (+:a) %~ - b (+,-) %: (*:b) - 4*a*c
>> -: a %~ - b (+,-) %: (*:b) - 4*a*c
>>
>>
>>
>> On Tue, Dec 11, 2012 at 11:37 AM, km <km at math.uh.edu> wrote:
>>
>> It appears this could be translated into J as the rather cool
>>>
>>> (2*a) %~ (-b) (+,-) %: (b^2) - 4*a*c
>>>
>>> Sent from my iPad
>>>
>>>
>>> On Dec 11, 2012, at 12:59 PM, Roger Hui <rogerhui.canada at gmail.com>
>>> wrote:
>>>
>>> Example from the Iverson and McDonnell *Phrasal
>>>> Forms*<http://www.jsoftware.**com/papers/fork.htm<http://www.jsoftware.com/papers/fork.htm>>paper
>>>> (which
>>>> introduced fork):
>>>>
>>>> (-b)(+,-)√((b*2)-4×a×c)÷2×a
>>>>
>>>> √ is a postulated APL primitive, spelled %: in J.
>>>>
>>>>
>>>>
>>>>
>>>> On Tue, Dec 11, 2012 at 10:49 AM, km <km at math.uh.edu> wrote:
>>>>
>>>> What is the coolest way of programming the quadratic formula in J? We
>>>>>
>>>> are
>>>
>>>> finding the roots of polynomial c + x*(b + x*a) without using p. . I
>>>>>
>>>> offer
>>>
>>>>
>>>>> roots
>>>>> 3 : 0
>>>>> 'a b c' =. y
>>>>> q =. %: (b^2) - 4*a*c
>>>>> (2*a) %~ (-b) + q,-q
>>>>> )
>>>>> roots 1 3 2
>>>>> _1 _2
>>>>> roots 1 0 1
>>>>> 0j1 0j_1
>>>>> roots 1 _2 1
>>>>> 1 1
>>>>>
>>>>> partly as problem definition. I am looking for cool roots verbs!
>>>>>
>>>>> Kip Murray
>>>>>
>>>>> Sent from my iPad
>>>>>
>>>>> ------------------------------**------------------------------**
>>>>> ----------
>>>>> For information about J forums see http://www.jsoftware.com/**
>>>>> forums.htm <http://www.jsoftware.com/forums.htm>
>>>>>
>>>> ------------------------------**------------------------------**
>>>> ----------
>>>> For information about J forums see http://www.jsoftware.com/**
>>>> forums.htm <http://www.jsoftware.com/forums.htm>
>>>>
>>> ------------------------------**------------------------------**
>>> ----------
>>> For information about J forums see http://www.jsoftware.com/**forums.htm<http://www.jsoftware.com/forums.htm>
>>>
>>> ------------------------------**------------------------------**
>> ----------
>> For information about J forums see http://www.jsoftware.com/**forums.htm<http://www.jsoftware.com/forums.htm>
>>
>> ------------------------------**------------------------------**
> ----------
> For information about J forums see http://www.jsoftware.com/**forums.htm<http://www.jsoftware.com/forums.htm>
>
More information about the Programming
mailing list