Roots of a quadratic function: Difference between revisions

m
m (replaced buggy R version: where in hell did you see that roots are real when the real part of the discriminant is positive???)
Line 1,832:
=={{header|R}}==
<lang R>qroots <- function(a, b, c) {
dr <- sqrt(b * b - 4 * a * c + 0i)
cif (abs(-b +- sqrt(d)r) /> abs(2b *+ ar),) {
z <- (-b -+ sqrt(d)r) / (2 * a))
c(z, c / (z * a))
} else {
z <- (-b - r) / (2 * a)
c(z, c / (z * a))
}
}
 
qroots(1, 0, 2i)
[1] 1-1+1i - 1+-1i</lang>
 
qroots(1, -1e9, 1)
[1] 1e+09+0i 1e-09+0i</lang>
 
=={{header|Racket}}==
1,336

edits