
(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 9 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 -5.9e+153)
(* (* b 2.0) (/ 1.0 (* a -3.0)))
(if (<= b 1.75e-63)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.9e+153) {
tmp = (b * 2.0) * (1.0 / (a * -3.0));
} else if (b <= 1.75e-63) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5.9d+153)) then
tmp = (b * 2.0d0) * (1.0d0 / (a * (-3.0d0)))
else if (b <= 1.75d-63) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5.9e+153) {
tmp = (b * 2.0) * (1.0 / (a * -3.0));
} else if (b <= 1.75e-63) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.9e+153: tmp = (b * 2.0) * (1.0 / (a * -3.0)) elif b <= 1.75e-63: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.9e+153) tmp = Float64(Float64(b * 2.0) * Float64(1.0 / Float64(a * -3.0))); elseif (b <= 1.75e-63) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.9e+153) tmp = (b * 2.0) * (1.0 / (a * -3.0)); elseif (b <= 1.75e-63) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.9e+153], N[(N[(b * 2.0), $MachinePrecision] * N[(1.0 / N[(a * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.75e-63], 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 / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.9 \cdot 10^{+153}:\\
\;\;\;\;\left(b \cdot 2\right) \cdot \frac{1}{a \cdot -3}\\
\mathbf{elif}\;b \leq 1.75 \cdot 10^{-63}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -5.9000000000000002e153Initial program 43.8%
frac-2neg43.8%
div-inv43.8%
Applied egg-rr43.9%
Taylor expanded in b around -inf 97.7%
*-commutative97.7%
Simplified97.7%
if -5.9000000000000002e153 < b < 1.75000000000000002e-63Initial program 79.6%
if 1.75000000000000002e-63 < b Initial program 9.8%
Taylor expanded in b around inf 87.3%
*-commutative87.3%
Simplified87.3%
Final simplification85.4%
(FPCore (a b c)
:precision binary64
(if (<= b -1.85e-35)
(* (* b 2.0) (/ 1.0 (* a -3.0)))
(if (<= b 4.4e-145)
(/ (- (sqrt (* (* a -3.0) c)) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.85e-35) {
tmp = (b * 2.0) * (1.0 / (a * -3.0));
} else if (b <= 4.4e-145) {
tmp = (sqrt(((a * -3.0) * c)) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.85d-35)) then
tmp = (b * 2.0d0) * (1.0d0 / (a * (-3.0d0)))
else if (b <= 4.4d-145) then
tmp = (sqrt(((a * (-3.0d0)) * c)) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.85e-35) {
tmp = (b * 2.0) * (1.0 / (a * -3.0));
} else if (b <= 4.4e-145) {
tmp = (Math.sqrt(((a * -3.0) * c)) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.85e-35: tmp = (b * 2.0) * (1.0 / (a * -3.0)) elif b <= 4.4e-145: tmp = (math.sqrt(((a * -3.0) * c)) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.85e-35) tmp = Float64(Float64(b * 2.0) * Float64(1.0 / Float64(a * -3.0))); elseif (b <= 4.4e-145) tmp = Float64(Float64(sqrt(Float64(Float64(a * -3.0) * c)) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.85e-35) tmp = (b * 2.0) * (1.0 / (a * -3.0)); elseif (b <= 4.4e-145) tmp = (sqrt(((a * -3.0) * c)) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.85e-35], N[(N[(b * 2.0), $MachinePrecision] * N[(1.0 / N[(a * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.4e-145], N[(N[(N[Sqrt[N[(N[(a * -3.0), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.85 \cdot 10^{-35}:\\
\;\;\;\;\left(b \cdot 2\right) \cdot \frac{1}{a \cdot -3}\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{-145}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot -3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.8499999999999999e-35Initial program 65.4%
frac-2neg65.4%
div-inv65.4%
Applied egg-rr65.5%
Taylor expanded in b around -inf 87.1%
*-commutative87.1%
Simplified87.1%
if -1.8499999999999999e-35 < b < 4.39999999999999998e-145Initial program 80.6%
Taylor expanded in b around 0 69.1%
*-commutative69.1%
*-commutative69.1%
associate-*r*69.3%
Simplified69.3%
if 4.39999999999999998e-145 < b Initial program 14.3%
Taylor expanded in b around inf 82.0%
*-commutative82.0%
Simplified82.0%
Final simplification80.5%
(FPCore (a b c) :precision binary64 (if (<= b 2.7e-247) (* (* b 2.0) (/ 1.0 (* a -3.0))) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.7e-247) {
tmp = (b * 2.0) * (1.0 / (a * -3.0));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 2.7d-247) then
tmp = (b * 2.0d0) * (1.0d0 / (a * (-3.0d0)))
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.7e-247) {
tmp = (b * 2.0) * (1.0 / (a * -3.0));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.7e-247: tmp = (b * 2.0) * (1.0 / (a * -3.0)) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.7e-247) tmp = Float64(Float64(b * 2.0) * Float64(1.0 / Float64(a * -3.0))); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.7e-247) tmp = (b * 2.0) * (1.0 / (a * -3.0)); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.7e-247], N[(N[(b * 2.0), $MachinePrecision] * N[(1.0 / N[(a * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.7 \cdot 10^{-247}:\\
\;\;\;\;\left(b \cdot 2\right) \cdot \frac{1}{a \cdot -3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 2.70000000000000008e-247Initial program 71.3%
frac-2neg71.3%
div-inv71.3%
Applied egg-rr71.3%
Taylor expanded in b around -inf 61.8%
*-commutative61.8%
Simplified61.8%
if 2.70000000000000008e-247 < b Initial program 21.6%
Taylor expanded in b around inf 74.0%
*-commutative74.0%
Simplified74.0%
(FPCore (a b c) :precision binary64 (if (<= b 2.7e-247) (/ -0.6666666666666666 (/ a b)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.7e-247) {
tmp = -0.6666666666666666 / (a / b);
} 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.7d-247) then
tmp = (-0.6666666666666666d0) / (a / b)
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.7e-247) {
tmp = -0.6666666666666666 / (a / b);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.7e-247: tmp = -0.6666666666666666 / (a / b) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.7e-247) tmp = Float64(-0.6666666666666666 / Float64(a / b)); 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.7e-247) tmp = -0.6666666666666666 / (a / b); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.7e-247], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.7 \cdot 10^{-247}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 2.70000000000000008e-247Initial program 71.3%
Taylor expanded in b around -inf 61.8%
*-commutative61.8%
Simplified61.8%
*-commutative61.8%
clear-num61.7%
un-div-inv61.8%
Applied egg-rr61.8%
if 2.70000000000000008e-247 < b Initial program 21.6%
Taylor expanded in b around inf 74.0%
*-commutative74.0%
Simplified74.0%
(FPCore (a b c) :precision binary64 (if (<= b 2.7e-247) (* -0.6666666666666666 (/ b a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.7e-247) {
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 <= 2.7d-247) 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 <= 2.7e-247) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.7e-247: tmp = -0.6666666666666666 * (b / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.7e-247) 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 <= 2.7e-247) tmp = -0.6666666666666666 * (b / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.7e-247], 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 2.7 \cdot 10^{-247}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 2.70000000000000008e-247Initial program 71.3%
Taylor expanded in b around -inf 61.8%
*-commutative61.8%
Simplified61.8%
if 2.70000000000000008e-247 < b Initial program 21.6%
Taylor expanded in b around inf 74.0%
*-commutative74.0%
Simplified74.0%
Final simplification67.2%
(FPCore (a b c) :precision binary64 (if (<= b 3.95e+127) (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.95e+127) {
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 <= 3.95d+127) 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 <= 3.95e+127) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * 0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.95e+127: tmp = -0.6666666666666666 * (b / a) else: tmp = (c / b) * 0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.95e+127) 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 <= 3.95e+127) tmp = -0.6666666666666666 * (b / a); else tmp = (c / b) * 0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.95e+127], 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 3.95 \cdot 10^{+127}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot 0.5\\
\end{array}
\end{array}
if b < 3.9499999999999998e127Initial program 58.5%
Taylor expanded in b around -inf 42.8%
*-commutative42.8%
Simplified42.8%
if 3.9499999999999998e127 < b Initial program 6.4%
clear-num6.4%
associate-/r/6.4%
associate-/r*6.4%
metadata-eval6.4%
add-sqr-sqrt0.0%
sqrt-unprod1.8%
sqr-neg1.8%
sqrt-prod1.8%
add-sqr-sqrt1.8%
sub-neg1.8%
+-commutative1.8%
*-commutative1.8%
distribute-rgt-neg-in1.8%
fma-define1.8%
*-commutative1.8%
distribute-rgt-neg-in1.8%
metadata-eval1.8%
pow21.8%
Applied egg-rr1.8%
Taylor expanded in b around -inf 34.9%
Final simplification41.3%
(FPCore (a b c) :precision binary64 (if (<= b 3.95e+127) (* b (/ -0.6666666666666666 a)) (* (/ c b) 0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.95e+127) {
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 <= 3.95d+127) 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 <= 3.95e+127) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * 0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.95e+127: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * 0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.95e+127) 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 <= 3.95e+127) tmp = b * (-0.6666666666666666 / a); else tmp = (c / b) * 0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.95e+127], 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 3.95 \cdot 10^{+127}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot 0.5\\
\end{array}
\end{array}
if b < 3.9499999999999998e127Initial program 58.5%
Taylor expanded in b around -inf 42.8%
*-commutative42.8%
Simplified42.8%
*-commutative42.8%
clear-num42.7%
un-div-inv42.8%
Applied egg-rr42.8%
associate-/r/42.7%
Simplified42.7%
if 3.9499999999999998e127 < b Initial program 6.4%
clear-num6.4%
associate-/r/6.4%
associate-/r*6.4%
metadata-eval6.4%
add-sqr-sqrt0.0%
sqrt-unprod1.8%
sqr-neg1.8%
sqrt-prod1.8%
add-sqr-sqrt1.8%
sub-neg1.8%
+-commutative1.8%
*-commutative1.8%
distribute-rgt-neg-in1.8%
fma-define1.8%
*-commutative1.8%
distribute-rgt-neg-in1.8%
metadata-eval1.8%
pow21.8%
Applied egg-rr1.8%
Taylor expanded in b around -inf 34.9%
Final simplification41.3%
(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 49.2%
clear-num49.2%
associate-/r/49.1%
associate-/r*49.1%
metadata-eval49.1%
add-sqr-sqrt36.8%
sqrt-unprod47.4%
sqr-neg47.4%
sqrt-prod10.8%
add-sqr-sqrt30.6%
sub-neg30.6%
+-commutative30.6%
*-commutative30.6%
distribute-rgt-neg-in30.6%
fma-define30.7%
*-commutative30.7%
distribute-rgt-neg-in30.7%
metadata-eval30.7%
pow230.7%
Applied egg-rr30.7%
Taylor expanded in b around -inf 8.8%
Final simplification8.8%
(FPCore (a b c) :precision binary64 -3.0)
double code(double a, double b, double c) {
return -3.0;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = -3.0d0
end function
public static double code(double a, double b, double c) {
return -3.0;
}
def code(a, b, c): return -3.0
function code(a, b, c) return -3.0 end
function tmp = code(a, b, c) tmp = -3.0; end
code[a_, b_, c_] := -3.0
\begin{array}{l}
\\
-3
\end{array}
Initial program 49.2%
frac-2neg49.2%
div-inv49.1%
Applied egg-rr49.2%
Taylor expanded in a around 0 49.2%
Taylor expanded in b around -inf 35.5%
Simplified3.6%
herbie shell --seed 2024088
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))