
(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 11 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 -1.6e+174)
(/ (/ (* -2.0 b) 3.0) a)
(if (<= b 2.9e-51)
(/ (- (sqrt (fma (* a -3.0) c (* b b))) b) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.6e+174) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 2.9e-51) {
tmp = (sqrt(fma((a * -3.0), c, (b * b))) - b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.6e+174) tmp = Float64(Float64(Float64(-2.0 * b) / 3.0) / a); elseif (b <= 2.9e-51) tmp = Float64(Float64(sqrt(fma(Float64(a * -3.0), c, Float64(b * b))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.6e+174], N[(N[(N[(-2.0 * b), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 2.9e-51], 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[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+174}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{3}}{a}\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{-51}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a \cdot -3, c, b \cdot b\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.6e174Initial program 30.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites30.8%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
lower-/.f6430.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6430.8
Applied rewrites30.8%
Taylor expanded in b around -inf
lower-*.f6496.2
Applied rewrites96.2%
if -1.6e174 < b < 2.89999999999999973e-51Initial program 80.5%
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-eval80.5
Applied rewrites80.5%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-neg.f64N/A
sub-negN/A
lift--.f6480.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6480.4
Applied rewrites80.4%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
lower-*.f6480.5
Applied rewrites80.5%
if 2.89999999999999973e-51 < b Initial program 22.7%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6482.3
Applied rewrites82.3%
Final simplification84.3%
(FPCore (a b c)
:precision binary64
(if (<= b -1.6e+174)
(/ (/ (* -2.0 b) 3.0) a)
(if (<= b 2.9e-51)
(/ (- (sqrt (fma (* -3.0 c) a (* b b))) b) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.6e+174) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 2.9e-51) {
tmp = (sqrt(fma((-3.0 * c), a, (b * b))) - b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.6e+174) tmp = Float64(Float64(Float64(-2.0 * b) / 3.0) / a); elseif (b <= 2.9e-51) tmp = Float64(Float64(sqrt(fma(Float64(-3.0 * c), a, Float64(b * b))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.6e+174], N[(N[(N[(-2.0 * b), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 2.9e-51], N[(N[(N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+174}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{3}}{a}\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{-51}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.6e174Initial program 30.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites30.8%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
lower-/.f6430.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6430.8
Applied rewrites30.8%
Taylor expanded in b around -inf
lower-*.f6496.2
Applied rewrites96.2%
if -1.6e174 < b < 2.89999999999999973e-51Initial program 80.5%
Applied rewrites80.4%
if 2.89999999999999973e-51 < b Initial program 22.7%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6482.3
Applied rewrites82.3%
Final simplification84.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.6e+174)
(/ (/ (* -2.0 b) 3.0) a)
(if (<= b 2.9e-51)
(/ (* 0.3333333333333333 (- (sqrt (fma (* -3.0 c) a (* b b))) b)) a)
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.6e+174) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 2.9e-51) {
tmp = (0.3333333333333333 * (sqrt(fma((-3.0 * c), a, (b * b))) - b)) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.6e+174) tmp = Float64(Float64(Float64(-2.0 * b) / 3.0) / a); elseif (b <= 2.9e-51) tmp = Float64(Float64(0.3333333333333333 * Float64(sqrt(fma(Float64(-3.0 * c), a, Float64(b * b))) - b)) / a); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.6e+174], N[(N[(N[(-2.0 * b), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 2.9e-51], N[(N[(0.3333333333333333 * N[(N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+174}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{3}}{a}\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{-51}:\\
\;\;\;\;\frac{0.3333333333333333 \cdot \left(\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.6e174Initial program 30.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites30.8%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
lower-/.f6430.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6430.8
Applied rewrites30.8%
Taylor expanded in b around -inf
lower-*.f6496.2
Applied rewrites96.2%
if -1.6e174 < b < 2.89999999999999973e-51Initial program 80.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites80.4%
if 2.89999999999999973e-51 < b Initial program 22.7%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6482.3
Applied rewrites82.3%
Final simplification84.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1e+101)
(/ (* (/ b a) -2.0) 3.0)
(if (<= b 2.9e-51)
(* (/ 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 <= -1e+101) {
tmp = ((b / a) * -2.0) / 3.0;
} else if (b <= 2.9e-51) {
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 <= -1e+101) tmp = Float64(Float64(Float64(b / a) * -2.0) / 3.0); elseif (b <= 2.9e-51) 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, -1e+101], N[(N[(N[(b / a), $MachinePrecision] * -2.0), $MachinePrecision] / 3.0), $MachinePrecision], If[LessEqual[b, 2.9e-51], 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 -1 \cdot 10^{+101}:\\
\;\;\;\;\frac{\frac{b}{a} \cdot -2}{3}\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{-51}:\\
\;\;\;\;\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.9999999999999998e100Initial program 45.2%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites45.4%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6497.0
Applied rewrites97.0%
if -9.9999999999999998e100 < b < 2.89999999999999973e-51Initial program 78.1%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval77.9
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6477.9
Applied rewrites77.9%
if 2.89999999999999973e-51 < b Initial program 22.7%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6482.3
Applied rewrites82.3%
Final simplification84.2%
(FPCore (a b c)
:precision binary64
(if (<= b -6.6e-99)
(* (fma (/ c (* b b)) -0.5 (/ 0.6666666666666666 a)) (- b))
(if (<= b 2.9e-51)
(/ (- (sqrt (* (* a c) -3.0)) b) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.6e-99) {
tmp = fma((c / (b * b)), -0.5, (0.6666666666666666 / a)) * -b;
} else if (b <= 2.9e-51) {
tmp = (sqrt(((a * c) * -3.0)) - b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -6.6e-99) tmp = Float64(fma(Float64(c / Float64(b * b)), -0.5, Float64(0.6666666666666666 / a)) * Float64(-b)); elseif (b <= 2.9e-51) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -6.6e-99], N[(N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] * -0.5 + N[(0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision] * (-b)), $MachinePrecision], If[LessEqual[b, 2.9e-51], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.6 \cdot 10^{-99}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{b \cdot b}, -0.5, \frac{0.6666666666666666}{a}\right) \cdot \left(-b\right)\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{-51}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -6.59999999999999973e-99Initial program 64.9%
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-/.f6485.9
Applied rewrites85.9%
if -6.59999999999999973e-99 < b < 2.89999999999999973e-51Initial program 67.3%
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.3
Applied rewrites67.3%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-neg.f64N/A
sub-negN/A
lift--.f6467.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.1
Applied rewrites67.1%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6464.6
Applied rewrites64.6%
if 2.89999999999999973e-51 < b Initial program 22.7%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6482.3
Applied rewrites82.3%
Final simplification79.1%
(FPCore (a b c)
:precision binary64
(if (<= b -2.3e-104)
(/ (/ (* -2.0 b) 3.0) a)
(if (<= b 2.9e-51)
(/ (- (sqrt (* (* a c) -3.0)) b) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.3e-104) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 2.9e-51) {
tmp = (sqrt(((a * c) * -3.0)) - b) / (3.0 * 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 <= (-2.3d-104)) then
tmp = (((-2.0d0) * b) / 3.0d0) / a
else if (b <= 2.9d-51) then
tmp = (sqrt(((a * c) * (-3.0d0))) - b) / (3.0d0 * 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 <= -2.3e-104) {
tmp = ((-2.0 * b) / 3.0) / a;
} else if (b <= 2.9e-51) {
tmp = (Math.sqrt(((a * c) * -3.0)) - b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.3e-104: tmp = ((-2.0 * b) / 3.0) / a elif b <= 2.9e-51: tmp = (math.sqrt(((a * c) * -3.0)) - b) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.3e-104) tmp = Float64(Float64(Float64(-2.0 * b) / 3.0) / a); elseif (b <= 2.9e-51) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) / Float64(3.0 * 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 <= -2.3e-104) tmp = ((-2.0 * b) / 3.0) / a; elseif (b <= 2.9e-51) tmp = (sqrt(((a * c) * -3.0)) - b) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.3e-104], N[(N[(N[(-2.0 * b), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 2.9e-51], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.3 \cdot 10^{-104}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{3}}{a}\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{-51}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.2999999999999999e-104Initial program 64.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites64.5%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
lower-/.f6464.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6464.5
Applied rewrites64.5%
Taylor expanded in b around -inf
lower-*.f6485.1
Applied rewrites85.1%
if -2.2999999999999999e-104 < b < 2.89999999999999973e-51Initial program 68.3%
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-eval68.3
Applied rewrites68.3%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-neg.f64N/A
sub-negN/A
lift--.f6468.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.1
Applied rewrites68.1%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6465.5
Applied rewrites65.5%
if 2.89999999999999973e-51 < b Initial program 22.7%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6482.3
Applied rewrites82.3%
Final simplification79.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (/ (* -2.0 b) 3.0) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = ((-2.0 * b) / 3.0) / 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 <= (-5d-310)) then
tmp = (((-2.0d0) * b) / 3.0d0) / 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 <= -5e-310) {
tmp = ((-2.0 * b) / 3.0) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = ((-2.0 * b) / 3.0) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(Float64(-2.0 * b) / 3.0) / 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 <= -5e-310) tmp = ((-2.0 * b) / 3.0) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(N[(-2.0 * b), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{3}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 65.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites66.0%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
lower-/.f6466.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.0
Applied rewrites66.0%
Taylor expanded in b around -inf
lower-*.f6472.5
Applied rewrites72.5%
if -4.999999999999985e-310 < b Initial program 38.3%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6462.5
Applied rewrites62.5%
Final simplification67.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (* (/ b a) -2.0) 3.0) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = ((b / a) * -2.0) / 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 <= (-5d-310)) then
tmp = ((b / a) * (-2.0d0)) / 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 <= -5e-310) {
tmp = ((b / a) * -2.0) / 3.0;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = ((b / a) * -2.0) / 3.0 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(Float64(b / a) * -2.0) / 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 <= -5e-310) tmp = ((b / a) * -2.0) / 3.0; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(N[(b / a), $MachinePrecision] * -2.0), $MachinePrecision] / 3.0), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\frac{b}{a} \cdot -2}{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 65.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites66.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6472.5
Applied rewrites72.5%
if -4.999999999999985e-310 < b Initial program 38.3%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6462.5
Applied rewrites62.5%
Final simplification67.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ b (* -1.5 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
tmp = b / (-1.5 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b / (-1.5 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = 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 <= -5e-310) tmp = b / (-1.5 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], 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 -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{-1.5 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 65.9%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6472.4
Applied rewrites72.4%
Applied rewrites72.3%
Applied rewrites72.3%
Applied rewrites72.4%
if -4.999999999999985e-310 < b Initial program 38.3%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6462.5
Applied rewrites62.5%
Final simplification67.6%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* -0.6666666666666666 (/ b a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(-0.6666666666666666 * Float64(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 <= -5e-310) tmp = -0.6666666666666666 * (b / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 65.9%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6472.4
Applied rewrites72.4%
if -4.999999999999985e-310 < b Initial program 38.3%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6462.5
Applied rewrites62.5%
Final simplification67.6%
(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 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6438.7
Applied rewrites38.7%
herbie shell --seed 2024312
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))