
(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}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (a b c)
:precision binary64
(if (<= b -3e+100)
(if (>= b 0.0) (* (/ 0.5 a) (* -2.0 b)) (/ (* 2.0 c) (- (- b) b)))
(if (<= b 5e+64)
(if (>= b 0.0)
(fma (/ b a) -0.5 (/ (sqrt (fma (* -4.0 c) a (* b b))) (* -2.0 a)))
(/ (* 2.0 c) (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c))))))
(if (>= b 0.0)
(/ (* 2.0 (fma a (/ c b) (- b))) (* 2.0 a))
(/ (* 2.0 c) (+ (- b) (- b)))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -3e+100) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (0.5 / a) * (-2.0 * b);
} else {
tmp_2 = (2.0 * c) / (-b - b);
}
tmp_1 = tmp_2;
} else if (b <= 5e+64) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = fma((b / a), -0.5, (sqrt(fma((-4.0 * c), a, (b * b))) / (-2.0 * a)));
} else {
tmp_3 = (2.0 * c) / (-b + sqrt(((b * b) - ((4.0 * a) * c))));
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * fma(a, (c / b), -b)) / (2.0 * a);
} else {
tmp_1 = (2.0 * c) / (-b + -b);
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -3e+100) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(0.5 / a) * Float64(-2.0 * b)); else tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - b)); end tmp_1 = tmp_2; elseif (b <= 5e+64) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = fma(Float64(b / a), -0.5, Float64(sqrt(fma(Float64(-4.0 * c), a, Float64(b * b))) / Float64(-2.0 * a))); else tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))))); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * fma(a, Float64(c / b), Float64(-b))) / Float64(2.0 * a)); else tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) + Float64(-b))); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -3e+100], If[GreaterEqual[b, 0.0], N[(N[(0.5 / a), $MachinePrecision] * N[(-2.0 * b), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 5e+64], If[GreaterEqual[b, 0.0], N[(N[(b / a), $MachinePrecision] * -0.5 + N[(N[Sqrt[N[(N[(-4.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(-2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + (-b)), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3 \cdot 10^{+100}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(-2 \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\end{array}\\
\mathbf{elif}\;b \leq 5 \cdot 10^{+64}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -0.5, \frac{\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)}}{-2 \cdot a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \left(-b\right)}\\
\end{array}
\end{array}
if b < -2.99999999999999985e100Initial program 54.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f6454.4
Applied rewrites54.4%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6496.2
Applied rewrites96.2%
Taylor expanded in a around 0
lower-*.f6496.2
Applied rewrites96.2%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6496.2
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
Applied rewrites96.2%
if -2.99999999999999985e100 < b < 5e64Initial program 93.3%
Applied rewrites93.3%
if 5e64 < b Initial program 48.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f6494.2
Applied rewrites94.2%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6494.2
Applied rewrites94.2%
Taylor expanded in a around 0
distribute-lft-out--N/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6494.2
Applied rewrites94.2%
(FPCore (a b c)
:precision binary64
(if (<= b -3.8e-103)
(if (>= b 0.0) (* (/ 0.5 a) (* -2.0 b)) (/ (* 2.0 c) (- (- b) b)))
(if (>= b 0.0)
(* (- (/ c (* b b)) (pow a -1.0)) b)
(/ (* 2.0 c) (- (sqrt (* (* -4.0 c) a)) b)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -3.8e-103) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (0.5 / a) * (-2.0 * b);
} else {
tmp_2 = (2.0 * c) / (-b - b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = ((c / (b * b)) - pow(a, -1.0)) * b;
} else {
tmp_1 = (2.0 * c) / (sqrt(((-4.0 * c) * a)) - b);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
if (b <= (-3.8d-103)) then
if (b >= 0.0d0) then
tmp_2 = (0.5d0 / a) * ((-2.0d0) * b)
else
tmp_2 = (2.0d0 * c) / (-b - b)
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = ((c / (b * b)) - (a ** (-1.0d0))) * b
else
tmp_1 = (2.0d0 * c) / (sqrt((((-4.0d0) * c) * a)) - b)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= -3.8e-103) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (0.5 / a) * (-2.0 * b);
} else {
tmp_2 = (2.0 * c) / (-b - b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = ((c / (b * b)) - Math.pow(a, -1.0)) * b;
} else {
tmp_1 = (2.0 * c) / (Math.sqrt(((-4.0 * c) * a)) - b);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= -3.8e-103: tmp_2 = 0 if b >= 0.0: tmp_2 = (0.5 / a) * (-2.0 * b) else: tmp_2 = (2.0 * c) / (-b - b) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = ((c / (b * b)) - math.pow(a, -1.0)) * b else: tmp_1 = (2.0 * c) / (math.sqrt(((-4.0 * c) * a)) - b) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= -3.8e-103) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(0.5 / a) * Float64(-2.0 * b)); else tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - b)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(c / Float64(b * b)) - (a ^ -1.0)) * b); else tmp_1 = Float64(Float64(2.0 * c) / Float64(sqrt(Float64(Float64(-4.0 * c) * a)) - b)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= -3.8e-103) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (0.5 / a) * (-2.0 * b); else tmp_3 = (2.0 * c) / (-b - b); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = ((c / (b * b)) - (a ^ -1.0)) * b; else tmp_2 = (2.0 * c) / (sqrt(((-4.0 * c) * a)) - b); end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, -3.8e-103], If[GreaterEqual[b, 0.0], N[(N[(0.5 / a), $MachinePrecision] * N[(-2.0 * b), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] - N[Power[a, -1.0], $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(N[Sqrt[N[(N[(-4.0 * c), $MachinePrecision] * a), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.8 \cdot 10^{-103}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(-2 \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\left(\frac{c}{b \cdot b} - {a}^{-1}\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\sqrt{\left(-4 \cdot c\right) \cdot a} - b}\\
\end{array}
\end{array}
if b < -3.8000000000000001e-103Initial program 76.1%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f6476.1
Applied rewrites76.1%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6485.8
Applied rewrites85.8%
Taylor expanded in a around 0
lower-*.f6485.8
Applied rewrites85.8%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6485.8
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
Applied rewrites85.8%
if -3.8000000000000001e-103 < b Initial program 74.2%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f6471.6
Applied rewrites71.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6470.0
Applied rewrites70.0%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6470.0
Applied rewrites70.0%
Final simplification75.9%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (fma -4.0 (* c a) (* b b)))))
(if (<= b -3e+100)
(if (>= b 0.0) (* (/ 0.5 a) (* -2.0 b)) (/ (* 2.0 c) (- (- b) b)))
(if (<= b 5e+64)
(if (>= b 0.0) (* (/ (+ t_0 b) a) -0.5) (/ (* 2.0 c) (- t_0 b)))
(if (>= b 0.0)
(/ (* 2.0 (fma a (/ c b) (- b))) (* 2.0 a))
(/ (* 2.0 c) (+ (- b) (- b))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(fma(-4.0, (c * a), (b * b)));
double tmp_1;
if (b <= -3e+100) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (0.5 / a) * (-2.0 * b);
} else {
tmp_2 = (2.0 * c) / (-b - b);
}
tmp_1 = tmp_2;
} else if (b <= 5e+64) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = ((t_0 + b) / a) * -0.5;
} else {
tmp_3 = (2.0 * c) / (t_0 - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * fma(a, (c / b), -b)) / (2.0 * a);
} else {
tmp_1 = (2.0 * c) / (-b + -b);
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(fma(-4.0, Float64(c * a), Float64(b * b))) tmp_1 = 0.0 if (b <= -3e+100) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(0.5 / a) * Float64(-2.0 * b)); else tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - b)); end tmp_1 = tmp_2; elseif (b <= 5e+64) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(Float64(t_0 + b) / a) * -0.5); else tmp_3 = Float64(Float64(2.0 * c) / Float64(t_0 - b)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * fma(a, Float64(c / b), Float64(-b))) / Float64(2.0 * a)); else tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) + Float64(-b))); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -3e+100], If[GreaterEqual[b, 0.0], N[(N[(0.5 / a), $MachinePrecision] * N[(-2.0 * b), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 5e+64], If[GreaterEqual[b, 0.0], N[(N[(N[(t$95$0 + b), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + (-b)), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}\\
\mathbf{if}\;b \leq -3 \cdot 10^{+100}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(-2 \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\end{array}\\
\mathbf{elif}\;b \leq 5 \cdot 10^{+64}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{t\_0 + b}{a} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \left(-b\right)}\\
\end{array}
\end{array}
if b < -2.99999999999999985e100Initial program 54.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f6454.4
Applied rewrites54.4%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6496.2
Applied rewrites96.2%
Taylor expanded in a around 0
lower-*.f6496.2
Applied rewrites96.2%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6496.2
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
Applied rewrites96.2%
if -2.99999999999999985e100 < b < 5e64Initial program 93.3%
Taylor expanded in a around 0
Applied rewrites93.3%
if 5e64 < b Initial program 48.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f6494.2
Applied rewrites94.2%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6494.2
Applied rewrites94.2%
Taylor expanded in a around 0
distribute-lft-out--N/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6494.2
Applied rewrites94.2%
(FPCore (a b c)
:precision binary64
(if (<= b -2.9e+100)
(if (>= b 0.0) (* (/ 0.5 a) (* -2.0 b)) (/ (* 2.0 c) (- (- b) b)))
(if (<= b 5e+64)
(if (>= b 0.0)
(* (/ (+ (sqrt (fma -4.0 (* c a) (* b b))) b) a) -0.5)
(* (/ 2.0 (- (sqrt (fma (* c -4.0) a (* b b))) b)) c))
(if (>= b 0.0)
(/ (* 2.0 (fma a (/ c b) (- b))) (* 2.0 a))
(/ (* 2.0 c) (+ (- b) (- b)))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -2.9e+100) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (0.5 / a) * (-2.0 * b);
} else {
tmp_2 = (2.0 * c) / (-b - b);
}
tmp_1 = tmp_2;
} else if (b <= 5e+64) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = ((sqrt(fma(-4.0, (c * a), (b * b))) + b) / a) * -0.5;
} else {
tmp_3 = (2.0 / (sqrt(fma((c * -4.0), a, (b * b))) - b)) * c;
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * fma(a, (c / b), -b)) / (2.0 * a);
} else {
tmp_1 = (2.0 * c) / (-b + -b);
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -2.9e+100) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(0.5 / a) * Float64(-2.0 * b)); else tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - b)); end tmp_1 = tmp_2; elseif (b <= 5e+64) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(Float64(sqrt(fma(-4.0, Float64(c * a), Float64(b * b))) + b) / a) * -0.5); else tmp_3 = Float64(Float64(2.0 / Float64(sqrt(fma(Float64(c * -4.0), a, Float64(b * b))) - b)) * c); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * fma(a, Float64(c / b), Float64(-b))) / Float64(2.0 * a)); else tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) + Float64(-b))); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -2.9e+100], If[GreaterEqual[b, 0.0], N[(N[(0.5 / a), $MachinePrecision] * N[(-2.0 * b), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 5e+64], If[GreaterEqual[b, 0.0], N[(N[(N[(N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + b), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision], N[(N[(2.0 / N[(N[Sqrt[N[(N[(c * -4.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + (-b)), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.9 \cdot 10^{+100}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(-2 \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\end{array}\\
\mathbf{elif}\;b \leq 5 \cdot 10^{+64}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} + b}{a} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\sqrt{\mathsf{fma}\left(c \cdot -4, a, b \cdot b\right)} - b} \cdot c\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \left(-b\right)}\\
\end{array}
\end{array}
if b < -2.9e100Initial program 54.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f6454.4
Applied rewrites54.4%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6496.2
Applied rewrites96.2%
Taylor expanded in a around 0
lower-*.f6496.2
Applied rewrites96.2%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6496.2
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
Applied rewrites96.2%
if -2.9e100 < b < 5e64Initial program 93.3%
Taylor expanded in a around 0
Applied rewrites93.3%
Applied rewrites93.2%
if 5e64 < b Initial program 48.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f6494.2
Applied rewrites94.2%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6494.2
Applied rewrites94.2%
Taylor expanded in a around 0
distribute-lft-out--N/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6494.2
Applied rewrites94.2%
(FPCore (a b c)
:precision binary64
(if (<= b -3e+100)
(if (>= b 0.0) (* (/ 0.5 a) (* -2.0 b)) (/ (* 2.0 c) (- (- b) b)))
(if (<= b 5.2e+64)
(if (>= b 0.0)
(* (+ (sqrt (fma (* c -4.0) a (* b b))) b) (/ -0.5 a))
(/ (* 2.0 c) (- (sqrt (fma -4.0 (* c a) (* b b))) b)))
(if (>= b 0.0)
(/ (* 2.0 (fma a (/ c b) (- b))) (* 2.0 a))
(/ (* 2.0 c) (+ (- b) (- b)))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -3e+100) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (0.5 / a) * (-2.0 * b);
} else {
tmp_2 = (2.0 * c) / (-b - b);
}
tmp_1 = tmp_2;
} else if (b <= 5.2e+64) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (sqrt(fma((c * -4.0), a, (b * b))) + b) * (-0.5 / a);
} else {
tmp_3 = (2.0 * c) / (sqrt(fma(-4.0, (c * a), (b * b))) - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * fma(a, (c / b), -b)) / (2.0 * a);
} else {
tmp_1 = (2.0 * c) / (-b + -b);
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -3e+100) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(0.5 / a) * Float64(-2.0 * b)); else tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - b)); end tmp_1 = tmp_2; elseif (b <= 5.2e+64) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(sqrt(fma(Float64(c * -4.0), a, Float64(b * b))) + b) * Float64(-0.5 / a)); else tmp_3 = Float64(Float64(2.0 * c) / Float64(sqrt(fma(-4.0, Float64(c * a), Float64(b * b))) - b)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * fma(a, Float64(c / b), Float64(-b))) / Float64(2.0 * a)); else tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) + Float64(-b))); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -3e+100], If[GreaterEqual[b, 0.0], N[(N[(0.5 / a), $MachinePrecision] * N[(-2.0 * b), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 5.2e+64], If[GreaterEqual[b, 0.0], N[(N[(N[Sqrt[N[(N[(c * -4.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + b), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + (-b)), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3 \cdot 10^{+100}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(-2 \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\end{array}\\
\mathbf{elif}\;b \leq 5.2 \cdot 10^{+64}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\left(\sqrt{\mathsf{fma}\left(c \cdot -4, a, b \cdot b\right)} + b\right) \cdot \frac{-0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \left(-b\right)}\\
\end{array}
\end{array}
if b < -2.99999999999999985e100Initial program 54.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f6454.4
Applied rewrites54.4%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6496.2
Applied rewrites96.2%
Taylor expanded in a around 0
lower-*.f6496.2
Applied rewrites96.2%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6496.2
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
Applied rewrites96.2%
if -2.99999999999999985e100 < b < 5.19999999999999994e64Initial program 93.3%
Taylor expanded in a around 0
Applied rewrites93.3%
Applied rewrites93.2%
if 5.19999999999999994e64 < b Initial program 48.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f6494.2
Applied rewrites94.2%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6494.2
Applied rewrites94.2%
Taylor expanded in a around 0
distribute-lft-out--N/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6494.2
Applied rewrites94.2%
(FPCore (a b c)
:precision binary64
(if (<= b -3.8e-103)
(if (>= b 0.0) (* (/ 0.5 a) (* -2.0 b)) (/ (* 2.0 c) (- (- b) b)))
(if (>= b 0.0)
(/ (- (- b) (fma (* -2.0 a) (/ c b) b)) (* 2.0 a))
(/ (* 2.0 c) (+ (- b) (sqrt (* -4.0 (* c a))))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -3.8e-103) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (0.5 / a) * (-2.0 * b);
} else {
tmp_2 = (2.0 * c) / (-b - b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (-b - fma((-2.0 * a), (c / b), b)) / (2.0 * a);
} else {
tmp_1 = (2.0 * c) / (-b + sqrt((-4.0 * (c * a))));
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -3.8e-103) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(0.5 / a) * Float64(-2.0 * b)); else tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - b)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) - fma(Float64(-2.0 * a), Float64(c / b), b)) / Float64(2.0 * a)); else tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) + sqrt(Float64(-4.0 * Float64(c * a))))); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -3.8e-103], If[GreaterEqual[b, 0.0], N[(N[(0.5 / a), $MachinePrecision] * N[(-2.0 * b), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[((-b) - N[(N[(-2.0 * a), $MachinePrecision] * N[(c / b), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.8 \cdot 10^{-103}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(-2 \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \mathsf{fma}\left(-2 \cdot a, \frac{c}{b}, b\right)}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{-4 \cdot \left(c \cdot a\right)}}\\
\end{array}
\end{array}
if b < -3.8000000000000001e-103Initial program 76.1%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f6476.1
Applied rewrites76.1%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6485.8
Applied rewrites85.8%
Taylor expanded in a around 0
lower-*.f6485.8
Applied rewrites85.8%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6485.8
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
Applied rewrites85.8%
if -3.8000000000000001e-103 < b Initial program 74.2%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f6472.4
Applied rewrites72.4%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6470.9
Applied rewrites70.9%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* -2.0 b) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-2.0 * b) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + -b);
}
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) :: tmp
if (b >= 0.0d0) then
tmp = ((-2.0d0) * b) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (-b + -b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-2.0 * b) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + -b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (-2.0 * b) / (2.0 * a) else: tmp = (2.0 * c) / (-b + -b) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(-2.0 * b) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + Float64(-b))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (-2.0 * b) / (2.0 * a); else tmp = (2.0 * c) / (-b + -b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(-2.0 * b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + (-b)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-2 \cdot b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \left(-b\right)}\\
\end{array}
\end{array}
Initial program 74.9%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f6473.8
Applied rewrites73.8%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6468.7
Applied rewrites68.7%
Taylor expanded in a around 0
lower-*.f6468.5
Applied rewrites68.5%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* -2.0 b) (* 2.0 a)) (* c (/ 2.0 (- (- b) b)))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-2.0 * b) / (2.0 * a);
} else {
tmp = c * (2.0 / (-b - b));
}
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) :: tmp
if (b >= 0.0d0) then
tmp = ((-2.0d0) * b) / (2.0d0 * a)
else
tmp = c * (2.0d0 / (-b - b))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-2.0 * b) / (2.0 * a);
} else {
tmp = c * (2.0 / (-b - b));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (-2.0 * b) / (2.0 * a) else: tmp = c * (2.0 / (-b - b)) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(-2.0 * b) / Float64(2.0 * a)); else tmp = Float64(c * Float64(2.0 / Float64(Float64(-b) - b))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (-2.0 * b) / (2.0 * a); else tmp = c * (2.0 / (-b - b)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(-2.0 * b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(c * N[(2.0 / N[((-b) - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-2 \cdot b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - b}\\
\end{array}
\end{array}
Initial program 74.9%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f6473.8
Applied rewrites73.8%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6468.7
Applied rewrites68.7%
Taylor expanded in a around 0
lower-*.f6468.5
Applied rewrites68.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6468.5
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6468.5
Applied rewrites68.5%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* (/ 0.5 a) (* -2.0 b)) (/ (* 2.0 c) (- (- b) b))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (0.5 / a) * (-2.0 * b);
} else {
tmp = (2.0 * c) / (-b - b);
}
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) :: tmp
if (b >= 0.0d0) then
tmp = (0.5d0 / a) * ((-2.0d0) * b)
else
tmp = (2.0d0 * c) / (-b - b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (0.5 / a) * (-2.0 * b);
} else {
tmp = (2.0 * c) / (-b - b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (0.5 / a) * (-2.0 * b) else: tmp = (2.0 * c) / (-b - b) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(0.5 / a) * Float64(-2.0 * b)); else tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (0.5 / a) * (-2.0 * b); else tmp = (2.0 * c) / (-b - b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(0.5 / a), $MachinePrecision] * N[(-2.0 * b), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(-2 \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\end{array}
\end{array}
Initial program 74.9%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f6473.8
Applied rewrites73.8%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6468.7
Applied rewrites68.7%
Taylor expanded in a around 0
lower-*.f6468.5
Applied rewrites68.5%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6468.5
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
Applied rewrites68.5%
herbie shell --seed 2024342
(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)))))))