
(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 -3e+135)
(/ b (* a -1.5))
(if (<= b 1.05e-152)
(/ (- (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 <= -3e+135) {
tmp = b / (a * -1.5);
} else if (b <= 1.05e-152) {
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 <= (-3d+135)) then
tmp = b / (a * (-1.5d0))
else if (b <= 1.05d-152) 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 <= -3e+135) {
tmp = b / (a * -1.5);
} else if (b <= 1.05e-152) {
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 <= -3e+135: tmp = b / (a * -1.5) elif b <= 1.05e-152: 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 <= -3e+135) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 1.05e-152) 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 <= -3e+135) tmp = b / (a * -1.5); elseif (b <= 1.05e-152) 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, -3e+135], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.05e-152], 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 -3 \cdot 10^{+135}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{-152}:\\
\;\;\;\;\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 < -3e135Initial program 53.9%
sqr-neg53.9%
sqr-neg53.9%
associate-*l*53.9%
Simplified53.9%
Applied egg-rr53.7%
Taylor expanded in b around -inf 97.9%
*-commutative97.9%
associate-*l/97.9%
associate-/l*98.0%
Simplified98.0%
clear-num98.0%
un-div-inv98.0%
div-inv98.1%
metadata-eval98.1%
Applied egg-rr98.1%
if -3e135 < b < 1.04999999999999999e-152Initial program 86.5%
if 1.04999999999999999e-152 < b Initial program 22.9%
sqr-neg22.9%
sqr-neg22.9%
associate-*l*22.9%
Simplified22.9%
Taylor expanded in b around inf 82.7%
*-commutative82.7%
associate-*l/82.8%
Simplified82.8%
Final simplification87.4%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+135)
(/ b (* a -1.5))
(if (<= b 1.05e-152)
(/ (- (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 <= -5e+135) {
tmp = b / (a * -1.5);
} else if (b <= 1.05e-152) {
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 <= (-5d+135)) then
tmp = b / (a * (-1.5d0))
else if (b <= 1.05d-152) 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 <= -5e+135) {
tmp = b / (a * -1.5);
} else if (b <= 1.05e-152) {
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 <= -5e+135: tmp = b / (a * -1.5) elif b <= 1.05e-152: 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 <= -5e+135) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 1.05e-152) 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 <= -5e+135) tmp = b / (a * -1.5); elseif (b <= 1.05e-152) 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, -5e+135], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.05e-152], 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 -5 \cdot 10^{+135}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{-152}:\\
\;\;\;\;\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 < -5.00000000000000029e135Initial program 53.9%
sqr-neg53.9%
sqr-neg53.9%
associate-*l*53.9%
Simplified53.9%
Applied egg-rr53.7%
Taylor expanded in b around -inf 97.9%
*-commutative97.9%
associate-*l/97.9%
associate-/l*98.0%
Simplified98.0%
clear-num98.0%
un-div-inv98.0%
div-inv98.1%
metadata-eval98.1%
Applied egg-rr98.1%
if -5.00000000000000029e135 < b < 1.04999999999999999e-152Initial program 86.5%
sqr-neg86.5%
sqr-neg86.5%
associate-*l*86.4%
Simplified86.4%
if 1.04999999999999999e-152 < b Initial program 22.9%
sqr-neg22.9%
sqr-neg22.9%
associate-*l*22.9%
Simplified22.9%
Taylor expanded in b around inf 82.7%
*-commutative82.7%
associate-*l/82.8%
Simplified82.8%
Final simplification87.3%
(FPCore (a b c)
:precision binary64
(if (<= b -80000.0)
(/ (+ (* -2.0 (/ b a)) (* 1.5 (/ c b))) 3.0)
(if (<= b 1.05e-152)
(* (/ -0.3333333333333333 a) (- b (sqrt (* a (* c -3.0)))))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -80000.0) {
tmp = ((-2.0 * (b / a)) + (1.5 * (c / b))) / 3.0;
} else if (b <= 1.05e-152) {
tmp = (-0.3333333333333333 / a) * (b - sqrt((a * (c * -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 <= (-80000.0d0)) then
tmp = (((-2.0d0) * (b / a)) + (1.5d0 * (c / b))) / 3.0d0
else if (b <= 1.05d-152) then
tmp = ((-0.3333333333333333d0) / a) * (b - sqrt((a * (c * (-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 <= -80000.0) {
tmp = ((-2.0 * (b / a)) + (1.5 * (c / b))) / 3.0;
} else if (b <= 1.05e-152) {
tmp = (-0.3333333333333333 / a) * (b - Math.sqrt((a * (c * -3.0))));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -80000.0: tmp = ((-2.0 * (b / a)) + (1.5 * (c / b))) / 3.0 elif b <= 1.05e-152: tmp = (-0.3333333333333333 / a) * (b - math.sqrt((a * (c * -3.0)))) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -80000.0) tmp = Float64(Float64(Float64(-2.0 * Float64(b / a)) + Float64(1.5 * Float64(c / b))) / 3.0); elseif (b <= 1.05e-152) tmp = Float64(Float64(-0.3333333333333333 / a) * Float64(b - sqrt(Float64(a * Float64(c * -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 <= -80000.0) tmp = ((-2.0 * (b / a)) + (1.5 * (c / b))) / 3.0; elseif (b <= 1.05e-152) tmp = (-0.3333333333333333 / a) * (b - sqrt((a * (c * -3.0)))); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -80000.0], N[(N[(N[(-2.0 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(1.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision], If[LessEqual[b, 1.05e-152], N[(N[(-0.3333333333333333 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -80000:\\
\;\;\;\;\frac{-2 \cdot \frac{b}{a} + 1.5 \cdot \frac{c}{b}}{3}\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{-152}:\\
\;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{a \cdot \left(c \cdot -3\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -8e4Initial program 69.4%
sqr-neg69.4%
sqr-neg69.4%
associate-*l*69.4%
Simplified69.4%
Taylor expanded in b around -inf 90.5%
add-cube-cbrt89.6%
*-commutative89.6%
times-frac89.7%
pow289.7%
*-commutative89.7%
fma-define89.7%
*-commutative89.7%
associate-/l*89.7%
associate-*l*89.7%
Applied egg-rr93.2%
associate-*r/93.1%
associate-*l/93.2%
unpow293.2%
rem-3cbrt-lft94.2%
Simplified94.2%
Taylor expanded in b around 0 94.2%
if -8e4 < b < 1.04999999999999999e-152Initial program 81.0%
sqr-neg81.0%
sqr-neg81.0%
associate-*l*80.9%
Simplified80.9%
Taylor expanded in b around 0 68.7%
*-commutative68.7%
associate-*r*68.7%
Simplified68.7%
frac-2neg68.7%
div-inv68.6%
distribute-neg-in68.6%
add-sqr-sqrt45.9%
sqrt-unprod67.9%
sqr-neg67.9%
sqrt-unprod22.8%
add-sqr-sqrt65.1%
sub-neg65.1%
add-sqr-sqrt42.3%
sqrt-unprod65.1%
sqr-neg65.1%
sqrt-unprod22.7%
add-sqr-sqrt68.6%
distribute-lft-neg-in68.6%
metadata-eval68.6%
*-commutative68.6%
associate-/r*68.5%
div-inv68.6%
metadata-eval68.6%
Applied egg-rr68.6%
*-commutative68.6%
associate-*l/68.8%
metadata-eval68.8%
Simplified68.8%
if 1.04999999999999999e-152 < b Initial program 22.9%
sqr-neg22.9%
sqr-neg22.9%
associate-*l*22.9%
Simplified22.9%
Taylor expanded in b around inf 82.7%
*-commutative82.7%
associate-*l/82.8%
Simplified82.8%
Final simplification82.8%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (+ (* -2.0 (/ b a)) (* 1.5 (/ c b))) 3.0) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = ((-2.0 * (b / a)) + (1.5 * (c / b))) / 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 <= (-5d-310)) then
tmp = (((-2.0d0) * (b / a)) + (1.5d0 * (c / b))) / 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 <= -5e-310) {
tmp = ((-2.0 * (b / a)) + (1.5 * (c / b))) / 3.0;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = ((-2.0 * (b / a)) + (1.5 * (c / b))) / 3.0 else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(Float64(-2.0 * Float64(b / a)) + Float64(1.5 * Float64(c / b))) / 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 <= -5e-310) tmp = ((-2.0 * (b / a)) + (1.5 * (c / b))) / 3.0; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(N[(-2.0 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(1.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{-2 \cdot \frac{b}{a} + 1.5 \cdot \frac{c}{b}}{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 74.4%
sqr-neg74.4%
sqr-neg74.4%
associate-*l*74.4%
Simplified74.4%
Taylor expanded in b around -inf 68.6%
add-cube-cbrt67.8%
*-commutative67.8%
times-frac67.8%
pow267.8%
*-commutative67.8%
fma-define67.8%
*-commutative67.8%
associate-/l*67.9%
associate-*l*67.9%
Applied egg-rr70.3%
associate-*r/70.3%
associate-*l/70.3%
unpow270.3%
rem-3cbrt-lft71.2%
Simplified71.2%
Taylor expanded in b around 0 71.3%
if -4.999999999999985e-310 < b Initial program 31.1%
sqr-neg31.1%
sqr-neg31.1%
associate-*l*31.1%
Simplified31.1%
Taylor expanded in b around inf 71.3%
*-commutative71.3%
associate-*l/71.3%
Simplified71.3%
Final simplification71.3%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (+ (* (/ b a) -0.6666666666666666) (* (/ c b) 0.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.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 <= (-5d-310)) then
tmp = ((b / a) * (-0.6666666666666666d0)) + ((c / b) * 0.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 <= -5e-310) {
tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(Float64(b / a) * -0.6666666666666666) + Float64(Float64(c / b) * 0.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 <= -5e-310) tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666 + \frac{c}{b} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 74.4%
sqr-neg74.4%
sqr-neg74.4%
associate-*l*74.4%
Simplified74.4%
Taylor expanded in b around -inf 71.2%
if -4.999999999999985e-310 < b Initial program 31.1%
sqr-neg31.1%
sqr-neg31.1%
associate-*l*31.1%
Simplified31.1%
Taylor expanded in b around inf 71.3%
*-commutative71.3%
associate-*l/71.3%
Simplified71.3%
Final simplification71.2%
(FPCore (a b c) :precision binary64 (if (<= b 1.22e+61) (* b (/ -0.6666666666666666 a)) (* (/ c b) 0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.22e+61) {
tmp = b * (-0.6666666666666666 / 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.22d+61) then
tmp = b * ((-0.6666666666666666d0) / 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.22e+61) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * 0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.22e+61: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * 0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.22e+61) tmp = Float64(b * Float64(-0.6666666666666666 / 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.22e+61) tmp = b * (-0.6666666666666666 / a); else tmp = (c / b) * 0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.22e+61], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.22 \cdot 10^{+61}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot 0.5\\
\end{array}
\end{array}
if b < 1.22e61Initial program 67.4%
sqr-neg67.4%
sqr-neg67.4%
associate-*l*67.4%
Simplified67.4%
Applied egg-rr63.0%
Taylor expanded in b around -inf 49.8%
*-commutative49.8%
associate-*l/49.8%
associate-/l*49.8%
Simplified49.8%
if 1.22e61 < b Initial program 14.5%
sqr-neg14.5%
sqr-neg14.5%
associate-*l*14.5%
Simplified14.5%
Taylor expanded in b around -inf 2.2%
Taylor expanded in b around 0 35.8%
Final simplification45.9%
(FPCore (a b c) :precision binary64 (if (<= b 1.22e+61) (* (/ b a) -0.6666666666666666) (* (/ c b) 0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.22e+61) {
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.22d+61) 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.22e+61) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c / b) * 0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.22e+61: tmp = (b / a) * -0.6666666666666666 else: tmp = (c / b) * 0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.22e+61) 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.22e+61) tmp = (b / a) * -0.6666666666666666; else tmp = (c / b) * 0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.22e+61], 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.22 \cdot 10^{+61}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot 0.5\\
\end{array}
\end{array}
if b < 1.22e61Initial program 67.4%
sqr-neg67.4%
sqr-neg67.4%
associate-*l*67.4%
Simplified67.4%
Taylor expanded in b around -inf 49.8%
*-commutative49.8%
Simplified49.8%
if 1.22e61 < b Initial program 14.5%
sqr-neg14.5%
sqr-neg14.5%
associate-*l*14.5%
Simplified14.5%
Taylor expanded in b around -inf 2.2%
Taylor expanded in b around 0 35.8%
Final simplification46.0%
(FPCore (a b c) :precision binary64 (if (<= b 1.22e+61) (/ b (* a -1.5)) (* (/ c b) 0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.22e+61) {
tmp = b / (a * -1.5);
} 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.22d+61) then
tmp = b / (a * (-1.5d0))
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.22e+61) {
tmp = b / (a * -1.5);
} else {
tmp = (c / b) * 0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.22e+61: tmp = b / (a * -1.5) else: tmp = (c / b) * 0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.22e+61) tmp = Float64(b / Float64(a * -1.5)); 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.22e+61) tmp = b / (a * -1.5); else tmp = (c / b) * 0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.22e+61], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.22 \cdot 10^{+61}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot 0.5\\
\end{array}
\end{array}
if b < 1.22e61Initial program 67.4%
sqr-neg67.4%
sqr-neg67.4%
associate-*l*67.4%
Simplified67.4%
Applied egg-rr63.0%
Taylor expanded in b around -inf 49.8%
*-commutative49.8%
associate-*l/49.8%
associate-/l*49.8%
Simplified49.8%
clear-num49.8%
un-div-inv49.8%
div-inv49.9%
metadata-eval49.9%
Applied egg-rr49.9%
if 1.22e61 < b Initial program 14.5%
sqr-neg14.5%
sqr-neg14.5%
associate-*l*14.5%
Simplified14.5%
Taylor expanded in b around -inf 2.2%
Taylor expanded in b around 0 35.8%
Final simplification46.0%
(FPCore (a b c) :precision binary64 (if (<= b 3.9e-308) (/ b (* a -1.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.9e-308) {
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 <= 3.9d-308) 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 <= 3.9e-308) {
tmp = b / (a * -1.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.9e-308: tmp = b / (a * -1.5) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.9e-308) 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 <= 3.9e-308) tmp = b / (a * -1.5); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.9e-308], 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 3.9 \cdot 10^{-308}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 3.8999999999999999e-308Initial program 74.4%
sqr-neg74.4%
sqr-neg74.4%
associate-*l*74.4%
Simplified74.4%
Applied egg-rr68.4%
Taylor expanded in b around -inf 70.7%
*-commutative70.7%
associate-*l/70.6%
associate-/l*70.6%
Simplified70.6%
clear-num70.6%
un-div-inv70.7%
div-inv70.7%
metadata-eval70.7%
Applied egg-rr70.7%
if 3.8999999999999999e-308 < b Initial program 31.1%
sqr-neg31.1%
sqr-neg31.1%
associate-*l*31.1%
Simplified31.1%
Taylor expanded in b around inf 71.3%
*-commutative71.3%
associate-*l/71.3%
Simplified71.3%
Final simplification71.0%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (/ b a) -1.5) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
tmp = (b / a) / -1.5;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (b / a) / -1.5 else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(b / 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 <= -5e-310) tmp = (b / a) / -1.5; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(b / a), $MachinePrecision] / -1.5), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\frac{b}{a}}{-1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 74.4%
sqr-neg74.4%
sqr-neg74.4%
associate-*l*74.4%
Simplified74.4%
Applied egg-rr68.4%
Taylor expanded in b around -inf 70.7%
*-commutative70.7%
associate-*l/70.6%
associate-/l*70.6%
Simplified70.6%
clear-num70.6%
un-div-inv70.7%
div-inv70.7%
metadata-eval70.7%
Applied egg-rr70.7%
associate-/r*70.7%
Simplified70.7%
if -4.999999999999985e-310 < b Initial program 31.1%
sqr-neg31.1%
sqr-neg31.1%
associate-*l*31.1%
Simplified31.1%
Taylor expanded in b around inf 71.3%
*-commutative71.3%
associate-*l/71.3%
Simplified71.3%
Final simplification71.0%
(FPCore (a b c) :precision binary64 (* (/ c b) 0.5))
double code(double a, double b, double c) {
return (c / b) * 0.5;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (c / b) * 0.5d0
end function
public static double code(double a, double b, double c) {
return (c / b) * 0.5;
}
def code(a, b, c): return (c / b) * 0.5
function code(a, b, c) return Float64(Float64(c / b) * 0.5) end
function tmp = code(a, b, c) tmp = (c / b) * 0.5; end
code[a_, b_, c_] := N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b} \cdot 0.5
\end{array}
Initial program 52.8%
sqr-neg52.8%
sqr-neg52.8%
associate-*l*52.8%
Simplified52.8%
Taylor expanded in b around -inf 35.4%
Taylor expanded in b around 0 12.3%
Final simplification12.3%
herbie shell --seed 2024039
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))