
(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 -2.05e+101)
(+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b)))
(if (<= b 1.8e-126)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.05e+101) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.8e-126) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2.05d+101)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else if (b <= 1.8d-126) then
tmp = (sqrt(((b * b) - (c * (a * 3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.05e+101) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else if (b <= 1.8e-126) {
tmp = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.05e+101: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) elif b <= 1.8e-126: tmp = (math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.05e+101) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); elseif (b <= 1.8e-126) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.05e+101) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); elseif (b <= 1.8e-126) tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.05e+101], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e-126], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.05 \cdot 10^{+101}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-126}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.05e101Initial program 46.0%
Taylor expanded in b around -inf 96.8%
if -2.05e101 < b < 1.8e-126Initial program 86.0%
if 1.8e-126 < b Initial program 21.4%
Taylor expanded in b around inf 84.7%
Final simplification88.3%
(FPCore (a b c)
:precision binary64
(if (<= b -1.4e+33)
(/ (* b -0.6666666666666666) a)
(if (<= b 1.9e-126)
(* -0.3333333333333333 (/ (- b (sqrt (- (* b b) (* 3.0 (* a c))))) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.4e+33) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.9e-126) {
tmp = -0.3333333333333333 * ((b - sqrt(((b * b) - (3.0 * (a * c))))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.4d+33)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 1.9d-126) then
tmp = (-0.3333333333333333d0) * ((b - sqrt(((b * b) - (3.0d0 * (a * c))))) / a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.4e+33) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.9e-126) {
tmp = -0.3333333333333333 * ((b - Math.sqrt(((b * b) - (3.0 * (a * c))))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.4e+33: tmp = (b * -0.6666666666666666) / a elif b <= 1.9e-126: tmp = -0.3333333333333333 * ((b - math.sqrt(((b * b) - (3.0 * (a * c))))) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.4e+33) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 1.9e-126) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c))))) / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.4e+33) tmp = (b * -0.6666666666666666) / a; elseif (b <= 1.9e-126) tmp = -0.3333333333333333 * ((b - sqrt(((b * b) - (3.0 * (a * c))))) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.4e+33], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.9e-126], N[(-0.3333333333333333 * N[(N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.4 \cdot 10^{+33}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-126}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.4e33Initial program 57.1%
Taylor expanded in b around -inf 96.3%
*-commutative96.3%
Simplified96.3%
associate-*l/96.3%
Applied egg-rr96.3%
if -1.4e33 < b < 1.8999999999999999e-126Initial program 84.2%
/-rgt-identity84.2%
metadata-eval84.2%
associate-/l*84.2%
associate-*r/84.2%
*-commutative84.2%
associate-*l/84.2%
associate-*r/84.2%
metadata-eval84.2%
metadata-eval84.2%
times-frac84.2%
neg-mul-184.2%
distribute-rgt-neg-in84.2%
times-frac84.1%
metadata-eval84.1%
neg-mul-184.1%
Simplified84.1%
fma-udef84.1%
associate-*r*84.2%
*-commutative84.2%
metadata-eval84.2%
cancel-sign-sub-inv84.2%
Applied egg-rr84.2%
if 1.8999999999999999e-126 < b Initial program 21.4%
Taylor expanded in b around inf 84.7%
Final simplification88.3%
(FPCore (a b c)
:precision binary64
(if (<= b -1.25e-83)
(/ (* b -0.6666666666666666) a)
(if (<= b 9.5e-127)
(* 0.3333333333333333 (/ (+ b (sqrt (* c (* a -3.0)))) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e-83) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 9.5e-127) {
tmp = 0.3333333333333333 * ((b + sqrt((c * (a * -3.0)))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.25d-83)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 9.5d-127) then
tmp = 0.3333333333333333d0 * ((b + sqrt((c * (a * (-3.0d0))))) / a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e-83) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 9.5e-127) {
tmp = 0.3333333333333333 * ((b + Math.sqrt((c * (a * -3.0)))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.25e-83: tmp = (b * -0.6666666666666666) / a elif b <= 9.5e-127: tmp = 0.3333333333333333 * ((b + math.sqrt((c * (a * -3.0)))) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.25e-83) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 9.5e-127) tmp = Float64(0.3333333333333333 * Float64(Float64(b + sqrt(Float64(c * Float64(a * -3.0)))) / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.25e-83) tmp = (b * -0.6666666666666666) / a; elseif (b <= 9.5e-127) tmp = 0.3333333333333333 * ((b + sqrt((c * (a * -3.0)))) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.25e-83], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 9.5e-127], N[(0.3333333333333333 * N[(N[(b + N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.25 \cdot 10^{-83}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 9.5 \cdot 10^{-127}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{b + \sqrt{c \cdot \left(a \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.25e-83Initial program 65.5%
Taylor expanded in b around -inf 90.2%
*-commutative90.2%
Simplified90.2%
associate-*l/90.3%
Applied egg-rr90.3%
if -1.25e-83 < b < 9.4999999999999997e-127Initial program 81.0%
Taylor expanded in b around 0 76.0%
clear-num75.9%
inv-pow75.9%
*-commutative75.9%
add-sqr-sqrt46.2%
sqrt-unprod75.6%
sqr-neg75.6%
sqrt-prod29.9%
add-sqr-sqrt75.0%
*-commutative75.0%
*-commutative75.0%
associate-*r*75.1%
Applied egg-rr75.1%
unpow-175.1%
Simplified75.1%
div-inv74.8%
*-commutative74.8%
Applied egg-rr74.8%
*-un-lft-identity74.8%
un-div-inv75.1%
Applied egg-rr75.1%
*-lft-identity75.1%
associate-/l*74.8%
associate-/r/75.0%
metadata-eval75.0%
associate-*r*75.1%
*-commutative75.1%
associate-*r*74.9%
Simplified74.9%
if 9.4999999999999997e-127 < b Initial program 21.4%
Taylor expanded in b around inf 84.7%
Final simplification84.6%
(FPCore (a b c)
:precision binary64
(if (<= b -6.2e-84)
(/ (* b -0.6666666666666666) a)
(if (<= b 4e-127)
(* (+ b (sqrt (* a (* c -3.0)))) (/ 0.3333333333333333 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.2e-84) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 4e-127) {
tmp = (b + sqrt((a * (c * -3.0)))) * (0.3333333333333333 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-6.2d-84)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 4d-127) then
tmp = (b + sqrt((a * (c * (-3.0d0))))) * (0.3333333333333333d0 / a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.2e-84) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 4e-127) {
tmp = (b + Math.sqrt((a * (c * -3.0)))) * (0.3333333333333333 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.2e-84: tmp = (b * -0.6666666666666666) / a elif b <= 4e-127: tmp = (b + math.sqrt((a * (c * -3.0)))) * (0.3333333333333333 / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.2e-84) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 4e-127) tmp = Float64(Float64(b + sqrt(Float64(a * Float64(c * -3.0)))) * Float64(0.3333333333333333 / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.2e-84) tmp = (b * -0.6666666666666666) / a; elseif (b <= 4e-127) tmp = (b + sqrt((a * (c * -3.0)))) * (0.3333333333333333 / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.2e-84], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 4e-127], N[(N[(b + N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.2 \cdot 10^{-84}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-127}:\\
\;\;\;\;\left(b + \sqrt{a \cdot \left(c \cdot -3\right)}\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -6.20000000000000003e-84Initial program 65.5%
Taylor expanded in b around -inf 90.2%
*-commutative90.2%
Simplified90.2%
associate-*l/90.3%
Applied egg-rr90.3%
if -6.20000000000000003e-84 < b < 4.0000000000000001e-127Initial program 81.0%
Taylor expanded in b around 0 76.0%
expm1-log1p-u59.6%
expm1-udef18.9%
div-inv18.9%
add-sqr-sqrt14.1%
sqrt-unprod19.0%
sqr-neg19.0%
sqrt-prod4.9%
add-sqr-sqrt18.9%
*-commutative18.9%
*-commutative18.9%
associate-*r*18.9%
associate-/r*18.9%
metadata-eval18.9%
Applied egg-rr18.9%
expm1-def59.7%
expm1-log1p75.0%
*-commutative75.0%
Simplified75.0%
if 4.0000000000000001e-127 < b Initial program 21.4%
Taylor expanded in b around inf 84.7%
Final simplification84.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.25e-86)
(/ (* b -0.6666666666666666) a)
(if (<= b 1.9e-126)
(/ (+ b (sqrt (* a (* c -3.0)))) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e-86) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.9e-126) {
tmp = (b + sqrt((a * (c * -3.0)))) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.25d-86)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 1.9d-126) then
tmp = (b + sqrt((a * (c * (-3.0d0))))) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e-86) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.9e-126) {
tmp = (b + Math.sqrt((a * (c * -3.0)))) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.25e-86: tmp = (b * -0.6666666666666666) / a elif b <= 1.9e-126: tmp = (b + math.sqrt((a * (c * -3.0)))) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.25e-86) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 1.9e-126) tmp = Float64(Float64(b + sqrt(Float64(a * Float64(c * -3.0)))) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.25e-86) tmp = (b * -0.6666666666666666) / a; elseif (b <= 1.9e-126) tmp = (b + sqrt((a * (c * -3.0)))) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.25e-86], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.9e-126], N[(N[(b + N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.25 \cdot 10^{-86}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-126}:\\
\;\;\;\;\frac{b + \sqrt{a \cdot \left(c \cdot -3\right)}}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.25e-86Initial program 65.5%
Taylor expanded in b around -inf 90.2%
*-commutative90.2%
Simplified90.2%
associate-*l/90.3%
Applied egg-rr90.3%
if -1.25e-86 < b < 1.8999999999999999e-126Initial program 81.0%
Taylor expanded in b around 0 76.0%
expm1-log1p-u74.5%
expm1-udef34.4%
add-sqr-sqrt22.8%
sqrt-unprod34.4%
sqr-neg34.4%
sqrt-prod11.6%
add-sqr-sqrt34.4%
*-commutative34.4%
*-commutative34.4%
associate-*r*34.4%
Applied egg-rr34.4%
expm1-def73.6%
expm1-log1p75.1%
Simplified75.1%
if 1.8999999999999999e-126 < b Initial program 21.4%
Taylor expanded in b around inf 84.7%
Final simplification84.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.15e-87)
(/ (* b -0.6666666666666666) a)
(if (<= b 1.9e-126)
(/ (+ b (sqrt (* c (* a -3.0)))) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e-87) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.9e-126) {
tmp = (b + sqrt((c * (a * -3.0)))) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.15d-87)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 1.9d-126) then
tmp = (b + sqrt((c * (a * (-3.0d0))))) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e-87) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.9e-126) {
tmp = (b + Math.sqrt((c * (a * -3.0)))) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.15e-87: tmp = (b * -0.6666666666666666) / a elif b <= 1.9e-126: tmp = (b + math.sqrt((c * (a * -3.0)))) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.15e-87) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 1.9e-126) tmp = Float64(Float64(b + sqrt(Float64(c * Float64(a * -3.0)))) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.15e-87) tmp = (b * -0.6666666666666666) / a; elseif (b <= 1.9e-126) tmp = (b + sqrt((c * (a * -3.0)))) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.15e-87], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.9e-126], N[(N[(b + N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.15 \cdot 10^{-87}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-126}:\\
\;\;\;\;\frac{b + \sqrt{c \cdot \left(a \cdot -3\right)}}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.1500000000000001e-87Initial program 65.5%
Taylor expanded in b around -inf 90.2%
*-commutative90.2%
Simplified90.2%
associate-*l/90.3%
Applied egg-rr90.3%
if -1.1500000000000001e-87 < b < 1.8999999999999999e-126Initial program 81.0%
Taylor expanded in b around 0 76.0%
expm1-log1p-u74.5%
expm1-udef34.4%
add-sqr-sqrt22.8%
sqrt-unprod34.4%
sqr-neg34.4%
sqrt-prod11.6%
add-sqr-sqrt34.4%
*-commutative34.4%
*-commutative34.4%
associate-*r*34.4%
Applied egg-rr34.4%
expm1-def73.6%
expm1-log1p75.1%
associate-*r*75.0%
*-commutative75.0%
associate-*r*75.1%
Simplified75.1%
if 1.8999999999999999e-126 < b Initial program 21.4%
Taylor expanded in b around inf 84.7%
Final simplification84.7%
(FPCore (a b c)
:precision binary64
(if (<= b -2e-70)
(/ (* b -0.6666666666666666) a)
(if (<= b 1.9e-126)
(/ (- (sqrt (* (* a c) -3.0)) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-70) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.9e-126) {
tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2d-70)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 1.9d-126) then
tmp = (sqrt(((a * c) * (-3.0d0))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2e-70) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.9e-126) {
tmp = (Math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-70: tmp = (b * -0.6666666666666666) / a elif b <= 1.9e-126: tmp = (math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-70) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 1.9e-126) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-70) tmp = (b * -0.6666666666666666) / a; elseif (b <= 1.9e-126) tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-70], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.9e-126], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-70}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-126}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.99999999999999999e-70Initial program 64.8%
Taylor expanded in b around -inf 90.9%
*-commutative90.9%
Simplified90.9%
associate-*l/91.0%
Applied egg-rr91.0%
if -1.99999999999999999e-70 < b < 1.8999999999999999e-126Initial program 81.5%
Taylor expanded in b around 0 75.5%
if 1.8999999999999999e-126 < b Initial program 21.4%
Taylor expanded in b around inf 84.7%
Final simplification84.9%
(FPCore (a b c)
:precision binary64
(if (<= b -6.8e-71)
(/ (* b -0.6666666666666666) a)
(if (<= b 1.85e-126)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.8e-71) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.85e-126) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-6.8d-71)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 1.85d-126) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.8e-71) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.85e-126) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.8e-71: tmp = (b * -0.6666666666666666) / a elif b <= 1.85e-126: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.8e-71) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 1.85e-126) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.8e-71) tmp = (b * -0.6666666666666666) / a; elseif (b <= 1.85e-126) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.8e-71], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.85e-126], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.8 \cdot 10^{-71}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 1.85 \cdot 10^{-126}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -6.80000000000000007e-71Initial program 64.8%
Taylor expanded in b around -inf 90.9%
*-commutative90.9%
Simplified90.9%
associate-*l/91.0%
Applied egg-rr91.0%
if -6.80000000000000007e-71 < b < 1.85e-126Initial program 81.5%
Taylor expanded in b around 0 75.5%
*-commutative75.5%
*-commutative75.5%
*-commutative75.5%
associate-*l*75.6%
Simplified75.6%
if 1.85e-126 < b Initial program 21.4%
Taylor expanded in b around inf 84.7%
Final simplification85.0%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b))) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2d-310)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 70.5%
Taylor expanded in b around -inf 70.8%
if -1.999999999999994e-310 < b Initial program 34.3%
Taylor expanded in b around inf 66.3%
Final simplification68.8%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (* -0.6666666666666666 (/ b a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2d-310)) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = -0.6666666666666666 * (b / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 70.5%
Taylor expanded in b around -inf 70.5%
*-commutative70.5%
Simplified70.5%
if -1.999999999999994e-310 < b Initial program 34.3%
Taylor expanded in b around inf 66.3%
Final simplification68.7%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ (* b -0.6666666666666666) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2d-310)) then
tmp = (b * (-0.6666666666666666d0)) / a
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = (b * -0.6666666666666666) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(b * -0.6666666666666666) / a); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = (b * -0.6666666666666666) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 70.5%
Taylor expanded in b around -inf 70.5%
*-commutative70.5%
Simplified70.5%
associate-*l/70.5%
Applied egg-rr70.5%
if -1.999999999999994e-310 < b Initial program 34.3%
Taylor expanded in b around inf 66.3%
Final simplification68.7%
(FPCore (a b c) :precision binary64 (* (/ c b) -0.5))
double code(double a, double b, double c) {
return (c / b) * -0.5;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (c / b) * (-0.5d0)
end function
public static double code(double a, double b, double c) {
return (c / b) * -0.5;
}
def code(a, b, c): return (c / b) * -0.5
function code(a, b, c) return Float64(Float64(c / b) * -0.5) end
function tmp = code(a, b, c) tmp = (c / b) * -0.5; end
code[a_, b_, c_] := N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b} \cdot -0.5
\end{array}
Initial program 55.0%
Taylor expanded in b around inf 29.6%
Final simplification29.6%
herbie shell --seed 2023187
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))