After 36 years of Algebra2::.
This is the real (imaginary) answer:
f=: 13 : '(2*0{y)%~(-1{y)(+,-)%:(*:1{y)-4*(0{y)*2{y'
f 1 1 _1
0.618034 _1.61803
f 1 0 1
0j1 0j_1
5!:4 <'f'
-- 2
+- *
------+ -- 0
│ L---+- {
│ L- ]
+- ~ --- %
│ -- [:
│ +- -
--+ ----+ -- 1
│ │ L----+- {
│ │ L- ]
│ │ -- +
│ +---+- ,
│ │ L- -
L-----+
│ -- [:
│ +- %:
│ │ -- [:
│ │ +- *:
L---+ ----+ -- 1
│ │ L----+- {
│ │ L- ]
│ +- -
L----+ -- 4
│ +- *
│ │ -- 0
L---+ ----+- {
│ │ L- ]
L----+- *
│ -- 2
L---+- {
L- ]
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of David Lambert
Sent: Saturday, November 7, 2015 9:21 AM
To: programming
Subject: Re: [Jprogramming] Quadratic formula
q2=: (3 : 0)&((0&+) ::('invalid data type'"_))"1
if. ([: -. (3=#) *. (0~:{.)) y do. 'Not quadratic' return. end.
'A B C'=. y
SQRTD=. %: (*:B)- +:^:2 A*C
S=. SQRTD-B
T=. -SQRTD+B
R=. (S [`]@.(<&|) T)%+:A
R , C % R * A
)
(quad,:q2)_1e_10 2 0.0001 NB. quad is RDM monadic p. solution
2e10 _5e_5
2e10 _5e_5
Swapping left and right causes
(quad,:|.@qbad)_1e_10 2 0.0001
2e10 _5e_5
2.04709e10 _4.88498e_5
On 11/07/2015 07:00 AM, [email protected] wrote:
> Date: Fri, 6 Nov 2015 17:18:34 -0600
> From: Kip Murray<[email protected]>
> To:"[email protected]" <[email protected]>
> Subject: [Jprogramming] Quadratic formula
> Message-ID:
> <CAOfWorjaCT8UZTKi-+Z342WAu+YKg9MRNQFSJKXLqgB+=pd...@mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> Most of us have heard of the quadratic formula
>
> x = ( -b +or- %: (b^2 - 4ac) )/2a (roughly standard math notation)
>
> for solving ax^2 + bx + c = 0 for x .
>
> Your mission, should you decide to accept it, is to write a verb quad
> that takes
> vector a,b,c as argument, says ?Not quadratic? if a is 0 , and
> otherwise uses the quadratic formula to find the values of x,
> reporting them in a vector.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm