
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -1.75e+55)
(/ 1.0 (* (/ a b) -1.5))
(if (<= b 5.6e-104)
(/ (- (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 <= -1.75e+55) {
tmp = 1.0 / ((a / b) * -1.5);
} else if (b <= 5.6e-104) {
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 <= (-1.75d+55)) then
tmp = 1.0d0 / ((a / b) * (-1.5d0))
else if (b <= 5.6d-104) 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 <= -1.75e+55) {
tmp = 1.0 / ((a / b) * -1.5);
} else if (b <= 5.6e-104) {
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 <= -1.75e+55: tmp = 1.0 / ((a / b) * -1.5) elif b <= 5.6e-104: 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 <= -1.75e+55) tmp = Float64(1.0 / Float64(Float64(a / b) * -1.5)); elseif (b <= 5.6e-104) 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 <= -1.75e+55) tmp = 1.0 / ((a / b) * -1.5); elseif (b <= 5.6e-104) 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, -1.75e+55], N[(1.0 / N[(N[(a / b), $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-104], 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 -1.75 \cdot 10^{+55}:\\
\;\;\;\;\frac{1}{\frac{a}{b} \cdot -1.5}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-104}:\\
\;\;\;\;\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 < -1.75000000000000005e55Initial program 56.2%
sqr-neg56.2%
sqr-neg56.2%
associate-*l*56.2%
Simplified56.2%
frac-2neg56.2%
div-inv56.2%
Applied egg-rr56.2%
un-div-inv56.2%
clear-num56.1%
fma-undefine56.1%
add-sqr-sqrt36.7%
hypot-define48.7%
Applied egg-rr48.7%
Taylor expanded in b around -inf 95.7%
*-commutative95.7%
Simplified95.7%
if -1.75000000000000005e55 < b < 5.6e-104Initial program 81.8%
if 5.6e-104 < b Initial program 20.0%
sqr-neg20.0%
sqr-neg20.0%
associate-*l*20.0%
Simplified20.0%
Taylor expanded in b around inf 86.4%
*-commutative86.4%
Simplified86.4%
Final simplification87.4%
(FPCore (a b c)
:precision binary64
(if (<= b -1.75e+55)
(/ 1.0 (* (/ a b) -1.5))
(if (<= b 5.6e-104)
(/ (- (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 <= -1.75e+55) {
tmp = 1.0 / ((a / b) * -1.5);
} else if (b <= 5.6e-104) {
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 <= (-1.75d+55)) then
tmp = 1.0d0 / ((a / b) * (-1.5d0))
else if (b <= 5.6d-104) 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 <= -1.75e+55) {
tmp = 1.0 / ((a / b) * -1.5);
} else if (b <= 5.6e-104) {
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 <= -1.75e+55: tmp = 1.0 / ((a / b) * -1.5) elif b <= 5.6e-104: 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 <= -1.75e+55) tmp = Float64(1.0 / Float64(Float64(a / b) * -1.5)); elseif (b <= 5.6e-104) 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 <= -1.75e+55) tmp = 1.0 / ((a / b) * -1.5); elseif (b <= 5.6e-104) 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, -1.75e+55], N[(1.0 / N[(N[(a / b), $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-104], 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 -1.75 \cdot 10^{+55}:\\
\;\;\;\;\frac{1}{\frac{a}{b} \cdot -1.5}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-104}:\\
\;\;\;\;\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 < -1.75000000000000005e55Initial program 56.2%
sqr-neg56.2%
sqr-neg56.2%
associate-*l*56.2%
Simplified56.2%
frac-2neg56.2%
div-inv56.2%
Applied egg-rr56.2%
un-div-inv56.2%
clear-num56.1%
fma-undefine56.1%
add-sqr-sqrt36.7%
hypot-define48.7%
Applied egg-rr48.7%
Taylor expanded in b around -inf 95.7%
*-commutative95.7%
Simplified95.7%
if -1.75000000000000005e55 < b < 5.6e-104Initial program 81.8%
sqr-neg81.8%
sqr-neg81.8%
associate-*l*81.6%
Simplified81.6%
if 5.6e-104 < b Initial program 20.0%
sqr-neg20.0%
sqr-neg20.0%
associate-*l*20.0%
Simplified20.0%
Taylor expanded in b around inf 86.4%
*-commutative86.4%
Simplified86.4%
Final simplification87.4%
(FPCore (a b c)
:precision binary64
(if (<= b -2.3e-35)
(/ 1.0 (* (/ a b) -1.5))
(if (<= b 5.6e-104)
(* (- b (sqrt (* c (* a -3.0)))) (/ 1.0 (* a -3.0)))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.3e-35) {
tmp = 1.0 / ((a / b) * -1.5);
} else if (b <= 5.6e-104) {
tmp = (b - sqrt((c * (a * -3.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.3d-35)) then
tmp = 1.0d0 / ((a / b) * (-1.5d0))
else if (b <= 5.6d-104) then
tmp = (b - sqrt((c * (a * (-3.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.3e-35) {
tmp = 1.0 / ((a / b) * -1.5);
} else if (b <= 5.6e-104) {
tmp = (b - Math.sqrt((c * (a * -3.0)))) * (1.0 / (a * -3.0));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.3e-35: tmp = 1.0 / ((a / b) * -1.5) elif b <= 5.6e-104: tmp = (b - math.sqrt((c * (a * -3.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.3e-35) tmp = Float64(1.0 / Float64(Float64(a / b) * -1.5)); elseif (b <= 5.6e-104) tmp = Float64(Float64(b - sqrt(Float64(c * Float64(a * -3.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.3e-35) tmp = 1.0 / ((a / b) * -1.5); elseif (b <= 5.6e-104) tmp = (b - sqrt((c * (a * -3.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.3e-35], N[(1.0 / N[(N[(a / b), $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-104], N[(N[(b - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $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.3 \cdot 10^{-35}:\\
\;\;\;\;\frac{1}{\frac{a}{b} \cdot -1.5}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-104}:\\
\;\;\;\;\left(b - \sqrt{c \cdot \left(a \cdot -3\right)}\right) \cdot \frac{1}{a \cdot -3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.2999999999999999e-35Initial program 63.1%
sqr-neg63.1%
sqr-neg63.1%
associate-*l*63.1%
Simplified63.1%
frac-2neg63.1%
div-inv63.1%
Applied egg-rr63.1%
un-div-inv63.1%
clear-num63.1%
fma-undefine63.1%
add-sqr-sqrt40.3%
hypot-define50.1%
Applied egg-rr50.1%
Taylor expanded in b around -inf 88.9%
*-commutative88.9%
Simplified88.9%
if -2.2999999999999999e-35 < b < 5.6e-104Initial program 79.0%
sqr-neg79.0%
sqr-neg79.0%
associate-*l*78.8%
Simplified78.8%
frac-2neg78.8%
div-inv78.8%
Applied egg-rr79.0%
Taylor expanded in b around 0 72.5%
*-commutative72.5%
*-commutative72.5%
associate-*r*72.7%
Simplified72.7%
if 5.6e-104 < b Initial program 20.0%
sqr-neg20.0%
sqr-neg20.0%
associate-*l*20.0%
Simplified20.0%
Taylor expanded in b around inf 86.4%
*-commutative86.4%
Simplified86.4%
Final simplification83.6%
(FPCore (a b c)
:precision binary64
(if (<= b -8e-36)
(/ 1.0 (* (/ a b) -1.5))
(if (<= b 2.45e-105)
(* 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 <= -8e-36) {
tmp = 1.0 / ((a / b) * -1.5);
} else if (b <= 2.45e-105) {
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 <= (-8d-36)) then
tmp = 1.0d0 / ((a / b) * (-1.5d0))
else if (b <= 2.45d-105) 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 <= -8e-36) {
tmp = 1.0 / ((a / b) * -1.5);
} else if (b <= 2.45e-105) {
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 <= -8e-36: tmp = 1.0 / ((a / b) * -1.5) elif b <= 2.45e-105: 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 <= -8e-36) tmp = Float64(1.0 / Float64(Float64(a / b) * -1.5)); elseif (b <= 2.45e-105) tmp = Float64(0.3333333333333333 * Float64(Float64(b + sqrt(Float64(Float64(a * 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 <= -8e-36) tmp = 1.0 / ((a / b) * -1.5); elseif (b <= 2.45e-105) 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, -8e-36], N[(1.0 / N[(N[(a / b), $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.45e-105], N[(0.3333333333333333 * N[(N[(b + N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8 \cdot 10^{-36}:\\
\;\;\;\;\frac{1}{\frac{a}{b} \cdot -1.5}\\
\mathbf{elif}\;b \leq 2.45 \cdot 10^{-105}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{b + \sqrt{\left(a \cdot c\right) \cdot -3}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -7.9999999999999995e-36Initial program 63.1%
sqr-neg63.1%
sqr-neg63.1%
associate-*l*63.1%
Simplified63.1%
frac-2neg63.1%
div-inv63.1%
Applied egg-rr63.1%
un-div-inv63.1%
clear-num63.1%
fma-undefine63.1%
add-sqr-sqrt40.3%
hypot-define50.1%
Applied egg-rr50.1%
Taylor expanded in b around -inf 88.9%
*-commutative88.9%
Simplified88.9%
if -7.9999999999999995e-36 < b < 2.45e-105Initial program 79.0%
sqr-neg79.0%
sqr-neg79.0%
associate-*l*78.8%
Simplified78.8%
*-un-lft-identity78.8%
times-frac78.8%
metadata-eval78.8%
add-sqr-sqrt46.9%
sqrt-unprod76.0%
sqr-neg76.0%
sqrt-prod29.3%
add-sqr-sqrt72.0%
fma-neg72.0%
associate-*r*71.9%
*-commutative71.9%
distribute-rgt-neg-in71.9%
*-commutative71.9%
distribute-rgt-neg-in71.9%
metadata-eval71.9%
Applied egg-rr71.9%
Taylor expanded in b around 0 71.9%
if 2.45e-105 < b Initial program 20.0%
sqr-neg20.0%
sqr-neg20.0%
associate-*l*20.0%
Simplified20.0%
Taylor expanded in b around inf 86.4%
*-commutative86.4%
Simplified86.4%
Final simplification83.4%
(FPCore (a b c)
:precision binary64
(if (<= b -7.6e-24)
(/ 1.0 (* (/ a b) -1.5))
(if (<= b 5.6e-104)
(/ (- (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 <= -7.6e-24) {
tmp = 1.0 / ((a / b) * -1.5);
} else if (b <= 5.6e-104) {
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 <= (-7.6d-24)) then
tmp = 1.0d0 / ((a / b) * (-1.5d0))
else if (b <= 5.6d-104) 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 <= -7.6e-24) {
tmp = 1.0 / ((a / b) * -1.5);
} else if (b <= 5.6e-104) {
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 <= -7.6e-24: tmp = 1.0 / ((a / b) * -1.5) elif b <= 5.6e-104: 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 <= -7.6e-24) tmp = Float64(1.0 / Float64(Float64(a / b) * -1.5)); elseif (b <= 5.6e-104) 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 <= -7.6e-24) tmp = 1.0 / ((a / b) * -1.5); elseif (b <= 5.6e-104) 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, -7.6e-24], N[(1.0 / N[(N[(a / b), $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-104], 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 -7.6 \cdot 10^{-24}:\\
\;\;\;\;\frac{1}{\frac{a}{b} \cdot -1.5}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-104}:\\
\;\;\;\;\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 < -7.60000000000000052e-24Initial program 63.1%
sqr-neg63.1%
sqr-neg63.1%
associate-*l*63.1%
Simplified63.1%
frac-2neg63.1%
div-inv63.1%
Applied egg-rr63.1%
un-div-inv63.1%
clear-num63.1%
fma-undefine63.1%
add-sqr-sqrt40.3%
hypot-define50.1%
Applied egg-rr50.1%
Taylor expanded in b around -inf 88.9%
*-commutative88.9%
Simplified88.9%
if -7.60000000000000052e-24 < b < 5.6e-104Initial program 79.0%
sqr-neg79.0%
sqr-neg79.0%
associate-*l*78.8%
Simplified78.8%
Taylor expanded in b around 0 72.5%
if 5.6e-104 < b Initial program 20.0%
sqr-neg20.0%
sqr-neg20.0%
associate-*l*20.0%
Simplified20.0%
Taylor expanded in b around inf 86.4%
*-commutative86.4%
Simplified86.4%
Final simplification83.5%
(FPCore (a b c)
:precision binary64
(if (<= b -4.8e-38)
(/ 1.0 (* (/ a b) -1.5))
(if (<= b 2.2e-104)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.8e-38) {
tmp = 1.0 / ((a / b) * -1.5);
} else if (b <= 2.2e-104) {
tmp = (sqrt((c * (a * -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 <= (-4.8d-38)) then
tmp = 1.0d0 / ((a / b) * (-1.5d0))
else if (b <= 2.2d-104) then
tmp = (sqrt((c * (a * (-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 <= -4.8e-38) {
tmp = 1.0 / ((a / b) * -1.5);
} else if (b <= 2.2e-104) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.8e-38: tmp = 1.0 / ((a / b) * -1.5) elif b <= 2.2e-104: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.8e-38) tmp = Float64(1.0 / Float64(Float64(a / b) * -1.5)); elseif (b <= 2.2e-104) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -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 <= -4.8e-38) tmp = 1.0 / ((a / b) * -1.5); elseif (b <= 2.2e-104) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.8e-38], N[(1.0 / N[(N[(a / b), $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.2e-104], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $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 -4.8 \cdot 10^{-38}:\\
\;\;\;\;\frac{1}{\frac{a}{b} \cdot -1.5}\\
\mathbf{elif}\;b \leq 2.2 \cdot 10^{-104}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.80000000000000044e-38Initial program 63.1%
sqr-neg63.1%
sqr-neg63.1%
associate-*l*63.1%
Simplified63.1%
frac-2neg63.1%
div-inv63.1%
Applied egg-rr63.1%
un-div-inv63.1%
clear-num63.1%
fma-undefine63.1%
add-sqr-sqrt40.3%
hypot-define50.1%
Applied egg-rr50.1%
Taylor expanded in b around -inf 88.9%
*-commutative88.9%
Simplified88.9%
if -4.80000000000000044e-38 < b < 2.20000000000000012e-104Initial program 79.0%
sqr-neg79.0%
sqr-neg79.0%
associate-*l*78.8%
Simplified78.8%
Taylor expanded in b around 0 72.5%
*-commutative72.5%
*-commutative72.5%
associate-*r*72.7%
Simplified72.7%
if 2.20000000000000012e-104 < b Initial program 20.0%
sqr-neg20.0%
sqr-neg20.0%
associate-*l*20.0%
Simplified20.0%
Taylor expanded in b around inf 86.4%
*-commutative86.4%
Simplified86.4%
Final simplification83.6%
(FPCore (a b c) :precision binary64 (if (<= b 1.4e-292) (/ 1.0 (* (/ a b) -1.5)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.4e-292) {
tmp = 1.0 / ((a / b) * -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.4d-292) then
tmp = 1.0d0 / ((a / b) * (-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.4e-292) {
tmp = 1.0 / ((a / b) * -1.5);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.4e-292: tmp = 1.0 / ((a / b) * -1.5) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.4e-292) tmp = Float64(1.0 / Float64(Float64(a / b) * -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.4e-292) tmp = 1.0 / ((a / b) * -1.5); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.4e-292], N[(1.0 / N[(N[(a / b), $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.4 \cdot 10^{-292}:\\
\;\;\;\;\frac{1}{\frac{a}{b} \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.4000000000000001e-292Initial program 70.4%
sqr-neg70.4%
sqr-neg70.4%
associate-*l*70.3%
Simplified70.3%
frac-2neg70.3%
div-inv70.2%
Applied egg-rr70.3%
un-div-inv70.4%
clear-num70.3%
fma-undefine70.3%
add-sqr-sqrt52.9%
hypot-define59.7%
Applied egg-rr59.7%
Taylor expanded in b around -inf 65.4%
*-commutative65.4%
Simplified65.4%
if 1.4000000000000001e-292 < b Initial program 31.2%
sqr-neg31.2%
sqr-neg31.2%
associate-*l*31.1%
Simplified31.1%
Taylor expanded in b around inf 71.9%
*-commutative71.9%
Simplified71.9%
Final simplification68.8%
(FPCore (a b c) :precision binary64 (if (<= b 4e-291) (* b (/ -0.6666666666666666 a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 4e-291) {
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 <= 4d-291) 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 <= 4e-291) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4e-291: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4e-291) 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 <= 4e-291) tmp = b * (-0.6666666666666666 / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4e-291], 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 4 \cdot 10^{-291}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 3.99999999999999985e-291Initial program 70.4%
sqr-neg70.4%
sqr-neg70.4%
associate-*l*70.3%
Simplified70.3%
Taylor expanded in b around -inf 65.3%
*-commutative65.3%
Simplified65.3%
*-commutative65.3%
clear-num65.2%
un-div-inv65.2%
Applied egg-rr65.2%
associate-/r/65.3%
Simplified65.3%
if 3.99999999999999985e-291 < b Initial program 31.2%
sqr-neg31.2%
sqr-neg31.2%
associate-*l*31.1%
Simplified31.1%
Taylor expanded in b around inf 54.4%
associate-*r/54.5%
*-commutative54.5%
associate-*l*54.5%
Simplified54.5%
associate-/l*63.0%
*-commutative63.0%
times-frac71.6%
Applied egg-rr71.6%
*-inverses71.6%
*-lft-identity71.6%
associate-/l/71.7%
*-commutative71.7%
Simplified71.7%
associate-/l*71.6%
*-commutative71.6%
*-commutative71.6%
associate-/r*71.7%
metadata-eval71.7%
Applied egg-rr71.7%
Final simplification68.6%
(FPCore (a b c) :precision binary64 (if (<= b 4e-294) (* (/ b a) -0.6666666666666666) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 4e-294) {
tmp = (b / a) * -0.6666666666666666;
} 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 <= 4d-294) then
tmp = (b / a) * (-0.6666666666666666d0)
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 <= 4e-294) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4e-294: tmp = (b / a) * -0.6666666666666666 else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4e-294) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(c * Float64(-0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 4e-294) tmp = (b / a) * -0.6666666666666666; else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4e-294], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4 \cdot 10^{-294}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 4.00000000000000007e-294Initial program 70.4%
sqr-neg70.4%
sqr-neg70.4%
associate-*l*70.3%
Simplified70.3%
Taylor expanded in b around -inf 65.3%
*-commutative65.3%
Simplified65.3%
if 4.00000000000000007e-294 < b Initial program 31.2%
sqr-neg31.2%
sqr-neg31.2%
associate-*l*31.1%
Simplified31.1%
Taylor expanded in b around inf 54.4%
associate-*r/54.5%
*-commutative54.5%
associate-*l*54.5%
Simplified54.5%
associate-/l*63.0%
*-commutative63.0%
times-frac71.6%
Applied egg-rr71.6%
*-inverses71.6%
*-lft-identity71.6%
associate-/l/71.7%
*-commutative71.7%
Simplified71.7%
associate-/l*71.6%
*-commutative71.6%
*-commutative71.6%
associate-/r*71.7%
metadata-eval71.7%
Applied egg-rr71.7%
Final simplification68.6%
(FPCore (a b c) :precision binary64 (if (<= b 3.1e-294) (* (/ b a) -0.6666666666666666) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.1e-294) {
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 <= 3.1d-294) 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 <= 3.1e-294) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.1e-294: tmp = (b / a) * -0.6666666666666666 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.1e-294) 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 <= 3.1e-294) tmp = (b / a) * -0.6666666666666666; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.1e-294], 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 3.1 \cdot 10^{-294}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 3.10000000000000003e-294Initial program 70.4%
sqr-neg70.4%
sqr-neg70.4%
associate-*l*70.3%
Simplified70.3%
Taylor expanded in b around -inf 65.3%
*-commutative65.3%
Simplified65.3%
if 3.10000000000000003e-294 < b Initial program 31.2%
sqr-neg31.2%
sqr-neg31.2%
associate-*l*31.1%
Simplified31.1%
Taylor expanded in b around inf 71.9%
*-commutative71.9%
Simplified71.9%
Final simplification68.7%
(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 50.2%
sqr-neg50.2%
sqr-neg50.2%
associate-*l*50.1%
Simplified50.1%
Taylor expanded in b around -inf 33.2%
*-commutative33.2%
Simplified33.2%
*-commutative33.2%
clear-num33.2%
un-div-inv33.2%
Applied egg-rr33.2%
associate-/r/33.2%
Simplified33.2%
Final simplification33.2%
herbie shell --seed 2024075
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))