
(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 10 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 -2e+151)
(/ b (* a -1.5))
(if (<= b 2.5e-80)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e+151) {
tmp = b / (a * -1.5);
} else if (b <= 2.5e-80) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} 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 <= (-2d+151)) then
tmp = b / (a * (-1.5d0))
else if (b <= 2.5d-80) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
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 <= -2e+151) {
tmp = b / (a * -1.5);
} else if (b <= 2.5e-80) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e+151: tmp = b / (a * -1.5) elif b <= 2.5e-80: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e+151) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 2.5e-80) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e+151) tmp = b / (a * -1.5); elseif (b <= 2.5e-80) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e+151], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.5e-80], 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 * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{+151}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 2.5 \cdot 10^{-80}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -2.00000000000000003e151Initial program 54.9%
Applied egg-rr60.3%
Taylor expanded in b around -inf 99.8%
associate-*r/99.7%
*-commutative99.7%
associate-/l*99.6%
Simplified99.6%
clear-num99.6%
div-inv99.7%
metadata-eval99.7%
un-div-inv99.9%
Applied egg-rr99.9%
if -2.00000000000000003e151 < b < 2.5e-80Initial program 85.4%
if 2.5e-80 < b Initial program 11.9%
Taylor expanded in b around inf 72.2%
associate-*r/72.2%
associate-*r*72.3%
Simplified72.3%
Taylor expanded in a around 0 88.7%
associate-*r/88.7%
*-commutative88.7%
Simplified88.7%
Final simplification88.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.75e-51)
(- (* 0.6666666666666666 (/ b (- a))) (* -0.5 (/ c b)))
(if (<= b 2.05e-79)
(* (- b (sqrt (* a (* c -3.0)))) (/ -0.3333333333333333 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.75e-51) {
tmp = (0.6666666666666666 * (b / -a)) - (-0.5 * (c / b));
} else if (b <= 2.05e-79) {
tmp = (b - sqrt((a * (c * -3.0)))) * (-0.3333333333333333 / 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.75d-51)) then
tmp = (0.6666666666666666d0 * (b / -a)) - ((-0.5d0) * (c / b))
else if (b <= 2.05d-79) then
tmp = (b - sqrt((a * (c * (-3.0d0))))) * ((-0.3333333333333333d0) / 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.75e-51) {
tmp = (0.6666666666666666 * (b / -a)) - (-0.5 * (c / b));
} else if (b <= 2.05e-79) {
tmp = (b - Math.sqrt((a * (c * -3.0)))) * (-0.3333333333333333 / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.75e-51: tmp = (0.6666666666666666 * (b / -a)) - (-0.5 * (c / b)) elif b <= 2.05e-79: tmp = (b - math.sqrt((a * (c * -3.0)))) * (-0.3333333333333333 / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.75e-51) tmp = Float64(Float64(0.6666666666666666 * Float64(b / Float64(-a))) - Float64(-0.5 * Float64(c / b))); elseif (b <= 2.05e-79) tmp = Float64(Float64(b - sqrt(Float64(a * Float64(c * -3.0)))) * Float64(-0.3333333333333333 / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.75e-51) tmp = (0.6666666666666666 * (b / -a)) - (-0.5 * (c / b)); elseif (b <= 2.05e-79) tmp = (b - sqrt((a * (c * -3.0)))) * (-0.3333333333333333 / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.75e-51], N[(N[(0.6666666666666666 * N[(b / (-a)), $MachinePrecision]), $MachinePrecision] - N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.05e-79], N[(N[(b - N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.75 \cdot 10^{-51}:\\
\;\;\;\;0.6666666666666666 \cdot \frac{b}{-a} - -0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 2.05 \cdot 10^{-79}:\\
\;\;\;\;\left(b - \sqrt{a \cdot \left(c \cdot -3\right)}\right) \cdot \frac{-0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.7499999999999999e-51Initial program 76.5%
Taylor expanded in b around -inf 93.4%
Taylor expanded in c around 0 93.5%
if -1.7499999999999999e-51 < b < 2.04999999999999997e-79Initial program 78.8%
Taylor expanded in b around 0 75.2%
associate-*r*75.4%
*-commutative75.4%
*-commutative75.4%
Simplified75.4%
*-commutative75.4%
sqrt-prod47.6%
Applied egg-rr47.6%
frac-2neg47.6%
div-inv47.6%
distribute-neg-in47.6%
add-sqr-sqrt27.7%
sqrt-unprod47.6%
sqr-neg47.6%
sqrt-prod19.9%
add-sqr-sqrt47.1%
sub-neg47.1%
add-sqr-sqrt27.2%
sqrt-unprod47.1%
sqr-neg47.1%
sqrt-prod19.9%
add-sqr-sqrt47.6%
*-commutative47.6%
sqrt-unprod75.2%
distribute-lft-neg-in75.2%
metadata-eval75.2%
*-commutative75.2%
Applied egg-rr75.2%
associate-*r*75.1%
*-commutative75.1%
associate-*l*73.7%
*-commutative73.7%
associate-/r*73.8%
metadata-eval73.8%
Simplified73.8%
if 2.04999999999999997e-79 < b Initial program 11.9%
Taylor expanded in b around inf 72.2%
associate-*r/72.2%
associate-*r*72.3%
Simplified72.3%
Taylor expanded in a around 0 88.7%
associate-*r/88.7%
*-commutative88.7%
Simplified88.7%
Final simplification86.6%
(FPCore (a b c)
:precision binary64
(if (<= b -8.5e-39)
(- (* 0.6666666666666666 (/ b (- a))) (* -0.5 (/ c b)))
(if (<= b 1.5e-77)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8.5e-39) {
tmp = (0.6666666666666666 * (b / -a)) - (-0.5 * (c / b));
} else if (b <= 1.5e-77) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} 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 <= (-8.5d-39)) then
tmp = (0.6666666666666666d0 * (b / -a)) - ((-0.5d0) * (c / b))
else if (b <= 1.5d-77) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (a * 3.0d0)
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 <= -8.5e-39) {
tmp = (0.6666666666666666 * (b / -a)) - (-0.5 * (c / b));
} else if (b <= 1.5e-77) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.5e-39: tmp = (0.6666666666666666 * (b / -a)) - (-0.5 * (c / b)) elif b <= 1.5e-77: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8.5e-39) tmp = Float64(Float64(0.6666666666666666 * Float64(b / Float64(-a))) - Float64(-0.5 * Float64(c / b))); elseif (b <= 1.5e-77) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8.5e-39) tmp = (0.6666666666666666 * (b / -a)) - (-0.5 * (c / b)); elseif (b <= 1.5e-77) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8.5e-39], N[(N[(0.6666666666666666 * N[(b / (-a)), $MachinePrecision]), $MachinePrecision] - N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.5e-77], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.5 \cdot 10^{-39}:\\
\;\;\;\;0.6666666666666666 \cdot \frac{b}{-a} - -0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.5 \cdot 10^{-77}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -8.5000000000000005e-39Initial program 76.5%
Taylor expanded in b around -inf 93.4%
Taylor expanded in c around 0 93.5%
if -8.5000000000000005e-39 < b < 1.50000000000000008e-77Initial program 78.8%
Taylor expanded in b around 0 75.2%
associate-*r*75.4%
*-commutative75.4%
*-commutative75.4%
Simplified75.4%
*-commutative75.4%
sqrt-prod47.6%
Applied egg-rr47.6%
+-commutative47.6%
unsub-neg47.6%
*-commutative47.6%
sqrt-unprod75.4%
Applied egg-rr75.4%
if 1.50000000000000008e-77 < b Initial program 11.9%
Taylor expanded in b around inf 72.2%
associate-*r/72.2%
associate-*r*72.3%
Simplified72.3%
Taylor expanded in a around 0 88.7%
associate-*r/88.7%
*-commutative88.7%
Simplified88.7%
Final simplification87.0%
(FPCore (a b c) :precision binary64 (if (<= b -1e-309) (- (* 0.6666666666666666 (/ b (- a))) (* -0.5 (/ c b))) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-309) {
tmp = (0.6666666666666666 * (b / -a)) - (-0.5 * (c / b));
} 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)) - ((-0.5d0) * (c / b))
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)) - (-0.5 * (c / b));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-309: tmp = (0.6666666666666666 * (b / -a)) - (-0.5 * (c / b)) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-309) tmp = Float64(Float64(0.6666666666666666 * Float64(b / Float64(-a))) - Float64(-0.5 * Float64(c / b))); else tmp = Float64(Float64(c * -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)) - (-0.5 * (c / b)); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-309], N[(N[(0.6666666666666666 * N[(b / (-a)), $MachinePrecision]), $MachinePrecision] - N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\
\;\;\;\;0.6666666666666666 \cdot \frac{b}{-a} - -0.5 \cdot \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.000000000000002e-309Initial program 78.6%
Taylor expanded in b around -inf 71.6%
Taylor expanded in c around 0 72.7%
if -1.000000000000002e-309 < b Initial program 27.0%
Taylor expanded in b around inf 55.6%
associate-*r/55.5%
associate-*r*55.6%
Simplified55.6%
Taylor expanded in a around 0 68.1%
associate-*r/68.1%
*-commutative68.1%
Simplified68.1%
Final simplification70.3%
(FPCore (a b c) :precision binary64 (if (<= b 3.4e-292) (* b (/ -0.6666666666666666 a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.4e-292) {
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 <= 3.4d-292) 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 <= 3.4e-292) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.4e-292: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.4e-292) 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 <= 3.4e-292) tmp = b * (-0.6666666666666666 / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.4e-292], 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 3.4 \cdot 10^{-292}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 3.40000000000000017e-292Initial program 78.0%
Applied egg-rr61.2%
Taylor expanded in b around -inf 71.9%
associate-*r/71.9%
*-commutative71.9%
associate-/l*71.8%
Simplified71.8%
if 3.40000000000000017e-292 < b Initial program 27.2%
Taylor expanded in c around 0 63.0%
associate-*r/63.0%
metadata-eval63.0%
Simplified63.0%
Taylor expanded in a around 0 68.4%
Final simplification70.0%
(FPCore (a b c) :precision binary64 (if (<= b 3.1e-292) (* (/ b a) -0.6666666666666666) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.1e-292) {
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 <= 3.1d-292) 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 <= 3.1e-292) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.1e-292: tmp = (b / a) * -0.6666666666666666 else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.1e-292) 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 <= 3.1e-292) tmp = (b / a) * -0.6666666666666666; else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.1e-292], 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 3.1 \cdot 10^{-292}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 3.0999999999999999e-292Initial program 78.0%
Taylor expanded in b around -inf 71.9%
*-commutative71.9%
Simplified71.9%
if 3.0999999999999999e-292 < b Initial program 27.2%
Taylor expanded in c around 0 63.0%
associate-*r/63.0%
metadata-eval63.0%
Simplified63.0%
Taylor expanded in a around 0 68.4%
Final simplification70.1%
(FPCore (a b c) :precision binary64 (if (<= b 3.1e-292) (* (/ b a) -0.6666666666666666) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.1e-292) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = -0.5 * (c / 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 <= 3.1d-292) then
tmp = (b / a) * (-0.6666666666666666d0)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 3.1e-292) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.1e-292: tmp = (b / a) * -0.6666666666666666 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.1e-292) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3.1e-292) tmp = (b / a) * -0.6666666666666666; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.1e-292], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.1 \cdot 10^{-292}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 3.0999999999999999e-292Initial program 78.0%
Taylor expanded in b around -inf 71.9%
*-commutative71.9%
Simplified71.9%
if 3.0999999999999999e-292 < b Initial program 27.2%
Taylor expanded in b around inf 68.6%
*-commutative68.6%
Simplified68.6%
Final simplification70.2%
(FPCore (a b c) :precision binary64 (if (<= b 3.4e-292) (/ b (* a -1.5)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.4e-292) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 * (c / 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 <= 3.4d-292) then
tmp = b / (a * (-1.5d0))
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 3.4e-292) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.4e-292: tmp = b / (a * -1.5) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.4e-292) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3.4e-292) tmp = b / (a * -1.5); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.4e-292], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.4 \cdot 10^{-292}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 3.40000000000000017e-292Initial program 78.0%
Applied egg-rr61.2%
Taylor expanded in b around -inf 71.9%
associate-*r/71.9%
*-commutative71.9%
associate-/l*71.8%
Simplified71.8%
clear-num71.7%
div-inv71.8%
metadata-eval71.8%
un-div-inv72.0%
Applied egg-rr72.0%
if 3.40000000000000017e-292 < b Initial program 27.2%
Taylor expanded in b around inf 68.6%
*-commutative68.6%
Simplified68.6%
Final simplification70.2%
(FPCore (a b c) :precision binary64 (if (<= b 3.1e-292) (/ b (* a -1.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.1e-292) {
tmp = b / (a * -1.5);
} 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 <= 3.1d-292) then
tmp = b / (a * (-1.5d0))
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 <= 3.1e-292) {
tmp = b / (a * -1.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.1e-292: tmp = b / (a * -1.5) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.1e-292) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3.1e-292) tmp = b / (a * -1.5); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.1e-292], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.1 \cdot 10^{-292}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 3.0999999999999999e-292Initial program 78.0%
Applied egg-rr61.2%
Taylor expanded in b around -inf 71.9%
associate-*r/71.9%
*-commutative71.9%
associate-/l*71.8%
Simplified71.8%
clear-num71.7%
div-inv71.8%
metadata-eval71.8%
un-div-inv72.0%
Applied egg-rr72.0%
if 3.0999999999999999e-292 < b Initial program 27.2%
Taylor expanded in b around inf 56.0%
associate-*r/55.9%
associate-*r*56.0%
Simplified56.0%
Taylor expanded in a around 0 68.6%
associate-*r/68.6%
*-commutative68.6%
Simplified68.6%
Final simplification70.2%
(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 51.6%
Applied egg-rr40.4%
Taylor expanded in b around -inf 35.9%
associate-*r/35.9%
*-commutative35.9%
associate-/l*35.9%
Simplified35.9%
Final simplification35.9%
herbie shell --seed 2024071
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))