
(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 -2.5e+117)
(/ -0.6666666666666666 (/ a b))
(if (<= b 2.7e-44)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.5e+117) {
tmp = -0.6666666666666666 / (a / b);
} else if (b <= 2.7e-44) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.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 (b <= (-2.5d+117)) then
tmp = (-0.6666666666666666d0) / (a / b)
else if (b <= 2.7d-44) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (a * 3.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 (b <= -2.5e+117) {
tmp = -0.6666666666666666 / (a / b);
} else if (b <= 2.7e-44) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.5e+117: tmp = -0.6666666666666666 / (a / b) elif b <= 2.7e-44: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.5e+117) tmp = Float64(-0.6666666666666666 / Float64(a / b)); elseif (b <= 2.7e-44) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.5e+117) tmp = -0.6666666666666666 / (a / b); elseif (b <= 2.7e-44) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.5e+117], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.7e-44], 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[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.5 \cdot 10^{+117}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{elif}\;b \leq 2.7 \cdot 10^{-44}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -2.49999999999999992e117Initial program 44.9%
Simplified44.9%
Taylor expanded in b around -inf 93.3%
*-commutative93.3%
Simplified93.3%
*-commutative93.3%
clear-num93.3%
un-div-inv93.4%
Applied egg-rr93.4%
if -2.49999999999999992e117 < b < 2.6999999999999999e-44Initial program 80.3%
sqr-neg80.3%
sqr-neg80.3%
associate-*l*80.3%
Simplified80.3%
if 2.6999999999999999e-44 < b Initial program 19.1%
Simplified19.1%
Taylor expanded in b around inf 88.2%
Final simplification85.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.26e-61)
(/ (* b -0.6666666666666666) a)
(if (<= b 6.5e-47)
(/ (- (sqrt (* (* a c) -3.0)) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.26e-61) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 6.5e-47) {
tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.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 (b <= (-1.26d-61)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 6.5d-47) then
tmp = (sqrt(((a * c) * (-3.0d0))) - b) / (a * 3.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 (b <= -1.26e-61) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 6.5e-47) {
tmp = (Math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.26e-61: tmp = (b * -0.6666666666666666) / a elif b <= 6.5e-47: tmp = (math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.26e-61) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 6.5e-47) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.26e-61) tmp = (b * -0.6666666666666666) / a; elseif (b <= 6.5e-47) tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.26e-61], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 6.5e-47], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.26 \cdot 10^{-61}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 6.5 \cdot 10^{-47}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.2599999999999999e-61Initial program 64.8%
Simplified64.8%
Taylor expanded in b around -inf 87.7%
*-commutative87.7%
Simplified87.7%
associate-*l/87.7%
Applied egg-rr87.7%
if -1.2599999999999999e-61 < b < 6.5000000000000004e-47Initial program 73.8%
Simplified73.8%
Taylor expanded in b around 0 70.6%
if 6.5000000000000004e-47 < b Initial program 19.1%
Simplified19.1%
Taylor expanded in b around inf 88.2%
Final simplification82.4%
(FPCore (a b c) :precision binary64 (if (<= b -5.2e-62) (/ (* b -0.6666666666666666) a) (if (<= b 4.2e-43) (/ (/ (sqrt (* c (* a -3.0))) a) 3.0) (* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.2e-62) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 4.2e-43) {
tmp = (sqrt((c * (a * -3.0))) / a) / 3.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 (b <= (-5.2d-62)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 4.2d-43) then
tmp = (sqrt((c * (a * (-3.0d0)))) / a) / 3.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 (b <= -5.2e-62) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 4.2e-43) {
tmp = (Math.sqrt((c * (a * -3.0))) / a) / 3.0;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.2e-62: tmp = (b * -0.6666666666666666) / a elif b <= 4.2e-43: tmp = (math.sqrt((c * (a * -3.0))) / a) / 3.0 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.2e-62) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 4.2e-43) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) / a) / 3.0); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.2e-62) tmp = (b * -0.6666666666666666) / a; elseif (b <= 4.2e-43) tmp = (sqrt((c * (a * -3.0))) / a) / 3.0; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.2e-62], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 4.2e-43], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.2 \cdot 10^{-62}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 4.2 \cdot 10^{-43}:\\
\;\;\;\;\frac{\frac{\sqrt{c \cdot \left(a \cdot -3\right)}}{a}}{3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -5.1999999999999999e-62Initial program 64.8%
Simplified64.8%
Taylor expanded in b around -inf 87.7%
*-commutative87.7%
Simplified87.7%
associate-*l/87.7%
Applied egg-rr87.7%
if -5.1999999999999999e-62 < b < 4.2000000000000001e-43Initial program 73.8%
sqr-neg73.8%
sqr-neg73.8%
associate-*l*73.8%
Simplified73.8%
add-cube-cbrt73.3%
pow373.4%
Applied egg-rr73.4%
Taylor expanded in a around -inf 0.0%
mul-1-neg0.0%
rem-cube-cbrt0.0%
unpow20.0%
rem-square-sqrt69.7%
Simplified69.7%
distribute-rgt-neg-in69.7%
metadata-eval69.7%
*-rgt-identity69.7%
sqrt-prod43.3%
*-commutative43.3%
Applied egg-rr43.3%
add-sqr-sqrt43.2%
*-commutative43.2%
times-frac43.2%
*-commutative43.2%
sqrt-prod34.6%
*-commutative34.6%
associate-*l*34.6%
pow1/234.6%
sqrt-pow134.6%
associate-*l*34.6%
*-commutative34.6%
metadata-eval34.6%
Applied egg-rr69.5%
associate-*r/69.6%
associate-*l/69.5%
pow-sqr69.7%
metadata-eval69.7%
unpow1/269.7%
associate-*r*69.8%
*-commutative69.8%
associate-*l*69.8%
Simplified69.8%
if 4.2000000000000001e-43 < b Initial program 19.1%
Simplified19.1%
Taylor expanded in b around inf 88.2%
(FPCore (a b c)
:precision binary64
(if (<= b -2.25e-61)
(/ (* b -0.6666666666666666) a)
(if (<= b 2.7e-46)
(* (sqrt (* c (* a -3.0))) (/ 0.3333333333333333 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.25e-61) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 2.7e-46) {
tmp = sqrt((c * (a * -3.0))) * (0.3333333333333333 / 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 <= (-2.25d-61)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 2.7d-46) then
tmp = sqrt((c * (a * (-3.0d0)))) * (0.3333333333333333d0 / 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 <= -2.25e-61) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 2.7e-46) {
tmp = Math.sqrt((c * (a * -3.0))) * (0.3333333333333333 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.25e-61: tmp = (b * -0.6666666666666666) / a elif b <= 2.7e-46: tmp = math.sqrt((c * (a * -3.0))) * (0.3333333333333333 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.25e-61) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 2.7e-46) tmp = Float64(sqrt(Float64(c * Float64(a * -3.0))) * Float64(0.3333333333333333 / 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 <= -2.25e-61) tmp = (b * -0.6666666666666666) / a; elseif (b <= 2.7e-46) tmp = sqrt((c * (a * -3.0))) * (0.3333333333333333 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.25e-61], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 2.7e-46], N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.25 \cdot 10^{-61}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 2.7 \cdot 10^{-46}:\\
\;\;\;\;\sqrt{c \cdot \left(a \cdot -3\right)} \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -2.25e-61Initial program 64.8%
Simplified64.8%
Taylor expanded in b around -inf 87.7%
*-commutative87.7%
Simplified87.7%
associate-*l/87.7%
Applied egg-rr87.7%
if -2.25e-61 < b < 2.7e-46Initial program 73.8%
sqr-neg73.8%
sqr-neg73.8%
associate-*l*73.8%
Simplified73.8%
add-cube-cbrt73.3%
pow373.4%
Applied egg-rr73.4%
Taylor expanded in a around -inf 0.0%
mul-1-neg0.0%
rem-cube-cbrt0.0%
unpow20.0%
rem-square-sqrt69.7%
Simplified69.7%
distribute-rgt-neg-in69.7%
metadata-eval69.7%
*-rgt-identity69.7%
sqrt-prod43.3%
*-commutative43.3%
Applied egg-rr43.3%
div-inv43.3%
*-commutative43.3%
sqrt-prod69.6%
associate-/r*69.6%
metadata-eval69.6%
Applied egg-rr69.6%
*-commutative69.6%
associate-*r*69.6%
*-commutative69.6%
associate-*l*69.6%
Simplified69.6%
if 2.7e-46 < b Initial program 19.1%
Simplified19.1%
Taylor expanded in b around inf 88.2%
Final simplification82.1%
(FPCore (a b c)
:precision binary64
(if (<= b -1.26e-61)
(/ (* b -0.6666666666666666) a)
(if (<= b 3.95e-38)
(* 0.3333333333333333 (/ (sqrt (* a (* c -3.0))) a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.26e-61) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 3.95e-38) {
tmp = 0.3333333333333333 * (sqrt((a * (c * -3.0))) / 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 <= (-1.26d-61)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 3.95d-38) then
tmp = 0.3333333333333333d0 * (sqrt((a * (c * (-3.0d0)))) / 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 <= -1.26e-61) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 3.95e-38) {
tmp = 0.3333333333333333 * (Math.sqrt((a * (c * -3.0))) / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.26e-61: tmp = (b * -0.6666666666666666) / a elif b <= 3.95e-38: tmp = 0.3333333333333333 * (math.sqrt((a * (c * -3.0))) / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.26e-61) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 3.95e-38) tmp = Float64(0.3333333333333333 * Float64(sqrt(Float64(a * Float64(c * -3.0))) / 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 <= -1.26e-61) tmp = (b * -0.6666666666666666) / a; elseif (b <= 3.95e-38) tmp = 0.3333333333333333 * (sqrt((a * (c * -3.0))) / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.26e-61], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 3.95e-38], N[(0.3333333333333333 * N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.26 \cdot 10^{-61}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 3.95 \cdot 10^{-38}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{a \cdot \left(c \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.2599999999999999e-61Initial program 64.8%
Simplified64.8%
Taylor expanded in b around -inf 87.7%
*-commutative87.7%
Simplified87.7%
associate-*l/87.7%
Applied egg-rr87.7%
if -1.2599999999999999e-61 < b < 3.9499999999999999e-38Initial program 73.8%
sqr-neg73.8%
sqr-neg73.8%
associate-*l*73.8%
Simplified73.8%
add-cube-cbrt73.3%
pow373.4%
Applied egg-rr73.4%
Taylor expanded in a around -inf 0.0%
mul-1-neg0.0%
rem-cube-cbrt0.0%
unpow20.0%
rem-square-sqrt69.7%
Simplified69.7%
distribute-rgt-neg-in69.7%
metadata-eval69.7%
*-rgt-identity69.7%
sqrt-prod43.3%
*-commutative43.3%
Applied egg-rr43.3%
*-commutative43.3%
sqrt-prod69.7%
*-commutative69.7%
associate-*l*69.7%
*-un-lft-identity69.7%
times-frac69.6%
metadata-eval69.6%
associate-*l*69.5%
*-commutative69.5%
Applied egg-rr69.5%
if 3.9499999999999999e-38 < b Initial program 19.1%
Simplified19.1%
Taylor expanded in b around inf 88.2%
(FPCore (a b c)
:precision binary64
(if (<= b -2.4e-121)
(/ (* b -0.6666666666666666) a)
(if (<= b 4.6e-83)
(* -0.3333333333333333 (- (sqrt (/ (* c -3.0) a))))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.4e-121) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 4.6e-83) {
tmp = -0.3333333333333333 * -sqrt(((c * -3.0) / 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 <= (-2.4d-121)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 4.6d-83) then
tmp = (-0.3333333333333333d0) * -sqrt(((c * (-3.0d0)) / 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 <= -2.4e-121) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 4.6e-83) {
tmp = -0.3333333333333333 * -Math.sqrt(((c * -3.0) / a));
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.4e-121: tmp = (b * -0.6666666666666666) / a elif b <= 4.6e-83: tmp = -0.3333333333333333 * -math.sqrt(((c * -3.0) / a)) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.4e-121) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 4.6e-83) tmp = Float64(-0.3333333333333333 * Float64(-sqrt(Float64(Float64(c * -3.0) / 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 <= -2.4e-121) tmp = (b * -0.6666666666666666) / a; elseif (b <= 4.6e-83) tmp = -0.3333333333333333 * -sqrt(((c * -3.0) / a)); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.4e-121], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 4.6e-83], N[(-0.3333333333333333 * (-N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] / a), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.4 \cdot 10^{-121}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 4.6 \cdot 10^{-83}:\\
\;\;\;\;-0.3333333333333333 \cdot \left(-\sqrt{\frac{c \cdot -3}{a}}\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -2.40000000000000003e-121Initial program 66.8%
Simplified66.8%
Taylor expanded in b around -inf 80.6%
*-commutative80.6%
Simplified80.6%
associate-*l/80.6%
Applied egg-rr80.6%
if -2.40000000000000003e-121 < b < 4.59999999999999979e-83Initial program 73.4%
sqr-neg73.4%
sqr-neg73.4%
associate-*l*73.4%
Simplified73.4%
add-cube-cbrt72.9%
pow373.0%
Applied egg-rr73.0%
Taylor expanded in a around -inf 0.0%
rem-cube-cbrt0.0%
unpow20.0%
rem-square-sqrt37.6%
Simplified37.6%
if 4.59999999999999979e-83 < b Initial program 20.8%
Simplified20.8%
Taylor expanded in b around inf 85.2%
Final simplification71.1%
(FPCore (a b c) :precision binary64 (if (<= b 2.3e-301) (/ (* b -0.6666666666666666) a) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.3e-301) {
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 <= 2.3d-301) 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 <= 2.3e-301) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.3e-301: tmp = (b * -0.6666666666666666) / a else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.3e-301) tmp = Float64(Float64(b * -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 <= 2.3e-301) tmp = (b * -0.6666666666666666) / a; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.3e-301], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.3 \cdot 10^{-301}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.3000000000000002e-301Initial program 67.8%
Simplified67.8%
Taylor expanded in b around -inf 64.2%
*-commutative64.2%
Simplified64.2%
associate-*l/64.2%
Applied egg-rr64.2%
if 2.3000000000000002e-301 < b Initial program 36.8%
Simplified36.8%
Taylor expanded in b around inf 64.0%
(FPCore (a b c) :precision binary64 (if (<= b 2.3e-301) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.3e-301) {
tmp = -0.6666666666666666 * (b / 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 <= 2.3d-301) then
tmp = (-0.6666666666666666d0) * (b / 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 <= 2.3e-301) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.3e-301: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.3e-301) tmp = Float64(-0.6666666666666666 * Float64(b / 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 <= 2.3e-301) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.3e-301], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.3 \cdot 10^{-301}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.3000000000000002e-301Initial program 67.8%
Simplified67.8%
Taylor expanded in b around -inf 64.2%
*-commutative64.2%
Simplified64.2%
if 2.3000000000000002e-301 < b Initial program 36.8%
Simplified36.8%
Taylor expanded in b around inf 64.0%
Final simplification64.1%
(FPCore (a b c) :precision binary64 (if (<= b 2.3e-301) (* b (/ -0.6666666666666666 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.3e-301) {
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 <= 2.3d-301) 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 <= 2.3e-301) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.3e-301: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.3e-301) 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 <= 2.3e-301) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.3e-301], 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.3 \cdot 10^{-301}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.3000000000000002e-301Initial program 67.8%
Simplified67.8%
Taylor expanded in b around -inf 64.2%
*-commutative64.2%
Simplified64.2%
Taylor expanded in b around 0 64.2%
associate-*r/64.2%
*-commutative64.2%
associate-*r/64.1%
Simplified64.1%
if 2.3000000000000002e-301 < b Initial program 36.8%
Simplified36.8%
Taylor expanded in b around inf 64.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 54.5%
Simplified54.5%
Taylor expanded in b around inf 28.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 54.5%
Simplified54.5%
Taylor expanded in b around inf 7.4%
Taylor expanded in b around 0 7.4%
herbie shell --seed 2024187
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))