Challenge:
Write the smallest program (in characters) that resolves quadratic equations
i.e. ax² + bx + c = 0
Rules:
Given 3 numbers in R comma-delimited on STDIN: a,b,c (a != 0), print on STDOUT the 2 roots in C, one per line.
R stands for real numbers, C for complex numbers.
Examples:
Input Output
1,0,0 r1=0 also accepted: r1=(-0-sqrt(0))/2
r2=0
1,2,1 r1=-1 also accepted: r1=(-2-sqrt(0))/2
r2=-1
1,1,1 r1=(-1-isqrt(3))/2 also accepted: r1=(-1-sqrt(-3))/2 or r1=-0.5-0.866i
r2=(-1+isqrt(3))/2
isqrt
mean? Are there any constraints on the output format (e.g. canonical forms) or is any expression which resolves to the roots valid? \$\endgroup\$r1=(-2-sqrt(0))/2
be an acceptable output line? How aboutr1=(-1-sqrt(-3))/2
? \$\endgroup\$