
(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 -2.2e+151)
(/ b (* a -1.5))
(if (<= b 2.2e-38)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.2e+151) {
tmp = b / (a * -1.5);
} else if (b <= 2.2e-38) {
tmp = (sqrt(((b * b) - (3.0 * (a * 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 <= (-2.2d+151)) then
tmp = b / (a * (-1.5d0))
else if (b <= 2.2d-38) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * 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 <= -2.2e+151) {
tmp = b / (a * -1.5);
} else if (b <= 2.2e-38) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.2e+151: tmp = b / (a * -1.5) elif b <= 2.2e-38: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.2e+151) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 2.2e-38) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * 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 <= -2.2e+151) tmp = b / (a * -1.5); elseif (b <= 2.2e-38) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.2e+151], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.2e-38], 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 / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.2 \cdot 10^{+151}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 2.2 \cdot 10^{-38}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.20000000000000007e151Initial program 52.3%
sqr-neg52.3%
sqr-neg52.3%
associate-*l*52.3%
Simplified52.3%
Applied egg-rr69.3%
Taylor expanded in b around -inf 95.9%
associate-*r/96.0%
*-commutative96.0%
associate-/l*96.0%
Simplified96.0%
clear-num95.9%
un-div-inv96.0%
div-inv96.2%
metadata-eval96.2%
Applied egg-rr96.2%
if -2.20000000000000007e151 < b < 2.20000000000000007e-38Initial program 82.2%
sqr-neg82.2%
sqr-neg82.2%
associate-*l*82.2%
Simplified82.2%
if 2.20000000000000007e-38 < b Initial program 15.4%
sqr-neg15.4%
sqr-neg15.4%
associate-*l*15.4%
Simplified15.4%
Taylor expanded in b around inf 89.3%
*-commutative89.3%
Simplified89.3%
Final simplification87.3%
(FPCore (a b c)
:precision binary64
(if (<= b -6e-67)
(+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5))
(if (<= b 2.6e-40)
(/ (- (sqrt (* (* a c) -3.0)) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6e-67) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 2.6e-40) {
tmp = (sqrt(((a * c) * -3.0)) - 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 <= (-6d-67)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
else if (b <= 2.6d-40) then
tmp = (sqrt(((a * c) * (-3.0d0))) - 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 <= -6e-67) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 2.6e-40) {
tmp = (Math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6e-67: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) elif b <= 2.6e-40: tmp = (math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6e-67) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); elseif (b <= 2.6e-40) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - 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 <= -6e-67) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); elseif (b <= 2.6e-40) tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6e-67], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.6e-40], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $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 -6 \cdot 10^{-67}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 2.6 \cdot 10^{-40}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -6.00000000000000065e-67Initial program 74.8%
sqr-neg74.8%
sqr-neg74.8%
associate-*l*74.8%
Simplified74.8%
Taylor expanded in b around -inf 88.0%
associate-*r*88.0%
mul-1-neg88.0%
fma-define88.0%
associate-*r/88.0%
metadata-eval88.0%
Simplified88.0%
Taylor expanded in c around 0 88.0%
if -6.00000000000000065e-67 < b < 2.6000000000000001e-40Initial program 71.5%
sqr-neg71.5%
sqr-neg71.5%
associate-*l*71.5%
Simplified71.5%
Taylor expanded in b around 0 71.5%
+-commutative71.5%
unsub-neg71.5%
Applied egg-rr71.5%
if 2.6000000000000001e-40 < b Initial program 15.4%
sqr-neg15.4%
sqr-neg15.4%
associate-*l*15.4%
Simplified15.4%
Taylor expanded in b around inf 89.3%
*-commutative89.3%
Simplified89.3%
Final simplification83.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.7e-66)
(+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5))
(if (<= b 4.8e-38)
(* (- b (sqrt (* a (* c -3.0)))) (/ -0.3333333333333333 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.7e-66) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 4.8e-38) {
tmp = (b - sqrt((a * (c * -3.0)))) * (-0.3333333333333333 / 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.7d-66)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
else if (b <= 4.8d-38) then
tmp = (b - sqrt((a * (c * (-3.0d0))))) * ((-0.3333333333333333d0) / 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.7e-66) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 4.8e-38) {
tmp = (b - Math.sqrt((a * (c * -3.0)))) * (-0.3333333333333333 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.7e-66: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) elif b <= 4.8e-38: tmp = (b - math.sqrt((a * (c * -3.0)))) * (-0.3333333333333333 / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.7e-66) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); elseif (b <= 4.8e-38) tmp = Float64(Float64(b - sqrt(Float64(a * Float64(c * -3.0)))) * Float64(-0.3333333333333333 / 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.7e-66) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); elseif (b <= 4.8e-38) tmp = (b - sqrt((a * (c * -3.0)))) * (-0.3333333333333333 / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.7e-66], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.8e-38], N[(N[(b - N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.7 \cdot 10^{-66}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 4.8 \cdot 10^{-38}:\\
\;\;\;\;\left(b - \sqrt{a \cdot \left(c \cdot -3\right)}\right) \cdot \frac{-0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.69999999999999999e-66Initial program 74.8%
sqr-neg74.8%
sqr-neg74.8%
associate-*l*74.8%
Simplified74.8%
Taylor expanded in b around -inf 88.0%
associate-*r*88.0%
mul-1-neg88.0%
fma-define88.0%
associate-*r/88.0%
metadata-eval88.0%
Simplified88.0%
Taylor expanded in c around 0 88.0%
if -1.69999999999999999e-66 < b < 4.80000000000000044e-38Initial program 71.5%
sqr-neg71.5%
sqr-neg71.5%
associate-*l*71.5%
Simplified71.5%
Taylor expanded in b around 0 71.5%
frac-2neg71.5%
div-inv71.4%
distribute-neg-in71.4%
add-sqr-sqrt31.8%
sqrt-unprod70.9%
sqr-neg70.9%
sqrt-unprod40.0%
add-sqr-sqrt70.9%
sub-neg70.9%
add-sqr-sqrt31.0%
sqrt-unprod70.8%
sqr-neg70.8%
sqrt-unprod39.6%
add-sqr-sqrt71.4%
distribute-lft-neg-in71.4%
metadata-eval71.4%
Applied egg-rr71.4%
*-commutative71.4%
rem-square-sqrt0.0%
unpow20.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt71.3%
associate-/r*71.4%
metadata-eval71.4%
Simplified71.4%
if 4.80000000000000044e-38 < b Initial program 15.4%
sqr-neg15.4%
sqr-neg15.4%
associate-*l*15.4%
Simplified15.4%
Taylor expanded in b around inf 89.3%
*-commutative89.3%
Simplified89.3%
Final simplification83.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.55e-70)
(+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5))
(if (<= b 2.6e-37)
(* 0.3333333333333333 (/ (+ b (sqrt (* a (* c -3.0)))) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.55e-70) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 2.6e-37) {
tmp = 0.3333333333333333 * ((b + sqrt((a * (c * -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 <= (-1.55d-70)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
else if (b <= 2.6d-37) then
tmp = 0.3333333333333333d0 * ((b + sqrt((a * (c * (-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 <= -1.55e-70) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 2.6e-37) {
tmp = 0.3333333333333333 * ((b + Math.sqrt((a * (c * -3.0)))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.55e-70: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) elif b <= 2.6e-37: tmp = 0.3333333333333333 * ((b + math.sqrt((a * (c * -3.0)))) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.55e-70) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); elseif (b <= 2.6e-37) tmp = Float64(0.3333333333333333 * Float64(Float64(b + sqrt(Float64(a * Float64(c * -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 <= -1.55e-70) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); elseif (b <= 2.6e-37) tmp = 0.3333333333333333 * ((b + sqrt((a * (c * -3.0)))) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.55e-70], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.6e-37], N[(0.3333333333333333 * N[(N[(b + N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.55 \cdot 10^{-70}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 2.6 \cdot 10^{-37}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{b + \sqrt{a \cdot \left(c \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.55e-70Initial program 74.8%
sqr-neg74.8%
sqr-neg74.8%
associate-*l*74.8%
Simplified74.8%
Taylor expanded in b around -inf 88.0%
associate-*r*88.0%
mul-1-neg88.0%
fma-define88.0%
associate-*r/88.0%
metadata-eval88.0%
Simplified88.0%
Taylor expanded in c around 0 88.0%
if -1.55e-70 < b < 2.5999999999999998e-37Initial program 71.5%
sqr-neg71.5%
sqr-neg71.5%
associate-*l*71.5%
Simplified71.5%
Taylor expanded in b around 0 71.5%
associate-*r*71.5%
*-commutative71.5%
Simplified71.5%
*-un-lft-identity71.5%
times-frac71.3%
metadata-eval71.3%
add-sqr-sqrt31.9%
sqrt-unprod70.8%
sqr-neg70.8%
sqrt-unprod39.8%
add-sqr-sqrt70.9%
associate-*l*70.9%
Applied egg-rr70.9%
if 2.5999999999999998e-37 < b Initial program 15.4%
sqr-neg15.4%
sqr-neg15.4%
associate-*l*15.4%
Simplified15.4%
Taylor expanded in b around inf 89.3%
*-commutative89.3%
Simplified89.3%
Final simplification83.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.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 <= (-5d-310)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.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 <= -5e-310) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.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 <= -5e-310) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $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} + \frac{c}{b} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\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 69.0%
associate-*r*69.0%
mul-1-neg69.0%
fma-define69.0%
associate-*r/69.0%
metadata-eval69.0%
Simplified69.0%
Taylor expanded in c around 0 70.5%
if -4.999999999999985e-310 < b Initial program 34.1%
sqr-neg34.1%
sqr-neg34.1%
associate-*l*34.1%
Simplified34.1%
Taylor expanded in b around inf 62.3%
*-commutative62.3%
Simplified62.3%
Final simplification66.7%
(FPCore (a b c) :precision binary64 (if (<= b 1.9e-297) (/ b (* a -1.5)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.9e-297) {
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.9d-297) 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.9e-297) {
tmp = b / (a * -1.5);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.9e-297: tmp = b / (a * -1.5) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.9e-297) 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.9e-297) tmp = b / (a * -1.5); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.9e-297], 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.9 \cdot 10^{-297}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.90000000000000002e-297Initial program 74.3%
sqr-neg74.3%
sqr-neg74.3%
associate-*l*74.2%
Simplified74.2%
Applied egg-rr64.9%
Taylor expanded in b around -inf 68.7%
associate-*r/68.8%
*-commutative68.8%
associate-/l*68.8%
Simplified68.8%
clear-num68.7%
un-div-inv68.8%
div-inv68.9%
metadata-eval68.9%
Applied egg-rr68.9%
if 1.90000000000000002e-297 < b Initial program 33.2%
sqr-neg33.2%
sqr-neg33.2%
associate-*l*33.2%
Simplified33.2%
Taylor expanded in b around inf 63.8%
*-commutative63.8%
Simplified63.8%
(FPCore (a b c) :precision binary64 (if (<= b 9e-294) (* b (/ -0.6666666666666666 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 9e-294) {
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 <= 9d-294) 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 <= 9e-294) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 9e-294: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 9e-294) 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 <= 9e-294) tmp = b * (-0.6666666666666666 / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 9e-294], 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 9 \cdot 10^{-294}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 8.99999999999999963e-294Initial program 74.3%
sqr-neg74.3%
sqr-neg74.3%
associate-*l*74.2%
Simplified74.2%
Applied egg-rr64.9%
Taylor expanded in b around -inf 68.7%
associate-*r/68.8%
*-commutative68.8%
associate-/l*68.8%
Simplified68.8%
if 8.99999999999999963e-294 < b Initial program 33.2%
sqr-neg33.2%
sqr-neg33.2%
associate-*l*33.2%
Simplified33.2%
Taylor expanded in b around inf 63.8%
*-commutative63.8%
Simplified63.8%
(FPCore (a b c) :precision binary64 (if (<= b 1.9e-297) (* b (/ -0.6666666666666666 a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.9e-297) {
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 <= 1.9d-297) 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 <= 1.9e-297) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.9e-297: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.9e-297) 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 <= 1.9e-297) tmp = b * (-0.6666666666666666 / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.9e-297], 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 1.9 \cdot 10^{-297}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 1.90000000000000002e-297Initial program 74.3%
sqr-neg74.3%
sqr-neg74.3%
associate-*l*74.2%
Simplified74.2%
Applied egg-rr64.9%
Taylor expanded in b around -inf 68.7%
associate-*r/68.8%
*-commutative68.8%
associate-/l*68.8%
Simplified68.8%
if 1.90000000000000002e-297 < b Initial program 33.2%
sqr-neg33.2%
sqr-neg33.2%
associate-*l*33.2%
Simplified33.2%
Applied egg-rr41.7%
clear-num41.8%
frac-times41.8%
metadata-eval41.8%
Applied egg-rr41.8%
*-commutative41.8%
clear-num41.7%
clear-num41.7%
un-div-inv41.8%
clear-num41.7%
div-inv41.8%
associate-*r*41.8%
*-commutative41.8%
metadata-eval41.8%
Applied egg-rr41.8%
Taylor expanded in a around 0 0.0%
*-commutative0.0%
associate-/l*0.0%
unpow20.0%
rem-square-sqrt63.6%
associate-*r*63.5%
associate-*l/63.6%
metadata-eval63.6%
Simplified63.6%
(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 55.8%
sqr-neg55.8%
sqr-neg55.8%
associate-*l*55.8%
Simplified55.8%
Applied egg-rr54.5%
Taylor expanded in b around -inf 39.0%
associate-*r/39.0%
*-commutative39.0%
associate-/l*39.0%
Simplified39.0%
herbie shell --seed 2024116
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))