
(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 -5.2e+100)
(/ (* b -0.6666666666666666) a)
(if (<= b 3.5e-29)
(/ (- (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 <= -5.2e+100) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 3.5e-29) {
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 <= (-5.2d+100)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 3.5d-29) 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 <= -5.2e+100) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 3.5e-29) {
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 <= -5.2e+100: tmp = (b * -0.6666666666666666) / a elif b <= 3.5e-29: 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 <= -5.2e+100) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 3.5e-29) 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 <= -5.2e+100) tmp = (b * -0.6666666666666666) / a; elseif (b <= 3.5e-29) 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, -5.2e+100], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 3.5e-29], 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 -5.2 \cdot 10^{+100}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-29}:\\
\;\;\;\;\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 < -5.2000000000000003e100Initial program 55.9%
add-cube-cbrt55.9%
pow355.9%
Applied egg-rr55.9%
Taylor expanded in b around -inf 96.0%
associate-*r/96.1%
*-commutative96.1%
Simplified96.1%
if -5.2000000000000003e100 < b < 3.4999999999999997e-29Initial program 83.4%
if 3.4999999999999997e-29 < b Initial program 12.2%
Simplified12.2%
Taylor expanded in b around inf 93.4%
associate-*r/93.4%
Applied egg-rr93.4%
Final simplification89.2%
(FPCore (a b c)
:precision binary64
(if (<= b -5.2e+100)
(/ (* b -0.6666666666666666) a)
(if (<= b 1.95e-28)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.2e+100) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.95e-28) {
tmp = (sqrt(((b * b) - (3.0 * (a * 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 <= (-5.2d+100)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 1.95d-28) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * 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 <= -5.2e+100) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.95e-28) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.2e+100: tmp = (b * -0.6666666666666666) / a elif b <= 1.95e-28: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.2e+100) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 1.95e-28) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * 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 <= -5.2e+100) tmp = (b * -0.6666666666666666) / a; elseif (b <= 1.95e-28) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.2e+100], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.95e-28], 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 * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.2 \cdot 10^{+100}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 1.95 \cdot 10^{-28}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.2000000000000003e100Initial program 55.9%
add-cube-cbrt55.9%
pow355.9%
Applied egg-rr55.9%
Taylor expanded in b around -inf 96.0%
associate-*r/96.1%
*-commutative96.1%
Simplified96.1%
if -5.2000000000000003e100 < b < 1.94999999999999999e-28Initial program 83.4%
sqr-neg83.4%
sqr-neg83.4%
associate-*l*83.3%
Simplified83.3%
if 1.94999999999999999e-28 < b Initial program 12.2%
Simplified12.2%
Taylor expanded in b around inf 93.4%
associate-*r/93.4%
Applied egg-rr93.4%
Final simplification89.1%
(FPCore (a b c)
:precision binary64
(if (<= b -1.75e-62)
(/ (/ b a) -1.5)
(if (<= b 5.8e-29)
(/ (- (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 <= -1.75e-62) {
tmp = (b / a) / -1.5;
} else if (b <= 5.8e-29) {
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 <= (-1.75d-62)) then
tmp = (b / a) / (-1.5d0)
else if (b <= 5.8d-29) 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 <= -1.75e-62) {
tmp = (b / a) / -1.5;
} else if (b <= 5.8e-29) {
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 <= -1.75e-62: tmp = (b / a) / -1.5 elif b <= 5.8e-29: 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 <= -1.75e-62) tmp = Float64(Float64(b / a) / -1.5); elseif (b <= 5.8e-29) 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 <= -1.75e-62) tmp = (b / a) / -1.5; elseif (b <= 5.8e-29) 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, -1.75e-62], N[(N[(b / a), $MachinePrecision] / -1.5), $MachinePrecision], If[LessEqual[b, 5.8e-29], 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 -1.75 \cdot 10^{-62}:\\
\;\;\;\;\frac{\frac{b}{a}}{-1.5}\\
\mathbf{elif}\;b \leq 5.8 \cdot 10^{-29}:\\
\;\;\;\;\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 < -1.7500000000000001e-62Initial program 72.0%
Simplified72.1%
Taylor expanded in b around -inf 87.6%
*-commutative87.6%
Simplified87.6%
add-cube-cbrt86.6%
pow386.7%
*-commutative86.7%
times-frac86.6%
metadata-eval86.6%
Applied egg-rr86.6%
rem-cube-cbrt87.5%
clear-num87.4%
div-inv87.6%
metadata-eval87.6%
associate-/r*87.5%
*-commutative87.5%
associate-/r*87.6%
clear-num87.6%
Applied egg-rr87.6%
if -1.7500000000000001e-62 < b < 5.80000000000000048e-29Initial program 78.4%
Simplified78.1%
Taylor expanded in b around 0 73.0%
associate-*r*73.2%
*-commutative73.2%
Simplified73.2%
if 5.80000000000000048e-29 < b Initial program 12.2%
Simplified12.2%
Taylor expanded in b around inf 93.4%
associate-*r/93.4%
Applied egg-rr93.4%
Final simplification84.4%
(FPCore (a b c)
:precision binary64
(if (<= b -1.15e-62)
(/ (/ b a) -1.5)
(if (<= b 6.5e-29)
(/ (- (sqrt (* (* a c) -3.0)) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e-62) {
tmp = (b / a) / -1.5;
} else if (b <= 6.5e-29) {
tmp = (sqrt(((a * c) * -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 <= (-1.15d-62)) then
tmp = (b / a) / (-1.5d0)
else if (b <= 6.5d-29) then
tmp = (sqrt(((a * c) * (-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 <= -1.15e-62) {
tmp = (b / a) / -1.5;
} else if (b <= 6.5e-29) {
tmp = (Math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.15e-62: tmp = (b / a) / -1.5 elif b <= 6.5e-29: tmp = (math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.15e-62) tmp = Float64(Float64(b / a) / -1.5); elseif (b <= 6.5e-29) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -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 <= -1.15e-62) tmp = (b / a) / -1.5; elseif (b <= 6.5e-29) tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.15e-62], N[(N[(b / a), $MachinePrecision] / -1.5), $MachinePrecision], If[LessEqual[b, 6.5e-29], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $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 -1.15 \cdot 10^{-62}:\\
\;\;\;\;\frac{\frac{b}{a}}{-1.5}\\
\mathbf{elif}\;b \leq 6.5 \cdot 10^{-29}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.15e-62Initial program 72.0%
Simplified72.1%
Taylor expanded in b around -inf 87.6%
*-commutative87.6%
Simplified87.6%
add-cube-cbrt86.6%
pow386.7%
*-commutative86.7%
times-frac86.6%
metadata-eval86.6%
Applied egg-rr86.6%
rem-cube-cbrt87.5%
clear-num87.4%
div-inv87.6%
metadata-eval87.6%
associate-/r*87.5%
*-commutative87.5%
associate-/r*87.6%
clear-num87.6%
Applied egg-rr87.6%
if -1.15e-62 < b < 6.5e-29Initial program 78.4%
Simplified78.1%
Taylor expanded in b around 0 73.0%
if 6.5e-29 < b Initial program 12.2%
Simplified12.2%
Taylor expanded in b around inf 93.4%
associate-*r/93.4%
Applied egg-rr93.4%
Final simplification84.4%
(FPCore (a b c) :precision binary64 (if (<= b -1.65e-62) (/ (/ b a) -1.5) (if (<= b 1.2e-29) (/ (sqrt (* a (* c -3.0))) (* a 3.0)) (/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.65e-62) {
tmp = (b / a) / -1.5;
} else if (b <= 1.2e-29) {
tmp = sqrt((a * (c * -3.0))) / (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 <= (-1.65d-62)) then
tmp = (b / a) / (-1.5d0)
else if (b <= 1.2d-29) then
tmp = sqrt((a * (c * (-3.0d0)))) / (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 <= -1.65e-62) {
tmp = (b / a) / -1.5;
} else if (b <= 1.2e-29) {
tmp = Math.sqrt((a * (c * -3.0))) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.65e-62: tmp = (b / a) / -1.5 elif b <= 1.2e-29: tmp = math.sqrt((a * (c * -3.0))) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.65e-62) tmp = Float64(Float64(b / a) / -1.5); elseif (b <= 1.2e-29) tmp = Float64(sqrt(Float64(a * Float64(c * -3.0))) / 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 <= -1.65e-62) tmp = (b / a) / -1.5; elseif (b <= 1.2e-29) tmp = sqrt((a * (c * -3.0))) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.65e-62], N[(N[(b / a), $MachinePrecision] / -1.5), $MachinePrecision], If[LessEqual[b, 1.2e-29], N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $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 -1.65 \cdot 10^{-62}:\\
\;\;\;\;\frac{\frac{b}{a}}{-1.5}\\
\mathbf{elif}\;b \leq 1.2 \cdot 10^{-29}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)}}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.65000000000000002e-62Initial program 72.0%
Simplified72.1%
Taylor expanded in b around -inf 87.6%
*-commutative87.6%
Simplified87.6%
add-cube-cbrt86.6%
pow386.7%
*-commutative86.7%
times-frac86.6%
metadata-eval86.6%
Applied egg-rr86.6%
rem-cube-cbrt87.5%
clear-num87.4%
div-inv87.6%
metadata-eval87.6%
associate-/r*87.5%
*-commutative87.5%
associate-/r*87.6%
clear-num87.6%
Applied egg-rr87.6%
if -1.65000000000000002e-62 < b < 1.19999999999999996e-29Initial program 78.4%
add-cube-cbrt77.7%
pow377.7%
Applied egg-rr77.7%
Taylor expanded in a around -inf 0.0%
mul-1-neg0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt71.6%
distribute-lft-neg-in71.6%
metadata-eval71.6%
rem-cube-cbrt71.8%
Simplified71.8%
if 1.19999999999999996e-29 < b Initial program 12.2%
Simplified12.2%
Taylor expanded in b around inf 93.4%
associate-*r/93.4%
Applied egg-rr93.4%
Final simplification83.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.7e-99)
(/ (/ b a) -1.5)
(if (<= b 8.6e-68)
(* (sqrt (* c (/ -3.0 a))) (- -0.3333333333333333))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.7e-99) {
tmp = (b / a) / -1.5;
} else if (b <= 8.6e-68) {
tmp = sqrt((c * (-3.0 / a))) * -(-0.3333333333333333);
} 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.7d-99)) then
tmp = (b / a) / (-1.5d0)
else if (b <= 8.6d-68) then
tmp = sqrt((c * ((-3.0d0) / a))) * -(-0.3333333333333333d0)
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.7e-99) {
tmp = (b / a) / -1.5;
} else if (b <= 8.6e-68) {
tmp = Math.sqrt((c * (-3.0 / a))) * -(-0.3333333333333333);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.7e-99: tmp = (b / a) / -1.5 elif b <= 8.6e-68: tmp = math.sqrt((c * (-3.0 / a))) * -(-0.3333333333333333) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.7e-99) tmp = Float64(Float64(b / a) / -1.5); elseif (b <= 8.6e-68) tmp = Float64(sqrt(Float64(c * Float64(-3.0 / a))) * Float64(-(-0.3333333333333333))); 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.7e-99) tmp = (b / a) / -1.5; elseif (b <= 8.6e-68) tmp = sqrt((c * (-3.0 / a))) * -(-0.3333333333333333); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.7e-99], N[(N[(b / a), $MachinePrecision] / -1.5), $MachinePrecision], If[LessEqual[b, 8.6e-68], N[(N[Sqrt[N[(c * N[(-3.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (--0.3333333333333333)), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.7 \cdot 10^{-99}:\\
\;\;\;\;\frac{\frac{b}{a}}{-1.5}\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{-68}:\\
\;\;\;\;\sqrt{c \cdot \frac{-3}{a}} \cdot \left(--0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.70000000000000003e-99Initial program 74.7%
Simplified74.7%
Taylor expanded in b around -inf 82.7%
*-commutative82.7%
Simplified82.7%
add-cube-cbrt81.8%
pow381.8%
*-commutative81.8%
times-frac81.8%
metadata-eval81.8%
Applied egg-rr81.8%
rem-cube-cbrt82.6%
clear-num82.6%
div-inv82.7%
metadata-eval82.7%
associate-/r*82.6%
*-commutative82.6%
associate-/r*82.8%
clear-num82.8%
Applied egg-rr82.8%
if -1.70000000000000003e-99 < b < 8.6000000000000002e-68Initial program 76.6%
add-cube-cbrt76.0%
pow376.0%
Applied egg-rr76.0%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt40.5%
rem-cube-cbrt40.7%
associate-/l*40.8%
Simplified40.8%
if 8.6000000000000002e-68 < b Initial program 16.0%
Simplified16.0%
Taylor expanded in b around inf 89.5%
associate-*r/89.5%
Applied egg-rr89.5%
Final simplification72.9%
(FPCore (a b c) :precision binary64 (if (<= b 4.4e-307) (/ (* b -0.6666666666666666) a) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 4.4e-307) {
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 <= 4.4d-307) 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 <= 4.4e-307) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4.4e-307: tmp = (b * -0.6666666666666666) / a else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4.4e-307) tmp = Float64(Float64(b * -0.6666666666666666) / 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 <= 4.4e-307) tmp = (b * -0.6666666666666666) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4.4e-307], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.4 \cdot 10^{-307}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 4.4e-307Initial program 77.2%
add-cube-cbrt76.9%
pow377.0%
Applied egg-rr77.0%
Taylor expanded in b around -inf 64.6%
associate-*r/64.7%
*-commutative64.7%
Simplified64.7%
if 4.4e-307 < b Initial program 32.7%
Simplified32.6%
Taylor expanded in b around inf 67.0%
associate-*r/67.0%
Applied egg-rr67.0%
Final simplification65.9%
(FPCore (a b c) :precision binary64 (if (<= b 1.32e-306) (/ -0.6666666666666666 (/ a b)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.32e-306) {
tmp = -0.6666666666666666 / (a / 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 <= 1.32d-306) then
tmp = (-0.6666666666666666d0) / (a / 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 <= 1.32e-306) {
tmp = -0.6666666666666666 / (a / b);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.32e-306: tmp = -0.6666666666666666 / (a / b) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.32e-306) tmp = Float64(-0.6666666666666666 / Float64(a / 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 <= 1.32e-306) tmp = -0.6666666666666666 / (a / b); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.32e-306], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.32 \cdot 10^{-306}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 1.32e-306Initial program 77.2%
Simplified77.1%
Taylor expanded in b around -inf 64.7%
*-commutative64.7%
Simplified64.7%
add-cube-cbrt64.0%
pow364.0%
*-commutative64.0%
times-frac64.0%
metadata-eval64.0%
Applied egg-rr64.0%
rem-cube-cbrt64.6%
clear-num64.6%
div-inv64.7%
Applied egg-rr64.7%
if 1.32e-306 < b Initial program 32.7%
Simplified32.6%
Taylor expanded in b around inf 67.0%
associate-*r/67.0%
Applied egg-rr67.0%
Final simplification65.8%
(FPCore (a b c) :precision binary64 (if (<= b 4.3e-308) (/ -0.6666666666666666 (/ a b)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 4.3e-308) {
tmp = -0.6666666666666666 / (a / b);
} 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 <= 4.3d-308) then
tmp = (-0.6666666666666666d0) / (a / b)
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 <= 4.3e-308) {
tmp = -0.6666666666666666 / (a / b);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4.3e-308: tmp = -0.6666666666666666 / (a / b) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4.3e-308) tmp = Float64(-0.6666666666666666 / Float64(a / b)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 4.3e-308) tmp = -0.6666666666666666 / (a / b); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4.3e-308], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.3 \cdot 10^{-308}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 4.3000000000000002e-308Initial program 77.2%
Simplified77.1%
Taylor expanded in b around -inf 64.7%
*-commutative64.7%
Simplified64.7%
add-cube-cbrt64.0%
pow364.0%
*-commutative64.0%
times-frac64.0%
metadata-eval64.0%
Applied egg-rr64.0%
rem-cube-cbrt64.6%
clear-num64.6%
div-inv64.7%
Applied egg-rr64.7%
if 4.3000000000000002e-308 < b Initial program 32.7%
Simplified32.6%
Taylor expanded in b around inf 67.0%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (* b (/ -0.6666666666666666 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = b * (-0.6666666666666666 / a);
} 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 <= (-2d-310)) then
tmp = b * ((-0.6666666666666666d0) / a)
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 <= -2e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 77.2%
add-cube-cbrt76.9%
pow377.0%
Applied egg-rr77.0%
div-inv76.9%
neg-mul-176.9%
fma-define76.9%
rem-cube-cbrt77.1%
pow277.1%
Applied egg-rr77.1%
associate-/r*77.0%
metadata-eval77.0%
metadata-eval77.0%
associate-*r/77.0%
*-commutative77.0%
associate-*r/77.0%
metadata-eval77.0%
associate-*r*77.0%
cancel-sign-sub-inv77.0%
unpow277.0%
metadata-eval77.0%
fma-undefine77.0%
*-commutative77.0%
associate-*r*77.0%
Simplified77.0%
Taylor expanded in b around -inf 64.6%
*-commutative64.6%
associate-*l/64.7%
associate-*r/64.6%
Simplified64.6%
if -1.999999999999994e-310 < b Initial program 32.7%
Simplified32.6%
Taylor expanded in b around inf 67.0%
(FPCore (a b c) :precision binary64 (* -0.5 (/ c b)))
double code(double a, double b, double c) {
return -0.5 * (c / b);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-0.5d0) * (c / b)
end function
public static double code(double a, double b, double c) {
return -0.5 * (c / b);
}
def code(a, b, c): return -0.5 * (c / b)
function code(a, b, c) return Float64(-0.5 * Float64(c / b)) end
function tmp = code(a, b, c) tmp = -0.5 * (c / b); end
code[a_, b_, c_] := N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \frac{c}{b}
\end{array}
Initial program 55.3%
Simplified55.2%
Taylor expanded in b around inf 34.1%
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
return 0.0;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 0.0d0
end function
public static double code(double a, double b, double c) {
return 0.0;
}
def code(a, b, c): return 0.0
function code(a, b, c) return 0.0 end
function tmp = code(a, b, c) tmp = 0.0; end
code[a_, b_, c_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 55.3%
add-cube-cbrt55.1%
pow355.1%
Applied egg-rr55.1%
div-inv55.0%
neg-mul-155.0%
fma-define55.0%
rem-cube-cbrt55.2%
pow255.2%
Applied egg-rr55.2%
associate-/r*55.2%
metadata-eval55.2%
metadata-eval55.2%
associate-*r/55.1%
*-commutative55.1%
associate-*r/55.2%
metadata-eval55.2%
associate-*r*55.2%
cancel-sign-sub-inv55.2%
unpow255.2%
metadata-eval55.2%
fma-undefine55.2%
*-commutative55.2%
associate-*r*55.2%
Simplified55.2%
Taylor expanded in a around 0 10.5%
associate-*r/10.5%
distribute-rgt1-in10.5%
metadata-eval10.5%
mul0-lft10.5%
metadata-eval10.5%
Simplified10.5%
Taylor expanded in a around 0 10.5%
herbie shell --seed 2024129
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))