
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) t_0)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (-b - t_0) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (-b + t_0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (-b - t_0) / (2.0 * a) else: tmp = (2.0 * c) / (-b + t_0) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + t_0)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); tmp = 0.0; if (b >= 0.0) tmp = (-b - t_0) / (2.0 * a); else tmp = (2.0 * c) / (-b + t_0); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t\_0}\\
\end{array}
\end{array}
herbie shell --seed 2024170
(FPCore (a b c)
:name "jeff quadratic root 1"
:precision binary64
(if (>= b 0.0) (/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))))))
Please file a bug report with this information.
| timeline-push!: contract violation expected: jsexpr? given: '#hash((#t . 0.062408491961832624) (unknown . 0.9361273794274894) (precondition . 0.0014641286106780171) (valid . 0.0)) in: the repeated argument of (-> symbol? jsexpr? ... void?) contract from: <pkgs>/herbie/timeline.rkt blaming: <pkgs>/herbie/searchreals.rkt (assuming the contract is correct) at: <pkgs>/herbie/timeline.rkt:10:3 | L | C | |
|---|---|---|---|
| raise-blame-error | /usr/local/racket/collects/racket/contract/private/blame.rkt | 346 | 0 |
| loop | /usr/local/racket/collects/racket/contract/private/list.rkt | 991 | 12 |
| (unnamed) | .../private/arrow-val-first.rkt | 486 | 18 |
| find-intervals | /home/nightlies/herbie/main/src/searchreals.rkt | 86 | 0 |
| make-sampler | /home/nightlies/herbie/main/src/sampling.rkt | 110 | 0 |
| sample-points | /home/nightlies/herbie/main/src/sampling.rkt | 244 | 0 |
| setup-context! | /home/nightlies/herbie/main/src/mainloop.rkt | 45 | 0 |
| get-alternatives/report | /home/nightlies/herbie/main/src/sandbox.rkt | 166 | 0 |
| (unnamed) | /home/nightlies/herbie/main/src/sandbox.rkt | 260 | 6 |
| (unnamed) | /usr/local/racket/share/pkgs/profile-lib/main.rkt | 40 | 10 |
| profile-thunk | /usr/local/racket/share/pkgs/profile-lib/main.rkt | 9 | 0 |
| (unnamed) | /usr/local/racket/collects/racket/engine.rkt | 42 | 24 |