
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -1.65e+89)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 1.22e-33)
(/ (- (sqrt (- (* b b) (* 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.65e+89) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.22e-33) {
tmp = (sqrt(((b * b) - (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.65d+89)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 1.22d-33) then
tmp = (sqrt(((b * b) - (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.65e+89) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.22e-33) {
tmp = (Math.sqrt(((b * b) - (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.65e+89: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 1.22e-33: tmp = (math.sqrt(((b * b) - (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.65e+89) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 1.22e-33) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - 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.65e+89) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 1.22e-33) tmp = (sqrt(((b * b) - (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.65e+89], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.22e-33], 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 * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.65 \cdot 10^{+89}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.22 \cdot 10^{-33}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 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.64999999999999987e89Initial program 51.9%
Taylor expanded in b around -inf 95.0%
if -1.64999999999999987e89 < b < 1.22e-33Initial program 80.9%
if 1.22e-33 < b Initial program 8.2%
Taylor expanded in b around inf 91.2%
associate-*r/91.2%
Simplified91.2%
Final simplification87.4%
(FPCore (a b c)
:precision binary64
(if (<= b -3.15e-100)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 8.2e-34)
(* (/ 1.0 (* a -3.0)) (- b (sqrt (* c (* a -3.0)))))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.15e-100) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 8.2e-34) {
tmp = (1.0 / (a * -3.0)) * (b - sqrt((c * (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 <= (-3.15d-100)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 8.2d-34) then
tmp = (1.0d0 / (a * (-3.0d0))) * (b - sqrt((c * (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 <= -3.15e-100) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 8.2e-34) {
tmp = (1.0 / (a * -3.0)) * (b - Math.sqrt((c * (a * -3.0))));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.15e-100: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 8.2e-34: tmp = (1.0 / (a * -3.0)) * (b - math.sqrt((c * (a * -3.0)))) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.15e-100) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 8.2e-34) tmp = Float64(Float64(1.0 / Float64(a * -3.0)) * Float64(b - sqrt(Float64(c * 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 <= -3.15e-100) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 8.2e-34) tmp = (1.0 / (a * -3.0)) * (b - sqrt((c * (a * -3.0)))); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.15e-100], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.2e-34], N[(N[(1.0 / N[(a * -3.0), $MachinePrecision]), $MachinePrecision] * N[(b - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.15 \cdot 10^{-100}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 8.2 \cdot 10^{-34}:\\
\;\;\;\;\frac{1}{a \cdot -3} \cdot \left(b - \sqrt{c \cdot \left(a \cdot -3\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.1499999999999998e-100Initial program 70.2%
Taylor expanded in b around -inf 85.1%
if -3.1499999999999998e-100 < b < 8.2000000000000007e-34Initial program 72.1%
Taylor expanded in b around 0 70.7%
*-commutative70.7%
associate-*l*69.5%
Simplified69.5%
frac-2neg69.5%
div-inv69.5%
distribute-neg-in69.5%
add-sqr-sqrt30.4%
sqrt-unprod69.0%
sqr-neg69.0%
sqrt-unprod39.4%
add-sqr-sqrt68.8%
sub-neg68.8%
add-sqr-sqrt29.4%
sqrt-unprod68.7%
sqr-neg68.7%
sqrt-unprod39.2%
add-sqr-sqrt69.5%
distribute-lft-neg-in69.5%
metadata-eval69.5%
associate-/l/69.3%
div-inv69.3%
metadata-eval69.3%
Applied egg-rr69.3%
*-commutative69.3%
associate-*l/69.4%
metadata-eval69.4%
associate-*r*70.6%
*-commutative70.6%
associate-*l*70.7%
Simplified70.7%
clear-num70.7%
inv-pow70.7%
div-inv70.9%
metadata-eval70.9%
Applied egg-rr70.9%
unpow-170.9%
Simplified70.9%
if 8.2000000000000007e-34 < b Initial program 8.2%
Taylor expanded in b around inf 91.2%
associate-*r/91.2%
Simplified91.2%
Final simplification83.0%
(FPCore (a b c)
:precision binary64
(if (<= b -1.6e-124)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 1.02e-33)
(* 0.3333333333333333 (/ (+ b (sqrt (* a (* c -3.0)))) a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.6e-124) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.02e-33) {
tmp = 0.3333333333333333 * ((b + sqrt((a * (c * -3.0)))) / 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.6d-124)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 1.02d-33) then
tmp = 0.3333333333333333d0 * ((b + sqrt((a * (c * (-3.0d0))))) / 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.6e-124) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.02e-33) {
tmp = 0.3333333333333333 * ((b + Math.sqrt((a * (c * -3.0)))) / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.6e-124: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 1.02e-33: tmp = 0.3333333333333333 * ((b + math.sqrt((a * (c * -3.0)))) / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.6e-124) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 1.02e-33) tmp = Float64(0.3333333333333333 * Float64(Float64(b + sqrt(Float64(a * Float64(c * -3.0)))) / 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.6e-124) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 1.02e-33) tmp = 0.3333333333333333 * ((b + sqrt((a * (c * -3.0)))) / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.6e-124], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.02e-33], N[(0.3333333333333333 * N[(N[(b + N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{-124}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.02 \cdot 10^{-33}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{b + \sqrt{a \cdot \left(c \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.60000000000000002e-124Initial program 70.2%
Taylor expanded in b around -inf 83.8%
if -1.60000000000000002e-124 < b < 1.02e-33Initial program 72.3%
Taylor expanded in b around 0 72.0%
*-commutative72.0%
associate-*l*70.7%
Simplified70.7%
*-un-lft-identity70.7%
times-frac70.7%
metadata-eval70.7%
+-commutative70.7%
add-sqr-sqrt29.8%
sqrt-unprod70.1%
sqr-neg70.1%
sqrt-unprod41.1%
add-sqr-sqrt70.2%
Applied egg-rr70.2%
if 1.02e-33 < b Initial program 8.2%
Taylor expanded in b around inf 91.2%
associate-*r/91.2%
Simplified91.2%
Final simplification82.4%
(FPCore (a b c)
:precision binary64
(if (<= b -3e-100)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 4.5e-33)
(* (- b (sqrt (* c (* a -3.0)))) (/ -0.3333333333333333 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3e-100) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 4.5e-33) {
tmp = (b - sqrt((c * (a * -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 <= (-3d-100)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 4.5d-33) then
tmp = (b - sqrt((c * (a * (-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 <= -3e-100) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 4.5e-33) {
tmp = (b - Math.sqrt((c * (a * -3.0)))) * (-0.3333333333333333 / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3e-100: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 4.5e-33: tmp = (b - math.sqrt((c * (a * -3.0)))) * (-0.3333333333333333 / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3e-100) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 4.5e-33) tmp = Float64(Float64(b - sqrt(Float64(c * Float64(a * -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 <= -3e-100) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 4.5e-33) tmp = (b - sqrt((c * (a * -3.0)))) * (-0.3333333333333333 / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3e-100], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.5e-33], N[(N[(b - N[Sqrt[N[(c * N[(a * -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 -3 \cdot 10^{-100}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-33}:\\
\;\;\;\;\left(b - \sqrt{c \cdot \left(a \cdot -3\right)}\right) \cdot \frac{-0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.0000000000000001e-100Initial program 70.2%
Taylor expanded in b around -inf 85.1%
if -3.0000000000000001e-100 < b < 4.49999999999999991e-33Initial program 72.1%
Taylor expanded in b around 0 70.7%
*-commutative70.7%
associate-*l*69.5%
Simplified69.5%
frac-2neg69.5%
div-inv69.5%
distribute-neg-in69.5%
add-sqr-sqrt30.4%
sqrt-unprod69.0%
sqr-neg69.0%
sqrt-unprod39.4%
add-sqr-sqrt68.8%
sub-neg68.8%
add-sqr-sqrt29.4%
sqrt-unprod68.7%
sqr-neg68.7%
sqrt-unprod39.2%
add-sqr-sqrt69.5%
distribute-lft-neg-in69.5%
metadata-eval69.5%
associate-/l/69.3%
div-inv69.3%
metadata-eval69.3%
Applied egg-rr69.3%
*-commutative69.3%
associate-*l/69.4%
metadata-eval69.4%
associate-*r*70.6%
*-commutative70.6%
associate-*l*70.7%
Simplified70.7%
if 4.49999999999999991e-33 < b Initial program 8.2%
Taylor expanded in b around inf 91.2%
associate-*r/91.2%
Simplified91.2%
Final simplification83.0%
(FPCore (a b c)
:precision binary64
(if (<= b -6.7e-102)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 8.2e-34)
(/ (- (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 <= -6.7e-102) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 8.2e-34) {
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 <= (-6.7d-102)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 8.2d-34) 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 <= -6.7e-102) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 8.2e-34) {
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 <= -6.7e-102: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 8.2e-34: 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 <= -6.7e-102) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 8.2e-34) 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 <= -6.7e-102) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 8.2e-34) 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, -6.7e-102], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.2e-34], 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 -6.7 \cdot 10^{-102}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 8.2 \cdot 10^{-34}:\\
\;\;\;\;\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 < -6.7e-102Initial program 70.2%
Taylor expanded in b around -inf 85.1%
if -6.7e-102 < b < 8.2000000000000007e-34Initial program 72.1%
Taylor expanded in b around 0 70.7%
associate-*r*70.8%
*-commutative70.8%
*-commutative70.8%
Simplified70.8%
if 8.2000000000000007e-34 < b Initial program 8.2%
Taylor expanded in b around inf 91.2%
associate-*r/91.2%
Simplified91.2%
Final simplification83.0%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b))) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
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 <= -5e-310: 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 <= -5e-310) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / 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 <= -5e-310) 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, -5e-310], 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 -5 \cdot 10^{-310}:\\
\;\;\;\;-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 < -4.999999999999985e-310Initial program 69.9%
Taylor expanded in b around -inf 67.9%
if -4.999999999999985e-310 < b Initial program 30.1%
Taylor expanded in b around inf 66.8%
associate-*r/66.8%
Simplified66.8%
Final simplification67.4%
(FPCore (a b c) :precision binary64 (if (<= b 1.5e-287) (/ -0.6666666666666666 (/ a b)) (/ -0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.5e-287) {
tmp = -0.6666666666666666 / (a / b);
} else {
tmp = -0.5 / (b / c);
}
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.5d-287) then
tmp = (-0.6666666666666666d0) / (a / b)
else
tmp = (-0.5d0) / (b / c)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.5e-287) {
tmp = -0.6666666666666666 / (a / b);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.5e-287: tmp = -0.6666666666666666 / (a / b) else: tmp = -0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.5e-287) tmp = Float64(-0.6666666666666666 / Float64(a / b)); else tmp = Float64(-0.5 / Float64(b / c)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.5e-287) tmp = -0.6666666666666666 / (a / b); else tmp = -0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.5e-287], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], N[(-0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.5 \cdot 10^{-287}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < 1.49999999999999996e-287Initial program 70.1%
Taylor expanded in b around -inf 67.1%
*-commutative67.1%
Simplified67.1%
*-commutative67.1%
add-cbrt-cube37.8%
pow1/319.3%
pow319.3%
*-commutative19.3%
associate-*l/19.3%
Applied egg-rr19.3%
unpow1/337.7%
rem-cbrt-cube67.2%
*-commutative67.2%
associate-/l*67.1%
Applied egg-rr67.1%
if 1.49999999999999996e-287 < b Initial program 29.5%
Taylor expanded in b around inf 67.3%
associate-*r/67.3%
associate-/l*66.5%
Simplified66.5%
Final simplification66.9%
(FPCore (a b c) :precision binary64 (if (<= b 1.5e-287) (/ b (* a -1.5)) (/ -0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.5e-287) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 / (b / c);
}
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.5d-287) then
tmp = b / (a * (-1.5d0))
else
tmp = (-0.5d0) / (b / c)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.5e-287) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.5e-287: tmp = b / (a * -1.5) else: tmp = -0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.5e-287) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(-0.5 / Float64(b / c)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.5e-287) tmp = b / (a * -1.5); else tmp = -0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.5e-287], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(-0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.5 \cdot 10^{-287}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < 1.49999999999999996e-287Initial program 70.1%
Applied egg-rr66.3%
associate-/r*66.3%
Simplified66.3%
Taylor expanded in b around -inf 67.2%
*-commutative67.2%
Simplified67.2%
Taylor expanded in b around 0 67.1%
*-commutative67.1%
metadata-eval67.1%
times-frac66.6%
associate-/l*66.6%
associate-/l*67.2%
metadata-eval67.2%
Simplified67.2%
Taylor expanded in a around 0 67.3%
*-commutative67.3%
Simplified67.3%
if 1.49999999999999996e-287 < b Initial program 29.5%
Taylor expanded in b around inf 67.3%
associate-*r/67.3%
associate-/l*66.5%
Simplified66.5%
Final simplification66.9%
(FPCore (a b c) :precision binary64 (if (<= b 2.8e-287) (/ b (* a -1.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.8e-287) {
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 <= 2.8d-287) 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 <= 2.8e-287) {
tmp = b / (a * -1.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.8e-287: tmp = b / (a * -1.5) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.8e-287) 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 <= 2.8e-287) tmp = b / (a * -1.5); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.8e-287], 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 2.8 \cdot 10^{-287}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 2.8000000000000002e-287Initial program 70.1%
Applied egg-rr66.3%
associate-/r*66.3%
Simplified66.3%
Taylor expanded in b around -inf 67.2%
*-commutative67.2%
Simplified67.2%
Taylor expanded in b around 0 67.1%
*-commutative67.1%
metadata-eval67.1%
times-frac66.6%
associate-/l*66.6%
associate-/l*67.2%
metadata-eval67.2%
Simplified67.2%
Taylor expanded in a around 0 67.3%
*-commutative67.3%
Simplified67.3%
if 2.8000000000000002e-287 < b Initial program 29.5%
Taylor expanded in b around inf 67.3%
associate-*r/67.3%
Simplified67.3%
Final simplification67.3%
(FPCore (a b c) :precision binary64 (* -0.6666666666666666 (/ b a)))
double code(double a, double b, double c) {
return -0.6666666666666666 * (b / a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-0.6666666666666666d0) * (b / a)
end function
public static double code(double a, double b, double c) {
return -0.6666666666666666 * (b / a);
}
def code(a, b, c): return -0.6666666666666666 * (b / a)
function code(a, b, c) return Float64(-0.6666666666666666 * Float64(b / a)) end
function tmp = code(a, b, c) tmp = -0.6666666666666666 * (b / a); end
code[a_, b_, c_] := N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.6666666666666666 \cdot \frac{b}{a}
\end{array}
Initial program 51.4%
Taylor expanded in b around -inf 37.4%
*-commutative37.4%
Simplified37.4%
Final simplification37.4%
(FPCore (a b c) :precision binary64 (/ -0.6666666666666666 (/ a b)))
double code(double a, double b, double c) {
return -0.6666666666666666 / (a / 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.6666666666666666d0) / (a / b)
end function
public static double code(double a, double b, double c) {
return -0.6666666666666666 / (a / b);
}
def code(a, b, c): return -0.6666666666666666 / (a / b)
function code(a, b, c) return Float64(-0.6666666666666666 / Float64(a / b)) end
function tmp = code(a, b, c) tmp = -0.6666666666666666 / (a / b); end
code[a_, b_, c_] := N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-0.6666666666666666}{\frac{a}{b}}
\end{array}
Initial program 51.4%
Taylor expanded in b around -inf 37.4%
*-commutative37.4%
Simplified37.4%
*-commutative37.4%
add-cbrt-cube21.5%
pow1/311.4%
pow311.4%
*-commutative11.4%
associate-*l/11.4%
Applied egg-rr11.4%
unpow1/321.5%
rem-cbrt-cube37.4%
*-commutative37.4%
associate-/l*37.4%
Applied egg-rr37.4%
Final simplification37.4%
herbie shell --seed 2024024
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))