
(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 12 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.3e+92)
(/ b (* a -1.5))
(if (<= b 1.55e-59)
(/ (/ (- b (sqrt (fma -3.0 (* a c) (pow b 2.0)))) a) -3.0)
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.3e+92) {
tmp = b / (a * -1.5);
} else if (b <= 1.55e-59) {
tmp = ((b - sqrt(fma(-3.0, (a * c), pow(b, 2.0)))) / a) / -3.0;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.3e+92) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 1.55e-59) tmp = Float64(Float64(Float64(b - sqrt(fma(-3.0, Float64(a * c), (b ^ 2.0)))) / a) / -3.0); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.3e+92], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.55e-59], N[(N[(N[(b - N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.3 \cdot 10^{+92}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 1.55 \cdot 10^{-59}:\\
\;\;\;\;\frac{\frac{b - \sqrt{\mathsf{fma}\left(-3, a \cdot c, {b}^{2}\right)}}{a}}{-3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.2999999999999999e92Initial program 53.2%
sqr-neg53.2%
sqr-neg53.2%
associate-*l*53.2%
Simplified53.2%
frac-2neg53.2%
div-inv53.1%
Applied egg-rr53.1%
fma-undefine53.1%
unpow253.1%
associate-*l*53.1%
*-commutative53.1%
+-commutative53.1%
fma-define53.1%
associate-/r*53.1%
Simplified53.1%
Taylor expanded in b around -inf 95.4%
*-commutative95.4%
associate-*l/95.3%
associate-/l*95.3%
Simplified95.3%
clear-num95.3%
un-div-inv95.5%
div-inv95.6%
metadata-eval95.6%
Applied egg-rr95.6%
if -1.2999999999999999e92 < b < 1.55e-59Initial program 80.2%
sqr-neg80.2%
sqr-neg80.2%
associate-*l*80.1%
Simplified80.1%
frac-2neg80.1%
div-inv80.1%
Applied egg-rr80.0%
fma-undefine80.0%
unpow280.0%
associate-*l*80.1%
*-commutative80.1%
+-commutative80.1%
fma-define80.1%
associate-/r*80.1%
Simplified80.1%
associate-*r/80.1%
Applied egg-rr80.1%
associate-*r/80.3%
*-rgt-identity80.3%
*-commutative80.3%
Simplified80.3%
if 1.55e-59 < b Initial program 13.4%
sqr-neg13.4%
sqr-neg13.4%
associate-*l*13.4%
Simplified13.4%
Taylor expanded in b around inf 92.4%
*-commutative92.4%
Simplified92.4%
Final simplification87.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.15e+92)
(/ b (* a -1.5))
(if (<= b 9.5e-60)
(/ (/ 1.0 (/ a (- b (sqrt (+ (pow b 2.0) (* c (* a -3.0))))))) -3.0)
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e+92) {
tmp = b / (a * -1.5);
} else if (b <= 9.5e-60) {
tmp = (1.0 / (a / (b - sqrt((pow(b, 2.0) + (c * (a * -3.0))))))) / -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.15d+92)) then
tmp = b / (a * (-1.5d0))
else if (b <= 9.5d-60) then
tmp = (1.0d0 / (a / (b - sqrt(((b ** 2.0d0) + (c * (a * (-3.0d0)))))))) / (-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.15e+92) {
tmp = b / (a * -1.5);
} else if (b <= 9.5e-60) {
tmp = (1.0 / (a / (b - Math.sqrt((Math.pow(b, 2.0) + (c * (a * -3.0))))))) / -3.0;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.15e+92: tmp = b / (a * -1.5) elif b <= 9.5e-60: tmp = (1.0 / (a / (b - math.sqrt((math.pow(b, 2.0) + (c * (a * -3.0))))))) / -3.0 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.15e+92) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 9.5e-60) tmp = Float64(Float64(1.0 / Float64(a / Float64(b - sqrt(Float64((b ^ 2.0) + Float64(c * Float64(a * -3.0))))))) / -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.15e+92) tmp = b / (a * -1.5); elseif (b <= 9.5e-60) tmp = (1.0 / (a / (b - sqrt(((b ^ 2.0) + (c * (a * -3.0))))))) / -3.0; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.15e+92], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9.5e-60], N[(N[(1.0 / N[(a / N[(b - N[Sqrt[N[(N[Power[b, 2.0], $MachinePrecision] + N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / -3.0), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.15 \cdot 10^{+92}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 9.5 \cdot 10^{-60}:\\
\;\;\;\;\frac{\frac{1}{\frac{a}{b - \sqrt{{b}^{2} + c \cdot \left(a \cdot -3\right)}}}}{-3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.14999999999999999e92Initial program 53.2%
sqr-neg53.2%
sqr-neg53.2%
associate-*l*53.2%
Simplified53.2%
frac-2neg53.2%
div-inv53.1%
Applied egg-rr53.1%
fma-undefine53.1%
unpow253.1%
associate-*l*53.1%
*-commutative53.1%
+-commutative53.1%
fma-define53.1%
associate-/r*53.1%
Simplified53.1%
Taylor expanded in b around -inf 95.4%
*-commutative95.4%
associate-*l/95.3%
associate-/l*95.3%
Simplified95.3%
clear-num95.3%
un-div-inv95.5%
div-inv95.6%
metadata-eval95.6%
Applied egg-rr95.6%
if -1.14999999999999999e92 < b < 9.49999999999999958e-60Initial program 80.2%
sqr-neg80.2%
sqr-neg80.2%
associate-*l*80.1%
Simplified80.1%
frac-2neg80.1%
div-inv80.1%
Applied egg-rr80.0%
fma-undefine80.0%
unpow280.0%
associate-*l*80.1%
*-commutative80.1%
+-commutative80.1%
fma-define80.1%
associate-/r*80.1%
Simplified80.1%
associate-*r/80.1%
Applied egg-rr80.1%
associate-*r/80.3%
*-rgt-identity80.3%
*-commutative80.3%
Simplified80.3%
clear-num80.2%
inv-pow80.2%
Applied egg-rr80.2%
unpow-180.2%
Simplified80.2%
fma-undefine80.2%
+-commutative80.2%
*-commutative80.2%
associate-*r*80.2%
Applied egg-rr80.2%
if 9.49999999999999958e-60 < b Initial program 13.4%
sqr-neg13.4%
sqr-neg13.4%
associate-*l*13.4%
Simplified13.4%
Taylor expanded in b around inf 92.4%
*-commutative92.4%
Simplified92.4%
Final simplification87.9%
(FPCore (a b c)
:precision binary64
(if (<= b -3e+98)
(/ b (* a -1.5))
(if (<= b 2.15e-61)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3e+98) {
tmp = b / (a * -1.5);
} else if (b <= 2.15e-61) {
tmp = (sqrt(((b * b) - (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 <= (-3d+98)) then
tmp = b / (a * (-1.5d0))
else if (b <= 2.15d-61) then
tmp = (sqrt(((b * b) - (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 <= -3e+98) {
tmp = b / (a * -1.5);
} else if (b <= 2.15e-61) {
tmp = (Math.sqrt(((b * b) - (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 <= -3e+98: tmp = b / (a * -1.5) elif b <= 2.15e-61: tmp = (math.sqrt(((b * b) - (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 <= -3e+98) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 2.15e-61) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - 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 <= -3e+98) tmp = b / (a * -1.5); elseif (b <= 2.15e-61) tmp = (sqrt(((b * b) - (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, -3e+98], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.15e-61], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $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 -3 \cdot 10^{+98}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 2.15 \cdot 10^{-61}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 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 < -3.0000000000000001e98Initial program 50.1%
sqr-neg50.1%
sqr-neg50.1%
associate-*l*50.1%
Simplified50.1%
frac-2neg50.1%
div-inv50.1%
Applied egg-rr50.1%
fma-undefine50.1%
unpow250.1%
associate-*l*50.1%
*-commutative50.1%
+-commutative50.1%
fma-define50.1%
associate-/r*50.0%
Simplified50.0%
Taylor expanded in b around -inf 95.1%
*-commutative95.1%
associate-*l/95.1%
associate-/l*95.0%
Simplified95.0%
clear-num95.0%
un-div-inv95.2%
div-inv95.3%
metadata-eval95.3%
Applied egg-rr95.3%
if -3.0000000000000001e98 < b < 2.1500000000000002e-61Initial program 80.9%
if 2.1500000000000002e-61 < b Initial program 13.4%
sqr-neg13.4%
sqr-neg13.4%
associate-*l*13.4%
Simplified13.4%
Taylor expanded in b around inf 92.4%
*-commutative92.4%
Simplified92.4%
Final simplification87.9%
(FPCore (a b c)
:precision binary64
(if (<= b -8.2e+98)
(/ b (* a -1.5))
(if (<= b 1.4e-62)
(/ (- (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 <= -8.2e+98) {
tmp = b / (a * -1.5);
} else if (b <= 1.4e-62) {
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 <= (-8.2d+98)) then
tmp = b / (a * (-1.5d0))
else if (b <= 1.4d-62) 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 <= -8.2e+98) {
tmp = b / (a * -1.5);
} else if (b <= 1.4e-62) {
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 <= -8.2e+98: tmp = b / (a * -1.5) elif b <= 1.4e-62: 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 <= -8.2e+98) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 1.4e-62) 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 <= -8.2e+98) tmp = b / (a * -1.5); elseif (b <= 1.4e-62) 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, -8.2e+98], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.4e-62], 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 -8.2 \cdot 10^{+98}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{-62}:\\
\;\;\;\;\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 < -8.2000000000000001e98Initial program 50.1%
sqr-neg50.1%
sqr-neg50.1%
associate-*l*50.1%
Simplified50.1%
frac-2neg50.1%
div-inv50.1%
Applied egg-rr50.1%
fma-undefine50.1%
unpow250.1%
associate-*l*50.1%
*-commutative50.1%
+-commutative50.1%
fma-define50.1%
associate-/r*50.0%
Simplified50.0%
Taylor expanded in b around -inf 95.1%
*-commutative95.1%
associate-*l/95.1%
associate-/l*95.0%
Simplified95.0%
clear-num95.0%
un-div-inv95.2%
div-inv95.3%
metadata-eval95.3%
Applied egg-rr95.3%
if -8.2000000000000001e98 < b < 1.40000000000000001e-62Initial program 80.9%
sqr-neg80.9%
sqr-neg80.9%
associate-*l*80.8%
Simplified80.8%
if 1.40000000000000001e-62 < b Initial program 13.4%
sqr-neg13.4%
sqr-neg13.4%
associate-*l*13.4%
Simplified13.4%
Taylor expanded in b around inf 92.4%
*-commutative92.4%
Simplified92.4%
Final simplification87.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.3e-36)
(+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5))
(if (<= b 7.8e-59)
(/ (/ (- b (sqrt (* -3.0 (* a c)))) a) -3.0)
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.3e-36) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 7.8e-59) {
tmp = ((b - sqrt((-3.0 * (a * c)))) / 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.3d-36)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
else if (b <= 7.8d-59) then
tmp = ((b - sqrt(((-3.0d0) * (a * c)))) / 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.3e-36) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else if (b <= 7.8e-59) {
tmp = ((b - Math.sqrt((-3.0 * (a * c)))) / a) / -3.0;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.3e-36: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) elif b <= 7.8e-59: tmp = ((b - math.sqrt((-3.0 * (a * c)))) / a) / -3.0 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.3e-36) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); elseif (b <= 7.8e-59) tmp = Float64(Float64(Float64(b - sqrt(Float64(-3.0 * Float64(a * c)))) / 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.3e-36) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); elseif (b <= 7.8e-59) tmp = ((b - sqrt((-3.0 * (a * c)))) / a) / -3.0; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.3e-36], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.8e-59], N[(N[(N[(b - N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.3 \cdot 10^{-36}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 7.8 \cdot 10^{-59}:\\
\;\;\;\;\frac{\frac{b - \sqrt{-3 \cdot \left(a \cdot c\right)}}{a}}{-3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.3e-36Initial program 65.4%
sqr-neg65.4%
sqr-neg65.4%
associate-*l*65.4%
Simplified65.4%
Taylor expanded in b around -inf 91.2%
Taylor expanded in c around 0 91.3%
if -1.3e-36 < b < 7.80000000000000038e-59Initial program 75.7%
sqr-neg75.7%
sqr-neg75.7%
associate-*l*75.7%
Simplified75.7%
frac-2neg75.7%
div-inv75.6%
Applied egg-rr75.5%
fma-undefine75.5%
unpow275.5%
associate-*l*75.6%
*-commutative75.6%
+-commutative75.6%
fma-define75.6%
associate-/r*75.7%
Simplified75.7%
associate-*r/75.7%
Applied egg-rr75.7%
associate-*r/75.8%
*-rgt-identity75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in c around inf 66.7%
if 7.80000000000000038e-59 < b Initial program 13.4%
sqr-neg13.4%
sqr-neg13.4%
associate-*l*13.4%
Simplified13.4%
Taylor expanded in b around inf 92.4%
*-commutative92.4%
Simplified92.4%
Final simplification83.8%
(FPCore (a b c) :precision binary64 (if (<= b -1e-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 <= -1e-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 <= (-1d-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 <= -1e-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 <= -1e-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 <= -1e-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 <= -1e-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, -1e-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 -1 \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 < -9.999999999999969e-311Initial program 69.6%
sqr-neg69.6%
sqr-neg69.6%
associate-*l*69.6%
Simplified69.6%
Taylor expanded in b around -inf 68.5%
Taylor expanded in c around 0 70.2%
if -9.999999999999969e-311 < b Initial program 31.8%
sqr-neg31.8%
sqr-neg31.8%
associate-*l*31.7%
Simplified31.7%
Taylor expanded in b around inf 68.7%
*-commutative68.7%
Simplified68.7%
Final simplification69.5%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (/ b (* a -1.5)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
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 <= (-1d-310)) 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 <= -1e-310) {
tmp = b / (a * -1.5);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = b / (a * -1.5) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) 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 <= -1e-310) tmp = b / (a * -1.5); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], 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 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 69.6%
sqr-neg69.6%
sqr-neg69.6%
associate-*l*69.6%
Simplified69.6%
frac-2neg69.6%
div-inv69.6%
Applied egg-rr69.5%
fma-undefine69.5%
unpow269.5%
associate-*l*69.6%
*-commutative69.6%
+-commutative69.6%
fma-define69.6%
associate-/r*69.6%
Simplified69.6%
Taylor expanded in b around -inf 69.5%
*-commutative69.5%
associate-*l/69.5%
associate-/l*69.5%
Simplified69.5%
clear-num69.4%
un-div-inv69.6%
div-inv69.6%
metadata-eval69.6%
Applied egg-rr69.6%
if -9.999999999999969e-311 < b Initial program 31.8%
sqr-neg31.8%
sqr-neg31.8%
associate-*l*31.7%
Simplified31.7%
Taylor expanded in b around inf 68.7%
*-commutative68.7%
Simplified68.7%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (* -0.6666666666666666 (/ b a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
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 <= (-1d-310)) 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 <= -1e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) 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 <= -1e-310) tmp = -0.6666666666666666 * (b / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], 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 -1 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 69.6%
sqr-neg69.6%
sqr-neg69.6%
associate-*l*69.6%
Simplified69.6%
Taylor expanded in b around -inf 69.5%
*-commutative69.5%
Simplified69.5%
if -9.999999999999969e-311 < b Initial program 31.8%
sqr-neg31.8%
sqr-neg31.8%
associate-*l*31.7%
Simplified31.7%
Taylor expanded in b around inf 68.7%
*-commutative68.7%
Simplified68.7%
Final simplification69.1%
(FPCore (a b c) :precision binary64 (if (<= b 1e-309) (* -0.6666666666666666 (/ b a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1e-309) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1d-309) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = c * ((-0.5d0) / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1e-309) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1e-309: tmp = -0.6666666666666666 * (b / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1e-309) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(c * Float64(-0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1e-309) tmp = -0.6666666666666666 * (b / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1e-309], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 10^{-309}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 1.000000000000002e-309Initial program 69.6%
sqr-neg69.6%
sqr-neg69.6%
associate-*l*69.6%
Simplified69.6%
Taylor expanded in b around -inf 69.5%
*-commutative69.5%
Simplified69.5%
if 1.000000000000002e-309 < b Initial program 31.8%
sqr-neg31.8%
sqr-neg31.8%
associate-*l*31.7%
Simplified31.7%
frac-2neg31.7%
div-inv31.7%
Applied egg-rr31.7%
fma-undefine31.7%
unpow231.7%
associate-*l*31.7%
*-commutative31.7%
+-commutative31.7%
fma-define31.7%
associate-/r*31.7%
Simplified31.7%
associate-*r/31.7%
Applied egg-rr31.7%
associate-*r/31.7%
*-rgt-identity31.7%
*-commutative31.7%
Simplified31.7%
Taylor expanded in b around inf 68.7%
associate-*r/68.7%
*-commutative68.7%
associate-/l*68.5%
Simplified68.5%
Final simplification69.1%
(FPCore (a b c) :precision binary64 (if (<= b 1e-309) (* b (/ -0.6666666666666666 a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1e-309) {
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 <= 1d-309) 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 <= 1e-309) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1e-309: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1e-309) 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 <= 1e-309) tmp = b * (-0.6666666666666666 / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1e-309], 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 10^{-309}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 1.000000000000002e-309Initial program 69.6%
sqr-neg69.6%
sqr-neg69.6%
associate-*l*69.6%
Simplified69.6%
frac-2neg69.6%
div-inv69.6%
Applied egg-rr69.5%
fma-undefine69.5%
unpow269.5%
associate-*l*69.6%
*-commutative69.6%
+-commutative69.6%
fma-define69.6%
associate-/r*69.6%
Simplified69.6%
Taylor expanded in b around -inf 69.5%
*-commutative69.5%
associate-*l/69.5%
associate-/l*69.5%
Simplified69.5%
if 1.000000000000002e-309 < b Initial program 31.8%
sqr-neg31.8%
sqr-neg31.8%
associate-*l*31.7%
Simplified31.7%
frac-2neg31.7%
div-inv31.7%
Applied egg-rr31.7%
fma-undefine31.7%
unpow231.7%
associate-*l*31.7%
*-commutative31.7%
+-commutative31.7%
fma-define31.7%
associate-/r*31.7%
Simplified31.7%
associate-*r/31.7%
Applied egg-rr31.7%
associate-*r/31.7%
*-rgt-identity31.7%
*-commutative31.7%
Simplified31.7%
Taylor expanded in b around inf 68.7%
associate-*r/68.7%
*-commutative68.7%
associate-/l*68.5%
Simplified68.5%
(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 52.5%
sqr-neg52.5%
sqr-neg52.5%
associate-*l*52.4%
Simplified52.4%
frac-2neg52.4%
div-inv52.4%
Applied egg-rr52.4%
fma-undefine52.4%
unpow252.4%
associate-*l*52.4%
*-commutative52.4%
+-commutative52.4%
fma-define52.4%
associate-/r*52.4%
Simplified52.4%
Taylor expanded in b around -inf 39.2%
*-commutative39.2%
associate-*l/39.2%
associate-/l*39.2%
Simplified39.2%
(FPCore (a b c) :precision binary64 (* (/ b a) 0.6666666666666666))
double code(double a, double b, double c) {
return (b / a) * 0.6666666666666666;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (b / a) * 0.6666666666666666d0
end function
public static double code(double a, double b, double c) {
return (b / a) * 0.6666666666666666;
}
def code(a, b, c): return (b / a) * 0.6666666666666666
function code(a, b, c) return Float64(Float64(b / a) * 0.6666666666666666) end
function tmp = code(a, b, c) tmp = (b / a) * 0.6666666666666666; end
code[a_, b_, c_] := N[(N[(b / a), $MachinePrecision] * 0.6666666666666666), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{a} \cdot 0.6666666666666666
\end{array}
Initial program 52.5%
sqr-neg52.5%
sqr-neg52.5%
associate-*l*52.4%
Simplified52.4%
*-un-lft-identity52.4%
times-frac52.5%
metadata-eval52.5%
add-sqr-sqrt38.1%
sqrt-unprod50.7%
sqr-neg50.7%
sqrt-prod12.9%
add-sqr-sqrt33.3%
fma-neg33.3%
distribute-lft-neg-in33.3%
*-commutative33.3%
associate-*r*33.3%
metadata-eval33.3%
Applied egg-rr33.3%
Taylor expanded in b around inf 2.4%
Final simplification2.4%
herbie shell --seed 2024143
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))