
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -4e+90)
(/ (- b) (* 1.5 a))
(if (<= b 7.6e-124)
(/ (- (sqrt (fma (* -3.0 a) c (* b b))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e+90) {
tmp = -b / (1.5 * a);
} else if (b <= 7.6e-124) {
tmp = (sqrt(fma((-3.0 * a), c, (b * b))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4e+90) tmp = Float64(Float64(-b) / Float64(1.5 * a)); elseif (b <= 7.6e-124) tmp = Float64(Float64(sqrt(fma(Float64(-3.0 * a), c, Float64(b * b))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4e+90], N[((-b) / N[(1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e-124], N[(N[(N[Sqrt[N[(N[(-3.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{+90}:\\
\;\;\;\;\frac{-b}{1.5 \cdot a}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-124}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.99999999999999987e90Initial program 57.7%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6496.5
Applied rewrites96.5%
Applied rewrites96.6%
Applied rewrites96.8%
if -3.99999999999999987e90 < b < 7.60000000000000025e-124Initial program 73.4%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval73.4
Applied rewrites73.4%
if 7.60000000000000025e-124 < b Initial program 17.4%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6487.9
Applied rewrites87.9%
Final simplification85.7%
(FPCore (a b c)
:precision binary64
(if (<= b -4e+90)
(/ (- b) (* 1.5 a))
(if (<= b 7.6e-124)
(/ (- (sqrt (fma (* -3.0 c) a (* b b))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e+90) {
tmp = -b / (1.5 * a);
} else if (b <= 7.6e-124) {
tmp = (sqrt(fma((-3.0 * c), a, (b * b))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4e+90) tmp = Float64(Float64(-b) / Float64(1.5 * a)); elseif (b <= 7.6e-124) tmp = Float64(Float64(sqrt(fma(Float64(-3.0 * c), a, Float64(b * b))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4e+90], N[((-b) / N[(1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e-124], N[(N[(N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{+90}:\\
\;\;\;\;\frac{-b}{1.5 \cdot a}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-124}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.99999999999999987e90Initial program 57.7%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6496.5
Applied rewrites96.5%
Applied rewrites96.6%
Applied rewrites96.8%
if -3.99999999999999987e90 < b < 7.60000000000000025e-124Initial program 73.4%
Applied rewrites73.3%
if 7.60000000000000025e-124 < b Initial program 17.4%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6487.9
Applied rewrites87.9%
Final simplification85.6%
(FPCore (a b c)
:precision binary64
(if (<= b -9.3e+83)
(/ (- b) (* 1.5 a))
(if (<= b 7.6e-124)
(* 0.3333333333333333 (/ (- (sqrt (fma (* c a) -3.0 (* b b))) b) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.3e+83) {
tmp = -b / (1.5 * a);
} else if (b <= 7.6e-124) {
tmp = 0.3333333333333333 * ((sqrt(fma((c * a), -3.0, (b * b))) - b) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -9.3e+83) tmp = Float64(Float64(-b) / Float64(1.5 * a)); elseif (b <= 7.6e-124) tmp = Float64(0.3333333333333333 * Float64(Float64(sqrt(fma(Float64(c * a), -3.0, Float64(b * b))) - b) / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -9.3e+83], N[((-b) / N[(1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e-124], N[(0.3333333333333333 * N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -3.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.3 \cdot 10^{+83}:\\
\;\;\;\;\frac{-b}{1.5 \cdot a}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-124}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{\mathsf{fma}\left(c \cdot a, -3, b \cdot b\right)} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -9.3000000000000003e83Initial program 59.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6496.6
Applied rewrites96.6%
Applied rewrites96.6%
Applied rewrites96.9%
if -9.3000000000000003e83 < b < 7.60000000000000025e-124Initial program 72.7%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval72.7
Applied rewrites72.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
Applied rewrites72.6%
if 7.60000000000000025e-124 < b Initial program 17.4%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6487.9
Applied rewrites87.9%
Final simplification85.6%
(FPCore (a b c)
:precision binary64
(if (<= b -9.3e+83)
(/ (- b) (* 1.5 a))
(if (<= b 7.6e-124)
(* (/ 0.3333333333333333 a) (- (sqrt (fma (* c a) -3.0 (* b b))) b))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.3e+83) {
tmp = -b / (1.5 * a);
} else if (b <= 7.6e-124) {
tmp = (0.3333333333333333 / a) * (sqrt(fma((c * a), -3.0, (b * b))) - b);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -9.3e+83) tmp = Float64(Float64(-b) / Float64(1.5 * a)); elseif (b <= 7.6e-124) tmp = Float64(Float64(0.3333333333333333 / a) * Float64(sqrt(fma(Float64(c * a), -3.0, Float64(b * b))) - b)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -9.3e+83], N[((-b) / N[(1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e-124], N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -3.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.3 \cdot 10^{+83}:\\
\;\;\;\;\frac{-b}{1.5 \cdot a}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-124}:\\
\;\;\;\;\frac{0.3333333333333333}{a} \cdot \left(\sqrt{\mathsf{fma}\left(c \cdot a, -3, b \cdot b\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -9.3000000000000003e83Initial program 59.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6496.6
Applied rewrites96.6%
Applied rewrites96.6%
Applied rewrites96.9%
if -9.3000000000000003e83 < b < 7.60000000000000025e-124Initial program 72.7%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval72.7
Applied rewrites72.7%
lift-/.f64N/A
div-invN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f6472.6
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
Applied rewrites72.6%
if 7.60000000000000025e-124 < b Initial program 17.4%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6487.9
Applied rewrites87.9%
Final simplification85.6%
(FPCore (a b c)
:precision binary64
(if (<= b -9.3e+83)
(/ (- b) (* 1.5 a))
(if (<= b 7.6e-124)
(* (/ 0.3333333333333333 a) (- (sqrt (fma (* -3.0 c) a (* b b))) b))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.3e+83) {
tmp = -b / (1.5 * a);
} else if (b <= 7.6e-124) {
tmp = (0.3333333333333333 / a) * (sqrt(fma((-3.0 * c), a, (b * b))) - b);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -9.3e+83) tmp = Float64(Float64(-b) / Float64(1.5 * a)); elseif (b <= 7.6e-124) tmp = Float64(Float64(0.3333333333333333 / a) * Float64(sqrt(fma(Float64(-3.0 * c), a, Float64(b * b))) - b)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -9.3e+83], N[((-b) / N[(1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e-124], N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.3 \cdot 10^{+83}:\\
\;\;\;\;\frac{-b}{1.5 \cdot a}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-124}:\\
\;\;\;\;\frac{0.3333333333333333}{a} \cdot \left(\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -9.3000000000000003e83Initial program 59.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6496.6
Applied rewrites96.6%
Applied rewrites96.6%
Applied rewrites96.9%
if -9.3000000000000003e83 < b < 7.60000000000000025e-124Initial program 72.7%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval72.6
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6472.6
Applied rewrites72.5%
if 7.60000000000000025e-124 < b Initial program 17.4%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6487.9
Applied rewrites87.9%
Final simplification85.6%
(FPCore (a b c)
:precision binary64
(if (<= b -2.9e-58)
(/ (- b) (* 1.5 a))
(if (<= b 7.6e-124)
(/ (- (sqrt (* (* c a) -3.0)) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.9e-58) {
tmp = -b / (1.5 * a);
} else if (b <= 7.6e-124) {
tmp = (sqrt(((c * a) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
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 <= (-2.9d-58)) then
tmp = -b / (1.5d0 * a)
else if (b <= 7.6d-124) then
tmp = (sqrt(((c * a) * (-3.0d0))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.9e-58) {
tmp = -b / (1.5 * a);
} else if (b <= 7.6e-124) {
tmp = (Math.sqrt(((c * a) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.9e-58: tmp = -b / (1.5 * a) elif b <= 7.6e-124: tmp = (math.sqrt(((c * a) * -3.0)) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.9e-58) tmp = Float64(Float64(-b) / Float64(1.5 * a)); elseif (b <= 7.6e-124) tmp = Float64(Float64(sqrt(Float64(Float64(c * a) * -3.0)) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.9e-58) tmp = -b / (1.5 * a); elseif (b <= 7.6e-124) tmp = (sqrt(((c * a) * -3.0)) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.9e-58], N[((-b) / N[(1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e-124], N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.9 \cdot 10^{-58}:\\
\;\;\;\;\frac{-b}{1.5 \cdot a}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-124}:\\
\;\;\;\;\frac{\sqrt{\left(c \cdot a\right) \cdot -3} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.8999999999999999e-58Initial program 64.3%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6488.2
Applied rewrites88.2%
Applied rewrites88.2%
Applied rewrites88.4%
if -2.8999999999999999e-58 < b < 7.60000000000000025e-124Initial program 69.4%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6465.1
Applied rewrites65.1%
if 7.60000000000000025e-124 < b Initial program 17.4%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6487.9
Applied rewrites87.9%
Final simplification82.9%
(FPCore (a b c)
:precision binary64
(if (<= b -2.9e-58)
(/ (- b) (* 1.5 a))
(if (<= b 7.6e-124)
(* (/ (- (sqrt (* (* c a) -3.0)) b) a) 0.3333333333333333)
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.9e-58) {
tmp = -b / (1.5 * a);
} else if (b <= 7.6e-124) {
tmp = ((sqrt(((c * a) * -3.0)) - b) / a) * 0.3333333333333333;
} else {
tmp = (c / b) * -0.5;
}
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 <= (-2.9d-58)) then
tmp = -b / (1.5d0 * a)
else if (b <= 7.6d-124) then
tmp = ((sqrt(((c * a) * (-3.0d0))) - b) / a) * 0.3333333333333333d0
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.9e-58) {
tmp = -b / (1.5 * a);
} else if (b <= 7.6e-124) {
tmp = ((Math.sqrt(((c * a) * -3.0)) - b) / a) * 0.3333333333333333;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.9e-58: tmp = -b / (1.5 * a) elif b <= 7.6e-124: tmp = ((math.sqrt(((c * a) * -3.0)) - b) / a) * 0.3333333333333333 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.9e-58) tmp = Float64(Float64(-b) / Float64(1.5 * a)); elseif (b <= 7.6e-124) tmp = Float64(Float64(Float64(sqrt(Float64(Float64(c * a) * -3.0)) - b) / a) * 0.3333333333333333); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.9e-58) tmp = -b / (1.5 * a); elseif (b <= 7.6e-124) tmp = ((sqrt(((c * a) * -3.0)) - b) / a) * 0.3333333333333333; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.9e-58], N[((-b) / N[(1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e-124], N[(N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.9 \cdot 10^{-58}:\\
\;\;\;\;\frac{-b}{1.5 \cdot a}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-124}:\\
\;\;\;\;\frac{\sqrt{\left(c \cdot a\right) \cdot -3} - b}{a} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.8999999999999999e-58Initial program 64.3%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6488.2
Applied rewrites88.2%
Applied rewrites88.2%
Applied rewrites88.4%
if -2.8999999999999999e-58 < b < 7.60000000000000025e-124Initial program 69.4%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval69.4
Applied rewrites69.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
Applied rewrites69.2%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6465.1
Applied rewrites65.1%
if 7.60000000000000025e-124 < b Initial program 17.4%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6487.9
Applied rewrites87.9%
Final simplification82.9%
(FPCore (a b c) :precision binary64 (if (<= b 1.04e-240) (/ (- b) (* 1.5 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.04e-240) {
tmp = -b / (1.5 * a);
} else {
tmp = (c / b) * -0.5;
}
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 <= 1.04d-240) then
tmp = -b / (1.5d0 * a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.04e-240) {
tmp = -b / (1.5 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.04e-240: tmp = -b / (1.5 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.04e-240) tmp = Float64(Float64(-b) / Float64(1.5 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.04e-240) tmp = -b / (1.5 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.04e-240], N[((-b) / N[(1.5 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.04 \cdot 10^{-240}:\\
\;\;\;\;\frac{-b}{1.5 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.04e-240Initial program 67.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6467.7
Applied rewrites67.7%
Applied rewrites67.7%
Applied rewrites67.9%
if 1.04e-240 < b Initial program 23.3%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6478.3
Applied rewrites78.3%
Final simplification73.3%
(FPCore (a b c) :precision binary64 (if (<= b 1.04e-240) (/ (* -0.6666666666666666 b) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.04e-240) {
tmp = (-0.6666666666666666 * b) / a;
} else {
tmp = (c / b) * -0.5;
}
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 <= 1.04d-240) then
tmp = ((-0.6666666666666666d0) * b) / a
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.04e-240) {
tmp = (-0.6666666666666666 * b) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.04e-240: tmp = (-0.6666666666666666 * b) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.04e-240) tmp = Float64(Float64(-0.6666666666666666 * b) / a); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.04e-240) tmp = (-0.6666666666666666 * b) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.04e-240], N[(N[(-0.6666666666666666 * b), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.04 \cdot 10^{-240}:\\
\;\;\;\;\frac{-0.6666666666666666 \cdot b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.04e-240Initial program 67.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6467.7
Applied rewrites67.7%
Applied rewrites67.8%
if 1.04e-240 < b Initial program 23.3%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6478.3
Applied rewrites78.3%
Final simplification73.3%
(FPCore (a b c) :precision binary64 (if (<= b 1.04e-240) (* (/ b a) -0.6666666666666666) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.04e-240) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c / b) * -0.5;
}
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 <= 1.04d-240) then
tmp = (b / a) * (-0.6666666666666666d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.04e-240) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.04e-240: tmp = (b / a) * -0.6666666666666666 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.04e-240) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.04e-240) tmp = (b / a) * -0.6666666666666666; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.04e-240], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.04 \cdot 10^{-240}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.04e-240Initial program 67.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6467.7
Applied rewrites67.7%
if 1.04e-240 < b Initial program 23.3%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6478.3
Applied rewrites78.3%
Final simplification73.3%
(FPCore (a b c) :precision binary64 (if (<= b 3e+29) (* (/ b a) -0.6666666666666666) (* 0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 3e+29) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = 0.5 * (c / 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 <= 3d+29) then
tmp = (b / a) * (-0.6666666666666666d0)
else
tmp = 0.5d0 * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 3e+29) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = 0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3e+29: tmp = (b / a) * -0.6666666666666666 else: tmp = 0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3e+29) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3e+29) tmp = (b / a) * -0.6666666666666666; else tmp = 0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3e+29], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3 \cdot 10^{+29}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.9999999999999999e29Initial program 60.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6449.8
Applied rewrites49.8%
if 2.9999999999999999e29 < b Initial program 13.0%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval13.0
Applied rewrites13.0%
Taylor expanded in b around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f642.3
Applied rewrites2.3%
Taylor expanded in a around inf
Applied rewrites28.2%
Final simplification42.5%
(FPCore (a b c) :precision binary64 (* 0.5 (/ c b)))
double code(double a, double b, double c) {
return 0.5 * (c / b);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 0.5d0 * (c / b)
end function
public static double code(double a, double b, double c) {
return 0.5 * (c / b);
}
def code(a, b, c): return 0.5 * (c / b)
function code(a, b, c) return Float64(0.5 * Float64(c / b)) end
function tmp = code(a, b, c) tmp = 0.5 * (c / b); end
code[a_, b_, c_] := N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \frac{c}{b}
\end{array}
Initial program 44.4%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval44.4
Applied rewrites44.4%
Taylor expanded in b around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6431.4
Applied rewrites31.4%
Taylor expanded in a around inf
Applied rewrites11.6%
herbie shell --seed 2024332
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))