
(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 -2.05e+139)
(/ (/ b -1.5) a)
(if (<= b 6e-85)
(/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.05e+139) {
tmp = (b / -1.5) / a;
} else if (b <= 6e-85) {
tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} 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 <= (-2.05d+139)) then
tmp = (b / (-1.5d0)) / a
else if (b <= 6d-85) then
tmp = (sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (3.0d0 * a)
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 <= -2.05e+139) {
tmp = (b / -1.5) / a;
} else if (b <= 6e-85) {
tmp = (Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.05e+139: tmp = (b / -1.5) / a elif b <= 6e-85: tmp = (math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.05e+139) tmp = Float64(Float64(b / -1.5) / a); elseif (b <= 6e-85) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.05e+139) tmp = (b / -1.5) / a; elseif (b <= 6e-85) tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.05e+139], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 6e-85], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.05 \cdot 10^{+139}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-85}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -2.0500000000000001e139Initial program 42.4%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6497.4
Applied rewrites97.4%
Applied rewrites97.3%
Applied rewrites97.4%
Applied rewrites97.5%
if -2.0500000000000001e139 < b < 6.00000000000000044e-85Initial program 76.8%
if 6.00000000000000044e-85 < b Initial program 10.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.7
Applied rewrites95.7%
Final simplification87.2%
(FPCore (a b c)
:precision binary64
(if (<= b -2.05e+139)
(/ (/ b -1.5) a)
(if (<= b 6e-85)
(/ (- (sqrt (fma (* a -3.0) c (* b b))) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.05e+139) {
tmp = (b / -1.5) / a;
} else if (b <= 6e-85) {
tmp = (sqrt(fma((a * -3.0), c, (b * b))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.05e+139) tmp = Float64(Float64(b / -1.5) / a); elseif (b <= 6e-85) tmp = Float64(Float64(sqrt(fma(Float64(a * -3.0), c, Float64(b * b))) - b) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.05e+139], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 6e-85], N[(N[(N[Sqrt[N[(N[(a * -3.0), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.05 \cdot 10^{+139}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-85}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a \cdot -3, c, b \cdot b\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -2.0500000000000001e139Initial program 42.4%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6497.4
Applied rewrites97.4%
Applied rewrites97.3%
Applied rewrites97.4%
Applied rewrites97.5%
if -2.0500000000000001e139 < b < 6.00000000000000044e-85Initial program 76.8%
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-eval76.8
Applied rewrites76.8%
if 6.00000000000000044e-85 < b Initial program 10.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.7
Applied rewrites95.7%
Final simplification87.2%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+127)
(/ (/ b -1.5) a)
(if (<= b 6e-85)
(* 0.3333333333333333 (/ (- (sqrt (fma (* a -3.0) c (* b b))) b) a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+127) {
tmp = (b / -1.5) / a;
} else if (b <= 6e-85) {
tmp = 0.3333333333333333 * ((sqrt(fma((a * -3.0), c, (b * b))) - b) / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e+127) tmp = Float64(Float64(b / -1.5) / a); elseif (b <= 6e-85) tmp = Float64(0.3333333333333333 * Float64(Float64(sqrt(fma(Float64(a * -3.0), c, Float64(b * b))) - b) / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e+127], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 6e-85], N[(0.3333333333333333 * N[(N[(N[Sqrt[N[(N[(a * -3.0), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+127}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-85}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{\mathsf{fma}\left(a \cdot -3, c, b \cdot b\right)} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -5.0000000000000004e127Initial program 43.8%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6497.4
Applied rewrites97.4%
Applied rewrites97.4%
Applied rewrites97.5%
Applied rewrites97.6%
if -5.0000000000000004e127 < b < 6.00000000000000044e-85Initial program 76.6%
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-eval76.6
Applied rewrites76.6%
Applied rewrites76.4%
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
metadata-evalN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-*.f6476.4
Applied rewrites76.4%
if 6.00000000000000044e-85 < b Initial program 10.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.7
Applied rewrites95.7%
Final simplification87.1%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+127)
(/ (/ b -1.5) a)
(if (<= b 6e-85)
(* (- (sqrt (fma (* a c) -3.0 (* b b))) b) (/ 0.3333333333333333 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+127) {
tmp = (b / -1.5) / a;
} else if (b <= 6e-85) {
tmp = (sqrt(fma((a * c), -3.0, (b * b))) - b) * (0.3333333333333333 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e+127) tmp = Float64(Float64(b / -1.5) / a); elseif (b <= 6e-85) tmp = Float64(Float64(sqrt(fma(Float64(a * c), -3.0, Float64(b * b))) - b) * Float64(0.3333333333333333 / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e+127], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 6e-85], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+127}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-85}:\\
\;\;\;\;\left(\sqrt{\mathsf{fma}\left(a \cdot c, -3, b \cdot b\right)} - b\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -5.0000000000000004e127Initial program 43.8%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6497.4
Applied rewrites97.4%
Applied rewrites97.4%
Applied rewrites97.5%
Applied rewrites97.6%
if -5.0000000000000004e127 < b < 6.00000000000000044e-85Initial program 76.6%
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-eval76.6
Applied rewrites76.6%
Applied rewrites76.3%
if 6.00000000000000044e-85 < b Initial program 10.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.7
Applied rewrites95.7%
Final simplification87.1%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+127)
(/ (/ b -1.5) a)
(if (<= b 6e-85)
(* (- (sqrt (fma (* c -3.0) a (* b b))) b) (/ 0.3333333333333333 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+127) {
tmp = (b / -1.5) / a;
} else if (b <= 6e-85) {
tmp = (sqrt(fma((c * -3.0), a, (b * b))) - b) * (0.3333333333333333 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e+127) tmp = Float64(Float64(b / -1.5) / a); elseif (b <= 6e-85) tmp = Float64(Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) - b) * Float64(0.3333333333333333 / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e+127], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 6e-85], N[(N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+127}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-85}:\\
\;\;\;\;\left(\sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)} - b\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -5.0000000000000004e127Initial program 43.8%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6497.4
Applied rewrites97.4%
Applied rewrites97.4%
Applied rewrites97.5%
Applied rewrites97.6%
if -5.0000000000000004e127 < b < 6.00000000000000044e-85Initial program 76.6%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval76.4
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6476.4
Applied rewrites76.3%
if 6.00000000000000044e-85 < b Initial program 10.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.7
Applied rewrites95.7%
Final simplification87.0%
(FPCore (a b c)
:precision binary64
(if (<= b -4.8e-109)
(fma (/ b a) -0.6666666666666666 (* (/ 0.5 b) c))
(if (<= b 1.95e-85)
(/ (- (sqrt (* (* a c) -3.0)) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.8e-109) {
tmp = fma((b / a), -0.6666666666666666, ((0.5 / b) * c));
} else if (b <= 1.95e-85) {
tmp = (sqrt(((a * c) * -3.0)) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4.8e-109) tmp = fma(Float64(b / a), -0.6666666666666666, Float64(Float64(0.5 / b) * c)); elseif (b <= 1.95e-85) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4.8e-109], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666 + N[(N[(0.5 / b), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.95e-85], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.8 \cdot 10^{-109}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -0.6666666666666666, \frac{0.5}{b} \cdot c\right)\\
\mathbf{elif}\;b \leq 1.95 \cdot 10^{-85}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.79999999999999977e-109Initial program 68.5%
Applied rewrites51.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
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6484.8
Applied rewrites84.8%
Taylor expanded in c around 0
Applied rewrites84.9%
if -4.79999999999999977e-109 < b < 1.94999999999999994e-85Initial program 67.7%
Taylor expanded in c around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6465.3
Applied rewrites65.3%
if 1.94999999999999994e-85 < b Initial program 10.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.7
Applied rewrites95.7%
Final simplification83.6%
(FPCore (a b c)
:precision binary64
(if (<= b -4.8e-109)
(fma (/ b a) -0.6666666666666666 (* (/ 0.5 b) c))
(if (<= b 1.95e-85)
(* (/ (- (sqrt (* (* a c) -3.0)) b) a) 0.3333333333333333)
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.8e-109) {
tmp = fma((b / a), -0.6666666666666666, ((0.5 / b) * c));
} else if (b <= 1.95e-85) {
tmp = ((sqrt(((a * c) * -3.0)) - b) / a) * 0.3333333333333333;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4.8e-109) tmp = fma(Float64(b / a), -0.6666666666666666, Float64(Float64(0.5 / b) * c)); elseif (b <= 1.95e-85) tmp = Float64(Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) / a) * 0.3333333333333333); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4.8e-109], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666 + N[(N[(0.5 / b), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.95e-85], N[(N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.8 \cdot 10^{-109}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -0.6666666666666666, \frac{0.5}{b} \cdot c\right)\\
\mathbf{elif}\;b \leq 1.95 \cdot 10^{-85}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{a} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.79999999999999977e-109Initial program 68.5%
Applied rewrites51.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
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6484.8
Applied rewrites84.8%
Taylor expanded in c around 0
Applied rewrites84.9%
if -4.79999999999999977e-109 < b < 1.94999999999999994e-85Initial program 67.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-eval67.7
Applied rewrites67.7%
Applied rewrites67.5%
Taylor expanded in c around inf
lower-*.f64N/A
lower-*.f6465.1
Applied rewrites65.1%
if 1.94999999999999994e-85 < b Initial program 10.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.7
Applied rewrites95.7%
Final simplification83.6%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (fma (/ b a) -0.6666666666666666 (* (/ 0.5 b) c)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = fma((b / a), -0.6666666666666666, ((0.5 / b) * c));
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) tmp = fma(Float64(b / a), -0.6666666666666666, Float64(Float64(0.5 / b) * c)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666 + N[(N[(0.5 / b), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -0.6666666666666666, \frac{0.5}{b} \cdot c\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 68.6%
Applied rewrites55.5%
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
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6465.6
Applied rewrites65.6%
Taylor expanded in c around 0
Applied rewrites65.8%
if -9.999999999999969e-311 < b Initial program 26.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6473.8
Applied rewrites73.8%
Final simplification70.0%
(FPCore (a b c) :precision binary64 (if (<= b 2.4e-308) (/ (/ b -1.5) a) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.4e-308) {
tmp = (b / -1.5) / a;
} 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 <= 2.4d-308) then
tmp = (b / (-1.5d0)) / a
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 <= 2.4e-308) {
tmp = (b / -1.5) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.4e-308: tmp = (b / -1.5) / a else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.4e-308) tmp = Float64(Float64(b / -1.5) / a); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.4e-308) tmp = (b / -1.5) / a; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.4e-308], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.4 \cdot 10^{-308}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.40000000000000008e-308Initial program 68.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6465.5
Applied rewrites65.5%
Applied rewrites65.5%
Applied rewrites65.5%
Applied rewrites65.6%
if 2.40000000000000008e-308 < b Initial program 26.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6473.8
Applied rewrites73.8%
Final simplification69.9%
(FPCore (a b c) :precision binary64 (if (<= b 2.4e-308) (/ (- b) (* 1.5 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.4e-308) {
tmp = -b / (1.5 * a);
} 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 <= 2.4d-308) then
tmp = -b / (1.5d0 * a)
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 <= 2.4e-308) {
tmp = -b / (1.5 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.4e-308: tmp = -b / (1.5 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.4e-308) tmp = Float64(Float64(-b) / Float64(1.5 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.4e-308) tmp = -b / (1.5 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.4e-308], N[((-b) / N[(1.5 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.4 \cdot 10^{-308}:\\
\;\;\;\;\frac{-b}{1.5 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.40000000000000008e-308Initial program 68.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6465.5
Applied rewrites65.5%
Applied rewrites65.5%
Applied rewrites65.6%
if 2.40000000000000008e-308 < b Initial program 26.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6473.8
Applied rewrites73.8%
Final simplification69.9%
(FPCore (a b c) :precision binary64 (if (<= b 2.4e-308) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.4e-308) {
tmp = -0.6666666666666666 * (b / a);
} 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 <= 2.4d-308) then
tmp = (-0.6666666666666666d0) * (b / a)
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 <= 2.4e-308) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.4e-308: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.4e-308) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.4e-308) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.4e-308], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.4 \cdot 10^{-308}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.40000000000000008e-308Initial program 68.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6465.5
Applied rewrites65.5%
if 2.40000000000000008e-308 < b Initial program 26.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6473.8
Applied rewrites73.8%
Final simplification69.9%
(FPCore (a b c) :precision binary64 (* -0.6666666666666666 (/ b a)))
double code(double a, double b, double c) {
return -0.6666666666666666 * (b / a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-0.6666666666666666d0) * (b / a)
end function
public static double code(double a, double b, double c) {
return -0.6666666666666666 * (b / a);
}
def code(a, b, c): return -0.6666666666666666 * (b / a)
function code(a, b, c) return Float64(-0.6666666666666666 * Float64(b / a)) end
function tmp = code(a, b, c) tmp = -0.6666666666666666 * (b / a); end
code[a_, b_, c_] := N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.6666666666666666 \cdot \frac{b}{a}
\end{array}
Initial program 46.4%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6432.3
Applied rewrites32.3%
herbie shell --seed 2024242
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))