
(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 10 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 -7e+152)
(/ 1.0 (/ -3.0 (/ (* b 2.0) a)))
(if (<= b 5.4e-109)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7e+152) {
tmp = 1.0 / (-3.0 / ((b * 2.0) / a));
} else if (b <= 5.4e-109) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / 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 <= (-7d+152)) then
tmp = 1.0d0 / ((-3.0d0) / ((b * 2.0d0) / a))
else if (b <= 5.4d-109) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -7e+152) {
tmp = 1.0 / (-3.0 / ((b * 2.0) / a));
} else if (b <= 5.4e-109) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7e+152: tmp = 1.0 / (-3.0 / ((b * 2.0) / a)) elif b <= 5.4e-109: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7e+152) tmp = Float64(1.0 / Float64(-3.0 / Float64(Float64(b * 2.0) / a))); elseif (b <= 5.4e-109) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -7e+152) tmp = 1.0 / (-3.0 / ((b * 2.0) / a)); elseif (b <= 5.4e-109) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7e+152], N[(1.0 / N[(-3.0 / N[(N[(b * 2.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.4e-109], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7 \cdot 10^{+152}:\\
\;\;\;\;\frac{1}{\frac{-3}{\frac{b \cdot 2}{a}}}\\
\mathbf{elif}\;b \leq 5.4 \cdot 10^{-109}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -6.99999999999999963e152Initial program 43.4%
sqr-neg43.4%
sqr-neg43.4%
associate-*l*43.4%
Simplified43.4%
Applied egg-rr48.0%
Taylor expanded in b around -inf 97.6%
*-commutative97.6%
Simplified97.6%
associate-*l/97.6%
clear-num97.6%
un-div-inv97.7%
Applied egg-rr97.7%
if -6.99999999999999963e152 < b < 5.4000000000000001e-109Initial program 85.2%
if 5.4000000000000001e-109 < b Initial program 22.7%
sqr-neg22.7%
sqr-neg22.7%
associate-*l*22.7%
Simplified22.7%
Taylor expanded in b around inf 69.1%
*-commutative69.1%
associate-/l*73.4%
associate-*r*73.4%
*-commutative73.4%
associate-*r/73.3%
Simplified73.3%
Taylor expanded in a around 0 83.3%
associate-*r/83.3%
*-commutative83.3%
Simplified83.3%
Final simplification86.7%
(FPCore (a b c)
:precision binary64
(if (<= b -3.4e+150)
(/ 1.0 (/ -3.0 (/ (* b 2.0) a)))
(if (<= b 8.5e-112)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.4e+150) {
tmp = 1.0 / (-3.0 / ((b * 2.0) / a));
} else if (b <= 8.5e-112) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / 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 <= (-3.4d+150)) then
tmp = 1.0d0 / ((-3.0d0) / ((b * 2.0d0) / a))
else if (b <= 8.5d-112) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.4e+150) {
tmp = 1.0 / (-3.0 / ((b * 2.0) / a));
} else if (b <= 8.5e-112) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.4e+150: tmp = 1.0 / (-3.0 / ((b * 2.0) / a)) elif b <= 8.5e-112: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.4e+150) tmp = Float64(1.0 / Float64(-3.0 / Float64(Float64(b * 2.0) / a))); elseif (b <= 8.5e-112) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.4e+150) tmp = 1.0 / (-3.0 / ((b * 2.0) / a)); elseif (b <= 8.5e-112) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.4e+150], N[(1.0 / N[(-3.0 / N[(N[(b * 2.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.5e-112], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.4 \cdot 10^{+150}:\\
\;\;\;\;\frac{1}{\frac{-3}{\frac{b \cdot 2}{a}}}\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-112}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.39999999999999983e150Initial program 43.4%
sqr-neg43.4%
sqr-neg43.4%
associate-*l*43.4%
Simplified43.4%
Applied egg-rr48.0%
Taylor expanded in b around -inf 97.6%
*-commutative97.6%
Simplified97.6%
associate-*l/97.6%
clear-num97.6%
un-div-inv97.7%
Applied egg-rr97.7%
if -3.39999999999999983e150 < b < 8.49999999999999992e-112Initial program 85.2%
sqr-neg85.2%
sqr-neg85.2%
associate-*l*85.2%
Simplified85.2%
if 8.49999999999999992e-112 < b Initial program 22.7%
sqr-neg22.7%
sqr-neg22.7%
associate-*l*22.7%
Simplified22.7%
Taylor expanded in b around inf 69.1%
*-commutative69.1%
associate-/l*73.4%
associate-*r*73.4%
*-commutative73.4%
associate-*r/73.3%
Simplified73.3%
Taylor expanded in a around 0 83.3%
associate-*r/83.3%
*-commutative83.3%
Simplified83.3%
Final simplification86.7%
(FPCore (a b c)
:precision binary64
(if (<= b -9.2e-70)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 4.2e-109)
(/ (- (sqrt (* -3.0 (* a c))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.2e-70) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 4.2e-109) {
tmp = (sqrt((-3.0 * (a * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / 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 <= (-9.2d-70)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 4.2d-109) then
tmp = (sqrt(((-3.0d0) * (a * c))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -9.2e-70) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 4.2e-109) {
tmp = (Math.sqrt((-3.0 * (a * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9.2e-70: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 4.2e-109: tmp = (math.sqrt((-3.0 * (a * c))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9.2e-70) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 4.2e-109) tmp = Float64(Float64(sqrt(Float64(-3.0 * Float64(a * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -9.2e-70) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 4.2e-109) tmp = (sqrt((-3.0 * (a * c))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9.2e-70], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.2e-109], N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.2 \cdot 10^{-70}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 4.2 \cdot 10^{-109}:\\
\;\;\;\;\frac{\sqrt{-3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -9.20000000000000002e-70Initial program 69.2%
sqr-neg69.2%
sqr-neg69.2%
associate-*l*69.2%
Simplified69.2%
Taylor expanded in b around -inf 84.0%
mul-1-neg84.0%
*-commutative84.0%
distribute-rgt-neg-in84.0%
fma-define84.0%
associate-*r/84.1%
metadata-eval84.1%
Simplified84.1%
Taylor expanded in c around 0 84.2%
if -9.20000000000000002e-70 < b < 4.19999999999999992e-109Initial program 80.8%
sqr-neg80.8%
sqr-neg80.8%
associate-*l*80.8%
Simplified80.8%
Taylor expanded in b around 0 77.9%
if 4.19999999999999992e-109 < b Initial program 22.7%
sqr-neg22.7%
sqr-neg22.7%
associate-*l*22.7%
Simplified22.7%
Taylor expanded in b around inf 69.1%
*-commutative69.1%
associate-/l*73.4%
associate-*r*73.4%
*-commutative73.4%
associate-*r/73.3%
Simplified73.3%
Taylor expanded in a around 0 83.3%
associate-*r/83.3%
*-commutative83.3%
Simplified83.3%
Final simplification82.3%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b))) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else {
tmp = (c * -0.5) / 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 <= (-2d-310)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 73.0%
sqr-neg73.0%
sqr-neg73.0%
associate-*l*73.0%
Simplified73.0%
Taylor expanded in b around -inf 62.4%
mul-1-neg62.4%
*-commutative62.4%
distribute-rgt-neg-in62.4%
fma-define62.4%
associate-*r/62.5%
metadata-eval62.5%
Simplified62.5%
Taylor expanded in c around 0 62.7%
if -1.999999999999994e-310 < b Initial program 34.9%
sqr-neg34.9%
sqr-neg34.9%
associate-*l*34.9%
Simplified34.9%
Taylor expanded in b around inf 54.7%
*-commutative54.7%
associate-/l*58.9%
associate-*r*58.8%
*-commutative58.8%
associate-*r/58.7%
Simplified58.7%
Taylor expanded in a around 0 66.6%
associate-*r/66.6%
*-commutative66.6%
Simplified66.6%
(FPCore (a b c) :precision binary64 (if (<= b 1.5e-305) (/ b (* a -1.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.5e-305) {
tmp = b / (a * -1.5);
} else {
tmp = (c * -0.5) / 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 <= 1.5d-305) then
tmp = b / (a * (-1.5d0))
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.5e-305) {
tmp = b / (a * -1.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.5e-305: tmp = b / (a * -1.5) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.5e-305) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.5e-305) tmp = b / (a * -1.5); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.5e-305], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.5 \cdot 10^{-305}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 1.5000000000000001e-305Initial program 73.2%
sqr-neg73.2%
sqr-neg73.2%
associate-*l*73.2%
Simplified73.2%
Applied egg-rr62.8%
Taylor expanded in b around -inf 61.7%
metadata-eval61.7%
times-frac61.8%
*-lft-identity61.8%
*-commutative61.8%
Simplified61.8%
if 1.5000000000000001e-305 < b Initial program 34.4%
sqr-neg34.4%
sqr-neg34.4%
associate-*l*34.4%
Simplified34.4%
Taylor expanded in b around inf 55.1%
*-commutative55.1%
associate-/l*59.3%
associate-*r*59.3%
*-commutative59.3%
associate-*r/59.2%
Simplified59.2%
Taylor expanded in a around 0 67.1%
associate-*r/67.1%
*-commutative67.1%
Simplified67.1%
(FPCore (a b c) :precision binary64 (if (<= b 8e-306) (/ b (* a -1.5)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 8e-306) {
tmp = b / (a * -1.5);
} 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 <= 8d-306) then
tmp = b / (a * (-1.5d0))
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 <= 8e-306) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 8e-306: tmp = b / (a * -1.5) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 8e-306) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 8e-306) tmp = b / (a * -1.5); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 8e-306], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8 \cdot 10^{-306}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 8.00000000000000022e-306Initial program 73.2%
sqr-neg73.2%
sqr-neg73.2%
associate-*l*73.2%
Simplified73.2%
Applied egg-rr62.8%
Taylor expanded in b around -inf 61.7%
metadata-eval61.7%
times-frac61.8%
*-lft-identity61.8%
*-commutative61.8%
Simplified61.8%
if 8.00000000000000022e-306 < b Initial program 34.4%
sqr-neg34.4%
sqr-neg34.4%
associate-*l*34.4%
Simplified34.4%
Taylor expanded in b around inf 67.1%
*-commutative67.1%
Simplified67.1%
Final simplification64.3%
(FPCore (a b c) :precision binary64 (if (<= b 8e-306) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 8e-306) {
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 <= 8d-306) 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 <= 8e-306) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 8e-306: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 8e-306) 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 <= 8e-306) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 8e-306], 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 8 \cdot 10^{-306}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 8.00000000000000022e-306Initial program 73.2%
sqr-neg73.2%
sqr-neg73.2%
associate-*l*73.2%
Simplified73.2%
Taylor expanded in b around -inf 61.7%
*-commutative61.7%
Simplified61.7%
if 8.00000000000000022e-306 < b Initial program 34.4%
sqr-neg34.4%
sqr-neg34.4%
associate-*l*34.4%
Simplified34.4%
Taylor expanded in b around inf 67.1%
*-commutative67.1%
Simplified67.1%
Final simplification64.3%
(FPCore (a b c) :precision binary64 (if (<= b 8e-306) (* -0.6666666666666666 (/ b a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 8e-306) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = c * (-0.5 / 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 <= 8d-306) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = c * ((-0.5d0) / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 8e-306) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 8e-306: tmp = -0.6666666666666666 * (b / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 8e-306) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(c * Float64(-0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 8e-306) tmp = -0.6666666666666666 * (b / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 8e-306], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8 \cdot 10^{-306}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 8.00000000000000022e-306Initial program 73.2%
sqr-neg73.2%
sqr-neg73.2%
associate-*l*73.2%
Simplified73.2%
Taylor expanded in b around -inf 61.7%
*-commutative61.7%
Simplified61.7%
if 8.00000000000000022e-306 < b Initial program 34.4%
sqr-neg34.4%
sqr-neg34.4%
associate-*l*34.4%
Simplified34.4%
Taylor expanded in b around inf 55.1%
*-commutative55.1%
associate-/l*59.3%
associate-*r*59.3%
*-commutative59.3%
associate-*r/59.2%
Simplified59.2%
Taylor expanded in a around 0 67.1%
metadata-eval67.1%
times-frac67.1%
*-commutative67.1%
times-frac66.9%
/-rgt-identity66.9%
Simplified66.9%
Final simplification64.2%
(FPCore (a b c) :precision binary64 (if (<= b 8.5e-306) (* b (/ -0.6666666666666666 a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 8.5e-306) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / 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 <= 8.5d-306) then
tmp = b * ((-0.6666666666666666d0) / a)
else
tmp = c * ((-0.5d0) / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 8.5e-306) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 8.5e-306: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 8.5e-306) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(c * Float64(-0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 8.5e-306) tmp = b * (-0.6666666666666666 / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 8.5e-306], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8.5 \cdot 10^{-306}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 8.5000000000000002e-306Initial program 73.2%
sqr-neg73.2%
sqr-neg73.2%
associate-*l*73.2%
Simplified73.2%
+-commutative73.2%
add-sqr-sqrt73.0%
fma-define73.0%
Applied egg-rr62.9%
associate-*r*62.9%
*-commutative62.9%
associate-*r*62.9%
Simplified62.9%
Taylor expanded in b around -inf 61.7%
associate-*r/61.7%
*-commutative61.7%
associate-/l*61.7%
Simplified61.7%
if 8.5000000000000002e-306 < b Initial program 34.4%
sqr-neg34.4%
sqr-neg34.4%
associate-*l*34.4%
Simplified34.4%
Taylor expanded in b around inf 55.1%
*-commutative55.1%
associate-/l*59.3%
associate-*r*59.3%
*-commutative59.3%
associate-*r/59.2%
Simplified59.2%
Taylor expanded in a around 0 67.1%
metadata-eval67.1%
times-frac67.1%
*-commutative67.1%
times-frac66.9%
/-rgt-identity66.9%
Simplified66.9%
(FPCore (a b c) :precision binary64 (* b (/ -0.6666666666666666 a)))
double code(double a, double b, double c) {
return b * (-0.6666666666666666 / 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 * ((-0.6666666666666666d0) / a)
end function
public static double code(double a, double b, double c) {
return b * (-0.6666666666666666 / a);
}
def code(a, b, c): return b * (-0.6666666666666666 / a)
function code(a, b, c) return Float64(b * Float64(-0.6666666666666666 / a)) end
function tmp = code(a, b, c) tmp = b * (-0.6666666666666666 / a); end
code[a_, b_, c_] := N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \frac{-0.6666666666666666}{a}
\end{array}
Initial program 54.8%
sqr-neg54.8%
sqr-neg54.8%
associate-*l*54.8%
Simplified54.8%
+-commutative54.8%
add-sqr-sqrt53.1%
fma-define51.1%
Applied egg-rr51.1%
associate-*r*51.1%
*-commutative51.1%
associate-*r*51.1%
Simplified51.1%
Taylor expanded in b around -inf 33.8%
associate-*r/33.7%
*-commutative33.7%
associate-/l*33.7%
Simplified33.7%
herbie shell --seed 2024096
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))