
(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 -24000000.0)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 6.5e+86)
(/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
(* (/ (* c (/ a b)) a) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -24000000.0) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 6.5e+86) {
tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = ((c * (a / b)) / a) * -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 <= (-24000000.0d0)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 6.5d+86) then
tmp = (sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (3.0d0 * a)
else
tmp = ((c * (a / b)) / a) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -24000000.0) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 6.5e+86) {
tmp = (Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = ((c * (a / b)) / a) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -24000000.0: tmp = (b * -2.0) / (3.0 * a) elif b <= 6.5e+86: tmp = (math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a) else: tmp = ((c * (a / b)) / a) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -24000000.0) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 6.5e+86) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(Float64(c * Float64(a / b)) / a) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -24000000.0) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 6.5e+86) tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a); else tmp = ((c * (a / b)) / a) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -24000000.0], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.5e+86], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -24000000:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 6.5 \cdot 10^{+86}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{a}{b}}{a} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.4e7Initial program 64.7%
Taylor expanded in b around -inf 94.2%
*-commutative94.2%
Simplified94.2%
if -2.4e7 < b < 6.49999999999999996e86Initial program 74.3%
if 6.49999999999999996e86 < b Initial program 24.8%
Taylor expanded in b around inf 67.5%
associate-/l*73.6%
associate-/r/76.1%
Simplified76.1%
*-commutative76.1%
*-commutative76.1%
times-frac76.2%
*-commutative76.2%
metadata-eval76.2%
Applied egg-rr76.2%
Final simplification80.0%
(FPCore (a b c)
:precision binary64
(if (<= b -3e-55)
(* b (/ -0.6666666666666666 a))
(if (<= b 8e-18)
(* 0.3333333333333333 (/ (+ b (sqrt (* c (* a -3.0)))) a))
(* (/ (* c (/ a b)) a) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3e-55) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 8e-18) {
tmp = 0.3333333333333333 * ((b + sqrt((c * (a * -3.0)))) / a);
} else {
tmp = ((c * (a / b)) / a) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-3d-55)) then
tmp = b * ((-0.6666666666666666d0) / a)
else if (b <= 8d-18) then
tmp = 0.3333333333333333d0 * ((b + sqrt((c * (a * (-3.0d0))))) / a)
else
tmp = ((c * (a / b)) / a) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3e-55) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 8e-18) {
tmp = 0.3333333333333333 * ((b + Math.sqrt((c * (a * -3.0)))) / a);
} else {
tmp = ((c * (a / b)) / a) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3e-55: tmp = b * (-0.6666666666666666 / a) elif b <= 8e-18: tmp = 0.3333333333333333 * ((b + math.sqrt((c * (a * -3.0)))) / a) else: tmp = ((c * (a / b)) / a) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3e-55) tmp = Float64(b * Float64(-0.6666666666666666 / a)); elseif (b <= 8e-18) tmp = Float64(0.3333333333333333 * Float64(Float64(b + sqrt(Float64(c * Float64(a * -3.0)))) / a)); else tmp = Float64(Float64(Float64(c * Float64(a / b)) / a) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3e-55) tmp = b * (-0.6666666666666666 / a); elseif (b <= 8e-18) tmp = 0.3333333333333333 * ((b + sqrt((c * (a * -3.0)))) / a); else tmp = ((c * (a / b)) / a) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3e-55], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e-18], N[(0.3333333333333333 * N[(N[(b + N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3 \cdot 10^{-55}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 8 \cdot 10^{-18}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{b + \sqrt{c \cdot \left(a \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{a}{b}}{a} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.00000000000000016e-55Initial program 70.5%
Applied egg-rr57.6%
sub-neg57.6%
distribute-rgt-out--57.6%
Simplified57.6%
expm1-log1p-u38.9%
Applied egg-rr38.9%
Taylor expanded in b around -inf 91.9%
metadata-eval91.9%
distribute-lft-neg-in91.9%
*-lft-identity91.9%
associate-*l/91.8%
associate-*r*91.8%
*-commutative91.8%
distribute-rgt-neg-in91.8%
associate-*r/91.9%
metadata-eval91.9%
distribute-neg-frac91.9%
metadata-eval91.9%
Simplified91.9%
if -3.00000000000000016e-55 < b < 8.0000000000000006e-18Initial program 71.8%
Taylor expanded in b around 0 63.2%
associate-*r*63.2%
*-commutative63.2%
*-commutative63.2%
Simplified63.2%
*-un-lft-identity63.2%
times-frac63.2%
metadata-eval63.2%
+-commutative63.2%
add-sqr-sqrt35.5%
sqrt-unprod62.9%
sqr-neg62.9%
sqrt-unprod28.1%
add-sqr-sqrt62.1%
Applied egg-rr62.1%
if 8.0000000000000006e-18 < b Initial program 39.4%
Taylor expanded in b around inf 61.6%
associate-/l*65.7%
associate-/r/67.4%
Simplified67.4%
*-commutative67.4%
*-commutative67.4%
times-frac67.5%
*-commutative67.5%
metadata-eval67.5%
Applied egg-rr67.5%
Final simplification73.9%
(FPCore (a b c)
:precision binary64
(if (<= b -2.1e-57)
(* b (/ -0.6666666666666666 a))
(if (<= b 7.6e-20)
(/ (- (sqrt (* a (* c -3.0))) b) (* 3.0 a))
(* (/ (* c (/ a b)) a) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.1e-57) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 7.6e-20) {
tmp = (sqrt((a * (c * -3.0))) - b) / (3.0 * a);
} else {
tmp = ((c * (a / b)) / a) * -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.1d-57)) then
tmp = b * ((-0.6666666666666666d0) / a)
else if (b <= 7.6d-20) then
tmp = (sqrt((a * (c * (-3.0d0)))) - b) / (3.0d0 * a)
else
tmp = ((c * (a / b)) / a) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.1e-57) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 7.6e-20) {
tmp = (Math.sqrt((a * (c * -3.0))) - b) / (3.0 * a);
} else {
tmp = ((c * (a / b)) / a) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.1e-57: tmp = b * (-0.6666666666666666 / a) elif b <= 7.6e-20: tmp = (math.sqrt((a * (c * -3.0))) - b) / (3.0 * a) else: tmp = ((c * (a / b)) / a) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.1e-57) tmp = Float64(b * Float64(-0.6666666666666666 / a)); elseif (b <= 7.6e-20) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(Float64(c * Float64(a / b)) / a) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.1e-57) tmp = b * (-0.6666666666666666 / a); elseif (b <= 7.6e-20) tmp = (sqrt((a * (c * -3.0))) - b) / (3.0 * a); else tmp = ((c * (a / b)) / a) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.1e-57], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e-20], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.1 \cdot 10^{-57}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-20}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{a}{b}}{a} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.0999999999999999e-57Initial program 70.5%
Applied egg-rr57.6%
sub-neg57.6%
distribute-rgt-out--57.6%
Simplified57.6%
expm1-log1p-u38.9%
Applied egg-rr38.9%
Taylor expanded in b around -inf 91.9%
metadata-eval91.9%
distribute-lft-neg-in91.9%
*-lft-identity91.9%
associate-*l/91.8%
associate-*r*91.8%
*-commutative91.8%
distribute-rgt-neg-in91.8%
associate-*r/91.9%
metadata-eval91.9%
distribute-neg-frac91.9%
metadata-eval91.9%
Simplified91.9%
if -2.0999999999999999e-57 < b < 7.5999999999999995e-20Initial program 71.8%
Taylor expanded in b around 0 63.2%
associate-*r*63.2%
*-commutative63.2%
*-commutative63.2%
Simplified63.2%
+-commutative63.2%
unsub-neg63.2%
Applied egg-rr63.2%
associate-*r*63.2%
*-commutative63.2%
rem-square-sqrt0.0%
unpow20.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt63.1%
Simplified63.1%
if 7.5999999999999995e-20 < b Initial program 39.4%
Taylor expanded in b around inf 61.6%
associate-/l*65.7%
associate-/r/67.4%
Simplified67.4%
*-commutative67.4%
*-commutative67.4%
times-frac67.5%
*-commutative67.5%
metadata-eval67.5%
Applied egg-rr67.5%
Final simplification74.2%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e-54)
(* b (/ -0.6666666666666666 a))
(if (<= b 5.3e-23)
(/ (- (sqrt (* c (* a -3.0))) b) (* 3.0 a))
(* (/ (* c (/ a b)) a) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-54) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 5.3e-23) {
tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = ((c * (a / b)) / a) * -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.5d-54)) then
tmp = b * ((-0.6666666666666666d0) / a)
else if (b <= 5.3d-23) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (3.0d0 * a)
else
tmp = ((c * (a / b)) / a) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-54) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 5.3e-23) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = ((c * (a / b)) / a) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.5e-54: tmp = b * (-0.6666666666666666 / a) elif b <= 5.3e-23: tmp = (math.sqrt((c * (a * -3.0))) - b) / (3.0 * a) else: tmp = ((c * (a / b)) / a) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.5e-54) tmp = Float64(b * Float64(-0.6666666666666666 / a)); elseif (b <= 5.3e-23) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(Float64(c * Float64(a / b)) / a) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.5e-54) tmp = b * (-0.6666666666666666 / a); elseif (b <= 5.3e-23) tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a); else tmp = ((c * (a / b)) / a) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-54], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.3e-23], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-54}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 5.3 \cdot 10^{-23}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{a}{b}}{a} \cdot -0.5\\
\end{array}
\end{array}
if b < -6.49999999999999991e-54Initial program 70.5%
Applied egg-rr57.6%
sub-neg57.6%
distribute-rgt-out--57.6%
Simplified57.6%
expm1-log1p-u38.9%
Applied egg-rr38.9%
Taylor expanded in b around -inf 91.9%
metadata-eval91.9%
distribute-lft-neg-in91.9%
*-lft-identity91.9%
associate-*l/91.8%
associate-*r*91.8%
*-commutative91.8%
distribute-rgt-neg-in91.8%
associate-*r/91.9%
metadata-eval91.9%
distribute-neg-frac91.9%
metadata-eval91.9%
Simplified91.9%
if -6.49999999999999991e-54 < b < 5.30000000000000042e-23Initial program 71.8%
Taylor expanded in b around 0 63.2%
associate-*r*63.2%
*-commutative63.2%
*-commutative63.2%
Simplified63.2%
+-commutative63.2%
unsub-neg63.2%
Applied egg-rr63.2%
if 5.30000000000000042e-23 < b Initial program 39.4%
Taylor expanded in b around inf 61.6%
associate-/l*65.7%
associate-/r/67.4%
Simplified67.4%
*-commutative67.4%
*-commutative67.4%
times-frac67.5%
*-commutative67.5%
metadata-eval67.5%
Applied egg-rr67.5%
Final simplification74.2%
(FPCore (a b c)
:precision binary64
(if (<= b -5e-310)
(* b (/ -0.6666666666666666 a))
(if (<= b 1.8e+86)
(/ (- (+ b (* -1.5 (/ (* a c) b))) b) (* 3.0 a))
(* (/ (* c (/ a b)) a) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 1.8e+86) {
tmp = ((b + (-1.5 * ((a * c) / b))) - b) / (3.0 * a);
} else {
tmp = ((c * (a / b)) / a) * -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 <= (-5d-310)) then
tmp = b * ((-0.6666666666666666d0) / a)
else if (b <= 1.8d+86) then
tmp = ((b + ((-1.5d0) * ((a * c) / b))) - b) / (3.0d0 * a)
else
tmp = ((c * (a / b)) / a) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 1.8e+86) {
tmp = ((b + (-1.5 * ((a * c) / b))) - b) / (3.0 * a);
} else {
tmp = ((c * (a / b)) / a) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b * (-0.6666666666666666 / a) elif b <= 1.8e+86: tmp = ((b + (-1.5 * ((a * c) / b))) - b) / (3.0 * a) else: tmp = ((c * (a / b)) / a) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b * Float64(-0.6666666666666666 / a)); elseif (b <= 1.8e+86) tmp = Float64(Float64(Float64(b + Float64(-1.5 * Float64(Float64(a * c) / b))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(Float64(c * Float64(a / b)) / a) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = b * (-0.6666666666666666 / a); elseif (b <= 1.8e+86) tmp = ((b + (-1.5 * ((a * c) / b))) - b) / (3.0 * a); else tmp = ((c * (a / b)) / a) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e+86], N[(N[(N[(b + N[(-1.5 * N[(N[(a * c), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{+86}:\\
\;\;\;\;\frac{\left(b + -1.5 \cdot \frac{a \cdot c}{b}\right) - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{a}{b}}{a} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 72.6%
Applied egg-rr65.3%
sub-neg65.3%
distribute-rgt-out--65.3%
Simplified65.3%
expm1-log1p-u46.1%
Applied egg-rr46.1%
Taylor expanded in b around -inf 66.9%
metadata-eval66.9%
distribute-lft-neg-in66.9%
*-lft-identity66.9%
associate-*l/66.8%
associate-*r*66.8%
*-commutative66.8%
distribute-rgt-neg-in66.8%
associate-*r/66.9%
metadata-eval66.9%
distribute-neg-frac66.9%
metadata-eval66.9%
Simplified66.9%
if -4.999999999999985e-310 < b < 1.80000000000000003e86Initial program 68.1%
Taylor expanded in b around inf 33.1%
if 1.80000000000000003e86 < b Initial program 24.8%
Taylor expanded in b around inf 67.5%
associate-/l*73.6%
associate-/r/76.1%
Simplified76.1%
*-commutative76.1%
*-commutative76.1%
times-frac76.2%
*-commutative76.2%
metadata-eval76.2%
Applied egg-rr76.2%
Final simplification59.8%
(FPCore (a b c) :precision binary64 (if (<= b 2e-309) (* b (/ -0.6666666666666666 a)) (* (/ (* c (/ a b)) a) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2e-309) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = ((c * (a / b)) / a) * -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 <= 2d-309) then
tmp = b * ((-0.6666666666666666d0) / a)
else
tmp = ((c * (a / b)) / a) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2e-309) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = ((c * (a / b)) / a) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2e-309: tmp = b * (-0.6666666666666666 / a) else: tmp = ((c * (a / b)) / a) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2e-309) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(Float64(Float64(c * Float64(a / b)) / a) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2e-309) tmp = b * (-0.6666666666666666 / a); else tmp = ((c * (a / b)) / a) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2e-309], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2 \cdot 10^{-309}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{a}{b}}{a} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.9999999999999988e-309Initial program 72.6%
Applied egg-rr65.3%
sub-neg65.3%
distribute-rgt-out--65.3%
Simplified65.3%
expm1-log1p-u46.1%
Applied egg-rr46.1%
Taylor expanded in b around -inf 66.9%
metadata-eval66.9%
distribute-lft-neg-in66.9%
*-lft-identity66.9%
associate-*l/66.8%
associate-*r*66.8%
*-commutative66.8%
distribute-rgt-neg-in66.8%
associate-*r/66.9%
metadata-eval66.9%
distribute-neg-frac66.9%
metadata-eval66.9%
Simplified66.9%
if 1.9999999999999988e-309 < b Initial program 48.3%
Taylor expanded in b around inf 45.5%
associate-/l*48.5%
associate-/r/49.6%
Simplified49.6%
*-commutative49.6%
*-commutative49.6%
times-frac49.6%
*-commutative49.6%
metadata-eval49.6%
Applied egg-rr49.6%
Final simplification58.2%
(FPCore (a b c) :precision binary64 (if (<= a 2.85e+25) 0.0 (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (a <= 2.85e+25) {
tmp = 0.0;
} 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 (a <= 2.85d+25) then
tmp = 0.0d0
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 (a <= 2.85e+25) {
tmp = 0.0;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if a <= 2.85e+25: tmp = 0.0 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (a <= 2.85e+25) tmp = 0.0; else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (a <= 2.85e+25) tmp = 0.0; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[a, 2.85e+25], 0.0, N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.85 \cdot 10^{+25}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if a < 2.8499999999999998e25Initial program 66.8%
Applied egg-rr15.1%
Taylor expanded in b around inf 2.3%
expm1-log1p-u1.8%
expm1-udef3.7%
Applied egg-rr3.7%
Taylor expanded in b around 0 30.2%
if 2.8499999999999998e25 < a Initial program 39.8%
Taylor expanded in b around inf 24.0%
Final simplification28.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* b (/ -0.6666666666666666 a)) 0.0))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = 0.0;
}
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 = b * ((-0.6666666666666666d0) / a)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = 0.0;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b * (-0.6666666666666666 / a) else: tmp = 0.0 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = 0.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = b * (-0.6666666666666666 / a); else tmp = 0.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 72.6%
Applied egg-rr65.3%
sub-neg65.3%
distribute-rgt-out--65.3%
Simplified65.3%
expm1-log1p-u46.1%
Applied egg-rr46.1%
Taylor expanded in b around -inf 66.9%
metadata-eval66.9%
distribute-lft-neg-in66.9%
*-lft-identity66.9%
associate-*l/66.8%
associate-*r*66.8%
*-commutative66.8%
distribute-rgt-neg-in66.8%
associate-*r/66.9%
metadata-eval66.9%
distribute-neg-frac66.9%
metadata-eval66.9%
Simplified66.9%
if -4.999999999999985e-310 < b Initial program 48.3%
Applied egg-rr19.8%
Taylor expanded in b around inf 3.5%
expm1-log1p-u2.9%
expm1-udef6.4%
Applied egg-rr6.4%
Taylor expanded in b around 0 47.0%
Final simplification56.8%
(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 60.3%
Applied egg-rr17.7%
Taylor expanded in b around inf 2.6%
expm1-log1p-u2.2%
expm1-udef4.0%
Applied egg-rr4.0%
Taylor expanded in b around 0 25.1%
Final simplification25.1%
herbie shell --seed 2024031
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))