⍝ Real roots of quadratic:

    roots 2 1 ¯3
1 ¯1.5

    roots←{                     ⍝ Roots of quadratic.
        a b c←⍵                 ⍝ coefficients.
        d←(b*2)-4×a×c           ⍝ discriminant.
        (-b+¯1 1×d*0.5)÷2×a     ⍝ both roots.
    }

    roots 1 2 3
¯1J1.414213562 ¯1J¯1.414213562

⍝∇ roots

Back to: code

Back to: Workspaces