
(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.5e+146)
(/
(* b (+ 2.0 (expm1 (log1p (* -1.5 (* a (* c (pow b -2.0))))))))
(* a (- 3.0)))
(if (<= b 1.1e-53)
(/ (- (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 <= -2.5e+146) {
tmp = (b * (2.0 + expm1(log1p((-1.5 * (a * (c * pow(b, -2.0)))))))) / (a * -3.0);
} else if (b <= 1.1e-53) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.5e+146) {
tmp = (b * (2.0 + Math.expm1(Math.log1p((-1.5 * (a * (c * Math.pow(b, -2.0)))))))) / (a * -3.0);
} else if (b <= 1.1e-53) {
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 <= -2.5e+146: tmp = (b * (2.0 + math.expm1(math.log1p((-1.5 * (a * (c * math.pow(b, -2.0)))))))) / (a * -3.0) elif b <= 1.1e-53: 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 <= -2.5e+146) tmp = Float64(Float64(b * Float64(2.0 + expm1(log1p(Float64(-1.5 * Float64(a * Float64(c * (b ^ -2.0)))))))) / Float64(a * Float64(-3.0))); elseif (b <= 1.1e-53) 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
code[a_, b_, c_] := If[LessEqual[b, -2.5e+146], N[(N[(b * N[(2.0 + N[(Exp[N[Log[1 + N[(-1.5 * N[(a * N[(c * N[Power[b, -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * (-3.0)), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.1e-53], 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 -2.5 \cdot 10^{+146}:\\
\;\;\;\;\frac{b \cdot \left(2 + \mathsf{expm1}\left(\mathsf{log1p}\left(-1.5 \cdot \left(a \cdot \left(c \cdot {b}^{-2}\right)\right)\right)\right)\right)}{a \cdot \left(-3\right)}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{-53}:\\
\;\;\;\;\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 < -2.4999999999999999e146Initial program 32.1%
sqr-neg32.1%
sqr-neg32.1%
associate-*l*32.1%
Simplified32.1%
Taylor expanded in b around -inf 75.5%
associate-*r*75.5%
mul-1-neg75.5%
associate-/l*88.7%
Simplified88.7%
expm1-log1p-u88.7%
expm1-undefine88.7%
div-inv88.7%
pow-flip88.7%
metadata-eval88.7%
Applied egg-rr88.7%
expm1-define88.7%
Simplified88.7%
if -2.4999999999999999e146 < b < 1.10000000000000009e-53Initial program 83.2%
if 1.10000000000000009e-53 < b Initial program 12.1%
sqr-neg12.1%
sqr-neg12.1%
associate-*l*12.1%
Simplified12.1%
Taylor expanded in b around inf 88.1%
*-commutative88.1%
Simplified88.1%
Final simplification85.9%
(FPCore (a b c)
:precision binary64
(if (<= b -4e+146)
(/ b (* -1.5 a))
(if (<= b 3.2e-53)
(/ (- (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 <= -4e+146) {
tmp = b / (-1.5 * a);
} else if (b <= 3.2e-53) {
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 <= (-4d+146)) then
tmp = b / ((-1.5d0) * a)
else if (b <= 3.2d-53) 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 <= -4e+146) {
tmp = b / (-1.5 * a);
} else if (b <= 3.2e-53) {
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 <= -4e+146: tmp = b / (-1.5 * a) elif b <= 3.2e-53: 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 <= -4e+146) tmp = Float64(b / Float64(-1.5 * a)); elseif (b <= 3.2e-53) 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 <= -4e+146) tmp = b / (-1.5 * a); elseif (b <= 3.2e-53) 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, -4e+146], N[(b / N[(-1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.2e-53], 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 -4 \cdot 10^{+146}:\\
\;\;\;\;\frac{b}{-1.5 \cdot a}\\
\mathbf{elif}\;b \leq 3.2 \cdot 10^{-53}:\\
\;\;\;\;\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.99999999999999973e146Initial program 32.1%
sqr-neg32.1%
sqr-neg32.1%
associate-*l*32.1%
Simplified32.1%
frac-2neg32.1%
div-inv32.1%
Applied egg-rr32.1%
fma-undefine32.1%
unpow232.1%
associate-*l*32.1%
*-commutative32.1%
+-commutative32.1%
fma-define32.1%
associate-/r*32.1%
Simplified32.1%
Taylor expanded in b around -inf 88.4%
associate-*r/88.4%
*-commutative88.4%
associate-/l*88.6%
Simplified88.6%
clear-num88.5%
un-div-inv88.5%
div-inv88.7%
metadata-eval88.7%
Applied egg-rr88.7%
if -3.99999999999999973e146 < b < 3.2000000000000001e-53Initial program 83.2%
if 3.2000000000000001e-53 < b Initial program 12.1%
sqr-neg12.1%
sqr-neg12.1%
associate-*l*12.1%
Simplified12.1%
Taylor expanded in b around inf 88.1%
*-commutative88.1%
Simplified88.1%
Final simplification85.9%
(FPCore (a b c)
:precision binary64
(if (<= b -2.5e+147)
(/ b (* -1.5 a))
(if (<= b 1.3e-54)
(/ (- (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.5e+147) {
tmp = b / (-1.5 * a);
} else if (b <= 1.3e-54) {
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.5d+147)) then
tmp = b / ((-1.5d0) * a)
else if (b <= 1.3d-54) 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.5e+147) {
tmp = b / (-1.5 * a);
} else if (b <= 1.3e-54) {
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.5e+147: tmp = b / (-1.5 * a) elif b <= 1.3e-54: 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.5e+147) tmp = Float64(b / Float64(-1.5 * a)); elseif (b <= 1.3e-54) 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.5e+147) tmp = b / (-1.5 * a); elseif (b <= 1.3e-54) 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.5e+147], N[(b / N[(-1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.3e-54], 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.5 \cdot 10^{+147}:\\
\;\;\;\;\frac{b}{-1.5 \cdot a}\\
\mathbf{elif}\;b \leq 1.3 \cdot 10^{-54}:\\
\;\;\;\;\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.5000000000000001e147Initial program 32.1%
sqr-neg32.1%
sqr-neg32.1%
associate-*l*32.1%
Simplified32.1%
frac-2neg32.1%
div-inv32.1%
Applied egg-rr32.1%
fma-undefine32.1%
unpow232.1%
associate-*l*32.1%
*-commutative32.1%
+-commutative32.1%
fma-define32.1%
associate-/r*32.1%
Simplified32.1%
Taylor expanded in b around -inf 88.4%
associate-*r/88.4%
*-commutative88.4%
associate-/l*88.6%
Simplified88.6%
clear-num88.5%
un-div-inv88.5%
div-inv88.7%
metadata-eval88.7%
Applied egg-rr88.7%
if -2.5000000000000001e147 < b < 1.30000000000000001e-54Initial program 83.2%
sqr-neg83.2%
sqr-neg83.2%
associate-*l*83.1%
Simplified83.1%
if 1.30000000000000001e-54 < b Initial program 12.1%
sqr-neg12.1%
sqr-neg12.1%
associate-*l*12.1%
Simplified12.1%
Taylor expanded in b around inf 88.1%
*-commutative88.1%
Simplified88.1%
Final simplification85.8%
(FPCore (a b c)
:precision binary64
(if (<= b -3.1e-72)
(/ b (* -1.5 a))
(if (<= b 1.26e-55)
(/ (- (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 <= -3.1e-72) {
tmp = b / (-1.5 * a);
} else if (b <= 1.26e-55) {
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 <= (-3.1d-72)) then
tmp = b / ((-1.5d0) * a)
else if (b <= 1.26d-55) 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 <= -3.1e-72) {
tmp = b / (-1.5 * a);
} else if (b <= 1.26e-55) {
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 <= -3.1e-72: tmp = b / (-1.5 * a) elif b <= 1.26e-55: 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 <= -3.1e-72) tmp = Float64(b / Float64(-1.5 * a)); elseif (b <= 1.26e-55) tmp = Float64(Float64(sqrt(Float64(a * Float64(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 <= -3.1e-72) tmp = b / (-1.5 * a); elseif (b <= 1.26e-55) 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, -3.1e-72], N[(b / N[(-1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.26e-55], N[(N[(N[Sqrt[N[(a * N[(c * -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 -3.1 \cdot 10^{-72}:\\
\;\;\;\;\frac{b}{-1.5 \cdot a}\\
\mathbf{elif}\;b \leq 1.26 \cdot 10^{-55}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.0999999999999998e-72Initial program 65.2%
sqr-neg65.2%
sqr-neg65.2%
associate-*l*65.2%
Simplified65.2%
frac-2neg65.2%
div-inv65.1%
Applied egg-rr65.1%
fma-undefine65.1%
unpow265.1%
associate-*l*65.1%
*-commutative65.1%
+-commutative65.1%
fma-define65.1%
associate-/r*65.2%
Simplified65.2%
Taylor expanded in b around -inf 83.0%
associate-*r/83.0%
*-commutative83.0%
associate-/l*83.1%
Simplified83.1%
clear-num82.9%
un-div-inv83.0%
div-inv83.2%
metadata-eval83.2%
Applied egg-rr83.2%
if -3.0999999999999998e-72 < b < 1.2599999999999999e-55Initial program 76.4%
sqr-neg76.4%
sqr-neg76.4%
associate-*l*76.3%
Simplified76.3%
Taylor expanded in b around 0 75.4%
*-commutative75.4%
associate-*l*75.4%
*-commutative75.4%
*-commutative75.4%
Simplified75.4%
if 1.2599999999999999e-55 < b Initial program 12.1%
sqr-neg12.1%
sqr-neg12.1%
associate-*l*12.1%
Simplified12.1%
Taylor expanded in b around inf 88.1%
*-commutative88.1%
Simplified88.1%
Final simplification82.8%
(FPCore (a b c)
:precision binary64
(if (<= b -6.6e-71)
(/ b (* -1.5 a))
(if (<= b 1.05e-54)
(/ (- (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 <= -6.6e-71) {
tmp = b / (-1.5 * a);
} else if (b <= 1.05e-54) {
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 <= (-6.6d-71)) then
tmp = b / ((-1.5d0) * a)
else if (b <= 1.05d-54) 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 <= -6.6e-71) {
tmp = b / (-1.5 * a);
} else if (b <= 1.05e-54) {
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 <= -6.6e-71: tmp = b / (-1.5 * a) elif b <= 1.05e-54: 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 <= -6.6e-71) tmp = Float64(b / Float64(-1.5 * a)); elseif (b <= 1.05e-54) 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 <= -6.6e-71) tmp = b / (-1.5 * a); elseif (b <= 1.05e-54) 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, -6.6e-71], N[(b / N[(-1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.05e-54], 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.6 \cdot 10^{-71}:\\
\;\;\;\;\frac{b}{-1.5 \cdot a}\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{-54}:\\
\;\;\;\;\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.6000000000000003e-71Initial program 65.2%
sqr-neg65.2%
sqr-neg65.2%
associate-*l*65.2%
Simplified65.2%
frac-2neg65.2%
div-inv65.1%
Applied egg-rr65.1%
fma-undefine65.1%
unpow265.1%
associate-*l*65.1%
*-commutative65.1%
+-commutative65.1%
fma-define65.1%
associate-/r*65.2%
Simplified65.2%
Taylor expanded in b around -inf 83.0%
associate-*r/83.0%
*-commutative83.0%
associate-/l*83.1%
Simplified83.1%
clear-num82.9%
un-div-inv83.0%
div-inv83.2%
metadata-eval83.2%
Applied egg-rr83.2%
if -6.6000000000000003e-71 < b < 1.05e-54Initial program 76.4%
sqr-neg76.4%
sqr-neg76.4%
associate-*l*76.3%
Simplified76.3%
Taylor expanded in b around 0 75.4%
if 1.05e-54 < b Initial program 12.1%
sqr-neg12.1%
sqr-neg12.1%
associate-*l*12.1%
Simplified12.1%
Taylor expanded in b around inf 88.1%
*-commutative88.1%
Simplified88.1%
Final simplification82.8%
(FPCore (a b c) :precision binary64 (if (<= b 5.5e-267) (/ (* b -2.0) (* a 3.0)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 5.5e-267) {
tmp = (b * -2.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 <= 5.5d-267) then
tmp = (b * (-2.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 <= 5.5e-267) {
tmp = (b * -2.0) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5.5e-267: tmp = (b * -2.0) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5.5e-267) tmp = Float64(Float64(b * -2.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 <= 5.5e-267) tmp = (b * -2.0) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5.5e-267], N[(N[(b * -2.0), $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.5 \cdot 10^{-267}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 5.4999999999999999e-267Initial program 70.9%
sqr-neg70.9%
sqr-neg70.9%
associate-*l*70.8%
Simplified70.8%
Taylor expanded in b around -inf 60.5%
*-commutative60.5%
Simplified60.5%
if 5.4999999999999999e-267 < b Initial program 26.6%
sqr-neg26.6%
sqr-neg26.6%
associate-*l*26.5%
Simplified26.5%
Taylor expanded in b around inf 70.3%
*-commutative70.3%
Simplified70.3%
Final simplification65.3%
(FPCore (a b c) :precision binary64 (if (<= b 4.5e-267) (/ b (* -1.5 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 4.5e-267) {
tmp = b / (-1.5 * 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 <= 4.5d-267) then
tmp = b / ((-1.5d0) * 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 <= 4.5e-267) {
tmp = b / (-1.5 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4.5e-267: tmp = b / (-1.5 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4.5e-267) tmp = Float64(b / Float64(-1.5 * 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 <= 4.5e-267) tmp = b / (-1.5 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4.5e-267], N[(b / N[(-1.5 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.5 \cdot 10^{-267}:\\
\;\;\;\;\frac{b}{-1.5 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 4.4999999999999999e-267Initial program 70.9%
sqr-neg70.9%
sqr-neg70.9%
associate-*l*70.8%
Simplified70.8%
frac-2neg70.8%
div-inv70.8%
Applied egg-rr70.8%
fma-undefine70.8%
unpow270.8%
associate-*l*70.8%
*-commutative70.8%
+-commutative70.8%
fma-define70.8%
associate-/r*70.9%
Simplified70.9%
Taylor expanded in b around -inf 60.4%
associate-*r/60.4%
*-commutative60.4%
associate-/l*60.4%
Simplified60.4%
clear-num60.3%
un-div-inv60.3%
div-inv60.5%
metadata-eval60.5%
Applied egg-rr60.5%
if 4.4999999999999999e-267 < b Initial program 26.6%
sqr-neg26.6%
sqr-neg26.6%
associate-*l*26.5%
Simplified26.5%
Taylor expanded in b around inf 70.3%
*-commutative70.3%
Simplified70.3%
Final simplification65.3%
(FPCore (a b c) :precision binary64 (if (<= b 4.5e-267) (* b (/ -0.6666666666666666 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 4.5e-267) {
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 <= 4.5d-267) 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 <= 4.5e-267) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4.5e-267: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4.5e-267) 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 <= 4.5e-267) tmp = b * (-0.6666666666666666 / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4.5e-267], 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 4.5 \cdot 10^{-267}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 4.4999999999999999e-267Initial program 70.9%
sqr-neg70.9%
sqr-neg70.9%
associate-*l*70.8%
Simplified70.8%
frac-2neg70.8%
div-inv70.8%
Applied egg-rr70.8%
fma-undefine70.8%
unpow270.8%
associate-*l*70.8%
*-commutative70.8%
+-commutative70.8%
fma-define70.8%
associate-/r*70.9%
Simplified70.9%
Taylor expanded in b around -inf 60.4%
associate-*r/60.4%
*-commutative60.4%
associate-/l*60.4%
Simplified60.4%
if 4.4999999999999999e-267 < b Initial program 26.6%
sqr-neg26.6%
sqr-neg26.6%
associate-*l*26.5%
Simplified26.5%
Taylor expanded in b around inf 70.3%
*-commutative70.3%
Simplified70.3%
(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 48.9%
sqr-neg48.9%
sqr-neg48.9%
associate-*l*48.9%
Simplified48.9%
frac-2neg48.9%
div-inv48.8%
Applied egg-rr48.8%
fma-undefine48.8%
unpow248.8%
associate-*l*48.8%
*-commutative48.8%
+-commutative48.8%
fma-define48.8%
associate-/r*48.8%
Simplified48.8%
Taylor expanded in b around -inf 31.6%
associate-*r/31.6%
*-commutative31.6%
associate-/l*31.6%
Simplified31.6%
herbie shell --seed 2024163
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))