[Question]
  [
**This question already has answers here**:
 
 
[Diamond Puzzles!](/questions/67952/diamond-puzzles)
 (21 answers)
 
Closed 2 years ago.
When learning to factorise quadratics in the form \$x^2 + ax + b\$, a common technique is to find two numbers, \$p, q\$ such that
$$pq = b \\
p + q = a$$
as, for such numbers, \$x^2 + ax + b = (x + p)(x + q)\$
You are to take two integers \$a, b \in (-\infty, +\infty)\$ and output the two integers \$p, q\$ such that
$$pq = b \\
p + q = a$$
You may take input in any [convenient method](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods) and you may assume that a solution always exists.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so the shortest code in bytes wins
## Test cases
```
2, -15 -> 5, -3
-22, 85 -> -5, -17
6, -16 -> -2, 8
-8, -240 -> -20, 12
-1, -272 -> 16, -17
17, 16 -> 1, 16
-4, 0 -> 0, -4
3, -54 -> 9, -6
13, 40 -> 8, 5
-29, 198 -> -11, -18
11, -12 -> -1, 12
4, -320 -> 20, -16
4, 4 -> 2, 2
```
  
[Answer]
# [Scala 3](http://dotty.epfl.ch/), ~~49~~ 44 bytes
```
a=>b=>(-b*b to b*b)map(p=>a-p->p)find(_*_==b)
```
[Try it onlne!](https://scastie.scala-lang.org/o1O8XHFOTMKTbrrpKrS9DQ)
Takes `(a)(b)` and returns an `Option[(Int, Int)]`. It's now a little more inefficient since it goes from \$-b^2\$ to \$b^2\$ instead of \$-|b|\$ to \$|b|\$, including values that \$p\$ and \$q\$ could never be, but it saves 4 bytes.
```
a => b =>
  (-b*b to b*b)              //Make a range of all possible q's and then some
    map(q => (a - q, q))     //Make a tuple of (p, q)
    find(_ * _ == b)         //Find a pair such that p * q = b
```
[Answer]
# JavaScript (ES7), ~~37 36 34~~ 31 bytes
*Saved 3 bytes thanks to @tsh*
Expects `(a)(b)`.
```
a=>b=>[b=a/2+(a*a/4-b)**.5,a-b]
```
[Try it online!](https://tio.run/##bZDNDoIwEITvPsUeKXbFXVooB3wR46H4F40Ro8bXx66Ug9b7l5lv5uxf/rG9n25PvPa7/XBoB9@uuna17lpf8DzzuS8MdirPF1Z77DbDtr8@@st@cemP2SEDYJUBklUKigKsBixn3wiyIOAigsJQPfvNqT45VYRYg/tF0KkQZpYTstRAnEAkUM0jRNXfMqrFaCqjkFMlOUYQiGWhCk2iXIqyNSPSBCRJIUFgUnYabHJOEwhqXBxFJMLJdKLPOzxR/5ZDMMaSY5e8g@ksGGdF5/AyD28 "JavaScript (Node.js) – Try It Online")
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~23~~ ~~21~~ 18 bytes
```
Solve[x x+#2==x#]&
```
[Try it online!](https://tio.run/##LYtBCoMwEEX3nqIQ6KYTMJOocZHiEQoupYsgSoVqoYQSCPHqaTp19@a9@at1j2m1bhltmk3qX8/PNPiTvzA0xrP7Od3ey@YGxq9z1@V770e77aEICFxUEYrAEUET1VnVpDRwVCWhyNjgD0UDR1ZATQKvFBUJxze2IFpNLg8F7RRwieWfVCxi@gI "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 bytes
```
1ṭÆrN
```
[Try it online!](https://tio.run/##y0rNyan8/9/w4c61h9uK/P6HHm73VnnUtCby//9oIx1dQ9NYnWhdIyMdCxDDDChgBhKw0NE1MjEAsQyBLHMjIMvQXAciZ6IDkjDW0TU1AQkb60AUGlnqGFpagESAWgxBOkx0dI2NDMAMk1gA "Jelly – Try It Online")
Input as a list `[b, a]`.
```
1ṭ       Append 1 to the input, (resulting in [b, a, 1])
  Ær     find roots of polynomial from little-endian coefficient list,
    N    negate each root.
```
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 94 bytes
```
\d+
$*
^(-?)(1*)(,(-)(?<2>\2(1(1)*))|(?<5>(?<6>1)*),)(?<-6>\2)*$(?(6)1)
$1$.2,$4$1$.5
--
-0
0
```
[Try it online!](https://tio.run/##FYqxDsIwDER3f0eQ7GCj2E3SVELtyE9UCCQYWBgQI/8enOWe3t19nt/X@94PeLn1/XGEEOGKshFqJGQUwu1s626oqBSJfu5l9ajrcB67VD9QDLhhJSUIGk7GIQ8WEAGQBKl3Y1F3M24FqksFaSyWE4g6ZwOdebSZE0wsJYNOPGZbWJcG6jc1yCyTJUf@Aw "Retina 0.8.2 – Try It Online") Link includes test cases. Explanation: \$|p|\$ is captured in `$2` and \$|q|\$ is captured in `$5`, with `$6` being a helper balancing group used to verify the multiplication.
```
\d+
$*
```
Convert to unary.
```
^(-?)(1*)
```
Start by matching the sign of \$a\$, then initially assume \$|p|\$ is no greater than \$|a|\$.
```
(,(-)(?<2>\2(1(1)*))
```
If \$b\$ is negative, then we actually end up matching \$|a|\$, and choose \$|q|\$ and overwrite `$2` with \$|p|=|a|+|q|\$, so \$|a|=|p|+|q|\operatorname{sgn}(b)\$.
```
|(?<5>(?<6>1)*),)
```
Otherwise \$b\$ is positive, so overwrite `$5` with \$|q|\$ such that \$|a|=|p|+|q|\operatorname{sgn}(b)\$.
```
(?<-6>\2)*$(?(6)1)
```
Ensure \$|b|=|pq|\$.
```
$1$.2,$4$1$.5
```
Output \$p = |p|\operatorname{sgn}(a)\$ and \$q = |q|\operatorname{sgn}(ab)\$. We then have \$p+q=|p|\operatorname{sgn}(a)+|q|\operatorname{sgn}(ab)=(|p|+|q|\operatorname{sgn}(b))\operatorname{sgn}(a)=|a|\operatorname{sgn}(a)=a\$ while \$pq=|p|\operatorname{sgn}(a)|q|\operatorname{sgn}(ab)=|pq|\operatorname{sgn}(b)=|b|\operatorname{sgn}(b)=b\$ as desired (where \$\operatorname{sgn}(0)=1\$).
```
--
-0
0
```
Fix up extraneous `-`s.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 25 bytes
```
ＮθＮηＩ⊟ΦＥ…·±↔η↔η⟦ι⁻θι⟧⁼ηΠι
```
[Try it online!](https://tio.run/##VckxD8IgEAXg3V/BeCR00MmmkzGadGjTuBqHKxK5BKEFrn8fiZO@6X3vaYtRB3Sl9H7hPPJ7NhFW2e1@baunSD7DGVOGKSxwJZfrM@ACvdeOE23mhv5lYDQvzAZOcwqOa7FSKvGvOykxkOcEqxIkH3W6rIwugVViiuHJOgPJb7pSmkMr9u2xNJv7AA "Charcoal – Try It Online") Link is to verbose version of code. Same idea as @user's Scala solution. Explanation:
```
ＮθＮη
```
Input \$a\$ and \$b\$.
```
Ｅ…·±↔η↔η
```
Loop \$p\$ over \$[-|b|,|b|]\$.
```
⟦ι⁻θι⟧
```
For each \$p\$ create a list \$(p,q)\$ where \$q=a-p\$.
```
Ｉ⊟Φ...⁼ηΠι
```
Output the one with the highest \$p\$ where \$pq=b\$.
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 17 bytes
```
@(x)-roots([1 x])
```
[Try it online!](https://tio.run/##PYzBCoAgEETvfYVHBYV209JD0H@Uh4i6ChXR39tKi7d5zJtJ270@ez7GJU/yVeZM6b7kDOKNKh9yRi0MuKgaygaJPENfip4LT4C2ZYJCA/4EgxbVs1qw1JHjLCsEdYyB/OC5KVfATzQ2HbYVaJ0/ "Octave – Try It Online")
You simply need to solve \$x^2 + ax + b = (x + p)(x + q) = 0\$, and \$x\_1=-p\$, \$x\_2=-q\$.
[Answer]
# [Python 3.8](https://docs.python.org/3.8/), ~~42~~ ~~39~~ 37 bytes
Saved 2 bytes thanks to [Danis](https://codegolf.stackexchange.com/users/99104/danis)!!!
```
lambda a,b:[c:=a/2+(a*a/4-b)**.5,a-c]
```
[Try it online!](https://tio.run/##PZDdboMwDIXveQrfkbBkbcJvkdiLtL0INKhoGyDIpG1Vn505BsbVx7GPfZzxx92HPi7GaWmry/JhPuubASPq8tyUlTnoF2Yic0hkzaPoNRVGNtfF2dnNUAFjWoBUKRfApEYuCDMvZiQWiDo5EivPufascgFbRyKAyjFW04SKiJtFn7DvVJDq7YrcaJGxxg4e2O/RNs7eKEzqdfJ5Uvk6AlOtcMRZ6/bsv6z2HFiUtB03SlIw@nrYurnYb1hn@Gl0JA@au23e7eQjhJcvnSdNKIBIxSEP2mECJyx0Pfx2I6O3E7AH52UA@PnXbFnkOP2NU9c71oYP9wT5Bo/5CY9ty3keJrSxmVfVhpZfnyFf/gA "Python 3.8 (pre-release) – Try It Online")
Port of [Arnauld](https://codegolf.stackexchange.com/users/58563/arnauld)'s [JavaScript answer](https://codegolf.stackexchange.com/a/216270/9481).
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~17~~ 16 bytes
```
(Dn4I*-t‚DOsÆ);(
```
[Try it online!](https://tio.run/##yy9OTMpM/f9fwyXPxFNLt@RRwywX/@LDbZrWGv//6xoZcVmYAgA "05AB1E – Try It Online")
Why oh why aren't there any built-ins for this? This solves the quadratic equation to get the two roots. *-1 thanks to @ovs*
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 8 bytes
```
~+ʰ⟨≜×⟩Ċ
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/pfXa6koGunoFRu/6htw6Ompoe7Omsfbp3wv0771IZH81c86pxzePqj@SuPdP3/Hx1tpBNvaBqrEx1vZKRjAWKYAQXMQAIWOvFGJgYgliGQZW4EZBma60DkTHRAEsY68aYmIGFjHYhCI0sdQ0sLkAhQiyFIh4lOvLGRAZhhEhsLAA "Brachylog – Try It Online")
Takes input as a list `[a,b]`.
```
  ʰ         For the first element of the input,
~+          get a list of integers which sum to it
    ≜       (in order of least absolute value of the first element).
   ⟨ ×⟩     Its product is the second element,
       Ċ    its length is 2,
            and it's the output.
```
I'm not entirely sure why this needs `≜`, but it comes at no cost because the "sandwich" construct `⟨~+×⟩` won't parse without braces around `~+` anyhow (and both `⟨{~+}×⟩Ċ` and `~+ʰ⟨≡×⟩Ċ` would still come out to 8).
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~28 bytes~~ 24 bytes
thanks to att
```
#&@@Solve[#-b==a==#2/b]&
```
[Try it online!](https://tio.run/##Vc1LCoMwEAbgfU8RCLhKqBmjRmQgRyh0KS5iESrUFkqox4@TRWGy/fgfe4jPdQ9xe4R0YJKV9/fP67dOUi@IAVHCdZmrdPtu7@iPCZTQpp3Hyx80EDkuXY50POJIwNacTKYeGJleibJmleCdhiqt5Q2SchUG2hgcz@Qjw39oVTdQl0Kz6QQ "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [dc](https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html), 24 bytes
Input is a line of two numbers from STDIN. Output is to STDOUT.
```
?rdsad*r4*-vla+2/dlar-rf
```
[Try it online!](https://tio.run/##S0n@/9@@KKU4MUWryERLtywnUdtIPyUnsUi3KO3/fyOFeENTAA "dc – Try It Online")
## Explanation
```
?                        # Read a line of input
 r                       # Swap the two numbers
  dsa                    # Store to `a` w/o popping
     d*                  # Square the 1st input
       r                 # Swap up the second input
        4*               # Multiply by four
          -              # Second-to-top - TOS
           v             # Square root
            la+          # Add by `a`
               2/        # Halve
                 d       # Duplicate
                  lar-   # Push `a` - TOS
                      r  # Swap the top 2 items
                       f # Print entire stack
```
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 37 bytes
```
lambda a,b:[p:=a/2+(a*a/4-b)**.5,a-p]
```
[Try it online!](https://tio.run/##PZDRboMwDEXf@Qq/kbBkbQIUWon9SNuHQIOKtrURZNI2xLczx8B4Olz72tdxP/7@fKSl6@e2uswf5rO@GTCiPp3dqTI7/cJMYnaZrHmSvObCSHedvR38ABUwpgVIlXMBTGrkkvAQxAOJJaLO9sQqcKEDq0LA2pEJoHKK1TyjIuJq0UfsO5akBrsiN1pkqrGDR/bb2cbbG4XJg06@QKpYRmCqBfY4a9l@@C@rLQcWJW3HjZIUjL4ctmwutxuWGWEaHcmj5m6bd9uHCPHlSxdZEwsgUmnMo/bZgxcWugf8do7R2wnYgvNTBPiF12xZ4jn9ub57eNbGo59AvsE4TDCuW87Ds0cbG3hVrWj5dYr5/Ac "Python 3.8 (pre-release) – Try It Online")
**[Python 2](https://docs.python.org/2/), 42 bytes**
```
def f(a,b):p=a/2+(a*a/4-b)**.5;print p,a-p
```
[Try it online!](https://tio.run/##PZDdbsMgDIXv8xS@C2SwFkJ@2qlvshuSghptSlBKpW4vnxnTjKtPPj72MeEn3pZZb9vVefDMioGfw8Ue9BuzlT0YOfCqem8@wjrNEYKwMmzR3eMdLsCYFiBVwwUwqZF7wjYVWyr2iNociVXiTidWnYBXhxFAco1qY0hEfFn0CftOPVWTXZEbLbLW2MEL9wxujO5KYZpUJ18i1eURmCrDEWfl7e2/rPYcKErajhslVTB6Pixv7vcb8ow0jY7kxXhz45dbU4Ty86E7M5YCiFRd8sIvK9C3CgfTDL9TYPR/Avbw/FwAPs/892Ijszg/08D59gc "Python 2 – Try It Online")
Takes input as float, and prints the output.
[Answer]
# [Husk](https://github.com/barbuz/Husk), 12 bytes
```
ḟo=¹ΠmSe`-²ṡ
```
[Try it online!](https://tio.run/##ASEA3v9odXNr///huJ9vPcK5zqBtU2VgLcKy4bmh////Nv8tMTY "Husk – Try It Online")
Port of [user](https://codegolf.stackexchange.com/users/95792/user)'s [Scala answer](https://codegolf.stackexchange.com/a/216271/95126).
```
           ṡ    # range of integers from -arg1 to +arg1
     m          # map over each of them
      S         # combining itself
       e        # into a 2-element list with
        `-²     # arg2 minus this;
ḟ               # now find the first element that satisfies
 o              # combine 2 functions:
    Π           # product
  =¹            # equals arg1
```
[Answer]
# [R](https://www.r-project.org/), ~~36~~ 35 bytes
```
function(b,c)b/2+-.5:1*(b^2-4*c)^.5
```
[Try it online!](https://tio.run/##dZHNDoIwEITvPEUTL4AtsmvLj4k@CgaqJFwgErj48riNlNP21s1@O5OZzlvf2mWah@/7@Vnb19wug71v/TraZZjGuJM26S54Vpm5QRp3DSqd2qTJDHcYoxQKTCJOQj2EoeEacZhCAivPKQdCyZKFWxUedFe8YEUc6vwAcykAeRQcWuKOQhE2h5JUvDm4N6@opfDO5Ks0S11pY/SO1TTwYkDckYNSmUCBpAB15fOCCwV8N/8dHmiwGe3@C723q1AFEhPpk9CXYLT9AA "R – Try It Online")
Uses the [Quadratic formula](https://en.wikipedia.org/wiki/Quadratic_formula) with `a=1`.
[Answer]
# [C (gcc)](https://gcc.gnu.org/) `-lm`, 45 bytes
```
f(int*a){*a-=a[1]=(*a+sqrt(*a**a-4*a[1]))/2;}
```
[Try it online!](https://tio.run/##bY9Ra8MgFIWf66@QwkDNlUZj25Qs@yNZHsTNIrTpluRpkr8@d@PyMhgIfp5zz8Xj5NW5lDwLwywsj8LK1naqb5mwxfQ5zngLFI1YVc4PulnS3YaB8UgwQ2fX9Z3u20iiBqmOC5AotYY60wmlU5ZqkNqUGRXiWa@ozrDZBrJXgTya7FSwTesLqEudNQyqnDMgK13@klnI0hD/GOnagYa2bMLzFL7eH57Njh82FMhNKApOI9l9jDjq2f7pjeKRL3QP2CP0XdlvgF0bsls34GvFP5HX4f8AfiV9O3@z1ynJ2/0H "C (gcc) – Try It Online")
Modifies an input array of 2 `int`s.
---
### [C (gcc)](https://gcc.gnu.org/), 53 bytes
```
i;f(int*a){for(i=*a/2;(*a-i)*i-a[1];i--);*a-=a[1]=i;}
```
[Try it online!](https://tio.run/##bY/BasMwDIbP9VOYwsBOJRo7aZvieS@S@WDSZeiwdHQ5zeTZM9nLZTDQ4dP/6xfSgO/DsK7kRkXTXEWdxvtDka/i0TpVRSRdEcbeBEeI2rHic@fJLetHpEnpJDgp56EPvQ0@iWQBzWkBkdBa6AqdWToXqQO0bV3QMF5sRnOBzW6heA3gqS1OA9u0vYK5dkXjoCm5FrCx9S@1i1ic4Otl/kSSrx09f9H3231U86CPG1bMjg4HLZPYfT54dFT7p5vkwhe5B/6DQl@HDUzQTuzyBu4y/om8Tv8H@JT1Bw "C (gcc) – Try It Online")
Doesn't use `sqrt`.
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~28~~ 26 bytes
-2 thanks to Razetime.
```
{⍺-⎕←(⍺÷2)+.5*⍨⍵-⍨⍺×⍺÷4}
```
[Try it online!](https://tio.run/##LYwxDsIwDEX3nOKPUBTUuEmbHqcSEkslGIsQK1sQC@IKbJ0QUsf2JrlIcJIu38/2s7tzLw@Xrj8dQxj8/Xn1bpL@8WLcMC4/2u72pvDu491XpjIt77TRtxAAwoB5VEbMI0WGNQKo87QWnDYx6TI2KjcNCagm6tnREcEGqiQYzfuI4DP2W0bVWh7mB4rvoRNWVK7M@Qc "APL (Dyalog Unicode) – Try It Online")
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 19 bytes
-2 thanks to @Bubbler
```
÷∘2⍛{⍺(+,-)√⍵-⍨⍺*2}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/v@JR24TD2x91zDB61Du7@lHvLg1tHV3NRx2zHvVu1X3UuwIoomVU@/@/goKRQoXCofWGplyH1huB2AoWplwKCmYQUTMuIGkBZhuZGIA4hhCOuRGXgqE5SDlEjQmIqQBUoWAMVmBqApQHMRWA2oDqLYFMQ0sLoCDEAEOgfgUTMNPYyADKBpIA "APL (Dyalog Extended) – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), ~~[46](https://codegolf.stackexchange.com/revisions/216319/1)~~ 39 bytes
```
a!b=[(k,b-k)|k<-[-a*a..],k*b-k*k==a]!!0
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P1ExyTZaI1snSTdbsybbRjdaN1ErUU8vVidbCyiklW1rmxirqGjwPzcxM8@2oCgzr0RFQ9dCU9HoPwA "Haskell – Try It Online")
Kind of boring, but short.
[Answer]
# [convey](http://xn--wxa.land/convey/), 113 bytes
```
v<1
>>>v 0
{?>*"-"v
4*  "vvv
 v  >*vv
v#<<<<vv
-<    vv
*%2   v>v
.1    v}>v
v     v%2v}%2
">>>>>-^>+>^
>>>>>>>>^
```
[Try it online!](https://xn--wxa.land/convey/run.html#eyJjIjoidjwxXG4+Pj52IDBcbns/PipcIi1cInZcbjQqICBcInZ2dlxuIHYgID4qdnZcbnYjPDw8PHZ2XG4tPCAgICB2dlxuKiUyICAgdj52XG4uMSAgICB2fT52XG52ICAgICB2JTJ2fSUyXG5cIj4+Pj4+LV4+Kz5eXG4+Pj4+Pj4+Pl4iLCJ2IjoxLCJpIjoiMiAtMTUifQ==)
Ungolfed, mostly. Uses quadratic formula.
[![enter image description here](https://i.stack.imgur.com/oL5X9.gif)](https://i.stack.imgur.com/oL5X9.gif)
[Answer]
# [Julia 1.0](http://julialang.org/), 34 bytes
```
(a,b)->(d=(a*a-4b)^.5;[a+d,a-d]/2)
```
[Try it online!](https://tio.run/##PZDBTsMwEETv@Yo92mBDvLWTVCiI/7CC5BJHBKG2IkZU/HzY3Yb69DSz4x374/tzTu6yTv2qkjlo@6zGXqW7ZP1Bvz6Ep5juR5PsODyiXkteygI9KIUGrAvagLJI3Ak2LDYidoToa2HH3CKzaw1sE96A2DtygxeTcIvgnub2nagcd5KmiN0hTegqX875reSRy8TA@mAgWibXMkoBBsdVsRZsbjajY6hJ8gy00TZbMshl183d7RKZx1oeOVCH6fQFqpisYT7C73xW8j0G/rvpCujwf02qREqXiMNVfFneTz9s9ZCrfBzXPw "Julia 1.0 – Try It Online")
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf/blob/master/math_golf.txt), 13 [bytes](https://github.com/maxbergmark/mathgolf/blob/master/code_page.py)
```
_½\²¼k-√+`-αÞ
```
I/O as floats.
Port of [*@Arnauld*'s JavaScript answer](https://codegolf.stackexchange.com/a/216270/52210).
[Try it online.](https://tio.run/##y00syUjPz0n7/z/@0N6YQ5sO7cnWfdQxSztB99zGw/P@/zfSM1DQNTTVM@DSNQKxLUBMM7CgGUjQAsQ0MjEAsQ3BbHOgMi5DcyAbosIEyAJJG4NkTU1AkiAmRIuRJUidpQVIFKzdEKQbpEXX2MgAygRiAA)
I have the feeling this can be a byte shorter with some smart stack manipulations, but I've been unable to find anything yet. An equal-bytes alternative could be [`²¼k-√`;½+`-αÞ`](https://tio.run/##y00syUjPz0n7///QpkN7snUfdcxKsD60VztB99zGw/P@/zfSM1DQNTTVM@DSNQKxLUBMM7CgGUjQAsQ0MjEAsQ3BbHOgMi5DcyAbosIEyAJJG4NkTU1AkiAmRIuRJUidpQVIFKzdEKQbpEXX2MgAygRiAA).
**Explanation:**
```
_             # Duplicate the first (implicit) input-float
 ½            # Halve it
  \           # Swap so the first input is at the top of the stack again
   ²          # Square it
    ¼         # Divide it by 4
     k-       # Subtract the second input-float
       √      # Take the square-root of that
        +     # Add it to the halved first input that's still on the stack
         `    # Duplicate the top two values (since the stack only contains a single
              # item, this will first add the first input-float implicitly as leading
              # item, and then duplicate both items)
          -   # Subtract the top two items from one another
           α  # Pair the top two items
            Þ # Only leave the top item of the stack, and discard everything else
              # (after which the entire stack is output implicitly as result)
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~41~~ ~~37~~ 35 bytes
*A port of [Arnauld's answer](https://codegolf.stackexchange.com/a/216270/83605) in Ruby!*
```
->a,b{[b=a/2r+(a*a/4r-b)**0.5,a-b]}
```
[Try it online!](https://tio.run/##VZCxEoMgEET7fAVlYiByJygW5EccCyisMyYWmUy@nRyCYrrbebc7ezcv/h0mG8Tdcf8ZvHU1ztezq1ytZuEvVSVvmjvhx294LK8nmwbkTIAembVs0DQ34ykTgcRMRiIy6HbYRtkmZmjGYlulkolBzEdZKETdYabtfyp0nG2pkUHxKc5ypCSP2kFDSqtEeprbEkZoq0Gd9OEwWoTe5MsgVgJTfKvGQ/9SQ8UPYQ5FmZ4Qfg "Ruby – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~10~~ 9 bytes
```
D(Ÿʒ-y*¹Q
```
[Try it online!](https://tio.run/##yy9OTMpM/f/fRePojlOTdCu1Du0M/P9f19SEyxgA "05AB1E – Try It Online")
Takes input as
```
b
a
```
In case \$p=q\$ it returns only a single value. In case that's not allowed, it's +5 bytes for appending `}Ðgi«`
Explanation:
```
D              duplicate
)              negate
Ÿ              range, so [-b,.. , b]
ʒ              filter
 -             minus the implicit a
  y            the current number
   *           multiply
    ¹          the first item from the input history - b
     Q         is equals
```
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal), 3 bytes
```
∆QN
```
[Try it Online!](http://lyxal.pythonanywhere.com?s=?flags=&code=%E2%88%86QN&inputs=2%0A-15&header=&footer=)
Solve for the roots and then negate
[Answer]
# [Whispers v2](https://github.com/cairdcoinheringaahing/Whispers), ~~110~~ 92 bytes
*Edit: -18 bytes (within less than 2 minutes of submission!) thanks to caird coinheringaahing and the `±` operator*
```
> Input
> Input
> 2
> 4
>> 1*3
>> 2⋅4
>> 5-6
>> √7
>> 8÷3
>> 1÷3
>> 10±9
>> Output 11
```
[Try it online!](https://tio.run/##K8/ILC5ILSo2@v/fTsEzr6C0hAtBGwGxCZednYKhljGIMnrU3Qrmm@qagahHHbPMQbTF4e1geUMYbXBooyWI4V9aAjRJwdDw/38jLl1DUwA "Whispers v2 – Try It Online")
My first **Whispers** program.  
Uses the [Quadratic formula](https://en.wikipedia.org/wiki/Quadratic_formula) with `a=1`.
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 33 bytes
```
f(a,b)=round(polroots(x^2+a*x+b))
```
[Try it online!](https://tio.run/##LctNCoMwEAXgqwyukpqAifFv0V5ELMQWixBMiBbs6dPJ4O6b9@YFG1f5CSktzIqZ36P/bm8WvIveHzs7n7q0t7OcOU82BPdjFuQDQly3A1nko4CXdY4tAiznAsZRC5CqmZBSo3tim8OWwh6pTUVW2Z3OVp2A68MIoLrGtjFUIq@JHvBv6CnNc0VrnMhaVxfNNPH0Bw "Pari/GP – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 39 bytes
```
f a b=let c=a/2+(a*a/4-b)**0.5in[c,a-c]
```
[Try it online!](https://tio.run/##XcwxDsIgGMXxvad4gwOgUIo0MU04gJMHMA5fsY1ERKO9P1I3Gd/vn7wbfe5TjDnPIIwuTgu8o9ZsGQlqrRy5EFr1IZ39jqS/5AeFhGHA8QTGm99yuD4b4PUOacEGM4zSYLLrleZ/zqQpieNQShXs6rribl@ObK12RaXzFw "Haskell – Try It Online")
]