
(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 -6e+119)
(/ (/ b -1.5) a)
(if (<= b 2.7e-90)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6e+119) {
tmp = (b / -1.5) / a;
} else if (b <= 2.7e-90) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - 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 <= (-6d+119)) then
tmp = (b / (-1.5d0)) / a
else if (b <= 2.7d-90) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - 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 <= -6e+119) {
tmp = (b / -1.5) / a;
} else if (b <= 2.7e-90) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6e+119: tmp = (b / -1.5) / a elif b <= 2.7e-90: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6e+119) tmp = Float64(Float64(b / -1.5) / a); elseif (b <= 2.7e-90) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - 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 <= -6e+119) tmp = (b / -1.5) / a; elseif (b <= 2.7e-90) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6e+119], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 2.7e-90], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{+119}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{elif}\;b \leq 2.7 \cdot 10^{-90}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -6.00000000000000002e119Initial program 39.3%
sqr-neg39.3%
sqr-neg39.3%
associate-*l*39.3%
Simplified39.3%
clear-num39.3%
associate-/r/39.3%
associate-/r*39.3%
metadata-eval39.3%
add-sqr-sqrt39.2%
sqrt-unprod39.3%
sqr-neg39.3%
sqrt-prod0.0%
add-sqr-sqrt30.2%
fma-neg30.2%
distribute-lft-neg-in30.2%
*-commutative30.2%
associate-*r*30.2%
metadata-eval30.2%
Applied egg-rr30.2%
Taylor expanded in a around 0 0.6%
*-commutative0.6%
Simplified0.6%
add-sqr-sqrt0.3%
sqrt-unprod29.6%
swap-sqr29.6%
metadata-eval29.6%
metadata-eval29.6%
swap-sqr29.6%
sqrt-unprod45.2%
add-sqr-sqrt95.8%
metadata-eval95.8%
div-inv95.9%
associate-/l/96.0%
associate-/r*96.2%
Applied egg-rr96.2%
if -6.00000000000000002e119 < b < 2.69999999999999996e-90Initial program 85.5%
if 2.69999999999999996e-90 < b Initial program 17.2%
sqr-neg17.2%
sqr-neg17.2%
associate-*l*17.2%
Simplified17.2%
Taylor expanded in b around inf 87.7%
*-commutative87.7%
Simplified87.7%
Final simplification88.9%
(FPCore (a b c)
:precision binary64
(if (<= b -9.8e+119)
(/ (/ b -1.5) a)
(if (<= b 4.5e-90)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.8e+119) {
tmp = (b / -1.5) / a;
} else if (b <= 4.5e-90) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - 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 <= (-9.8d+119)) then
tmp = (b / (-1.5d0)) / a
else if (b <= 4.5d-90) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - 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 <= -9.8e+119) {
tmp = (b / -1.5) / a;
} else if (b <= 4.5e-90) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9.8e+119: tmp = (b / -1.5) / a elif b <= 4.5e-90: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9.8e+119) tmp = Float64(Float64(b / -1.5) / a); elseif (b <= 4.5e-90) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - 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 <= -9.8e+119) tmp = (b / -1.5) / a; elseif (b <= 4.5e-90) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9.8e+119], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 4.5e-90], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.8 \cdot 10^{+119}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-90}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -9.79999999999999992e119Initial program 39.3%
sqr-neg39.3%
sqr-neg39.3%
associate-*l*39.3%
Simplified39.3%
clear-num39.3%
associate-/r/39.3%
associate-/r*39.3%
metadata-eval39.3%
add-sqr-sqrt39.2%
sqrt-unprod39.3%
sqr-neg39.3%
sqrt-prod0.0%
add-sqr-sqrt30.2%
fma-neg30.2%
distribute-lft-neg-in30.2%
*-commutative30.2%
associate-*r*30.2%
metadata-eval30.2%
Applied egg-rr30.2%
Taylor expanded in a around 0 0.6%
*-commutative0.6%
Simplified0.6%
add-sqr-sqrt0.3%
sqrt-unprod29.6%
swap-sqr29.6%
metadata-eval29.6%
metadata-eval29.6%
swap-sqr29.6%
sqrt-unprod45.2%
add-sqr-sqrt95.8%
metadata-eval95.8%
div-inv95.9%
associate-/l/96.0%
associate-/r*96.2%
Applied egg-rr96.2%
if -9.79999999999999992e119 < b < 4.50000000000000009e-90Initial program 85.5%
sqr-neg85.5%
sqr-neg85.5%
associate-*l*85.4%
Simplified85.4%
if 4.50000000000000009e-90 < b Initial program 17.2%
sqr-neg17.2%
sqr-neg17.2%
associate-*l*17.2%
Simplified17.2%
Taylor expanded in b around inf 87.7%
*-commutative87.7%
Simplified87.7%
Final simplification88.9%
(FPCore (a b c) :precision binary64 (if (<= b -8.5e-81) (/ (/ b -1.5) a) (if (<= b 9e-91) (/ (sqrt (* a (* c -3.0))) (* a 3.0)) (* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8.5e-81) {
tmp = (b / -1.5) / a;
} else if (b <= 9e-91) {
tmp = 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 <= (-8.5d-81)) then
tmp = (b / (-1.5d0)) / a
else if (b <= 9d-91) then
tmp = 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 <= -8.5e-81) {
tmp = (b / -1.5) / a;
} else if (b <= 9e-91) {
tmp = 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 <= -8.5e-81: tmp = (b / -1.5) / a elif b <= 9e-91: tmp = 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 <= -8.5e-81) tmp = Float64(Float64(b / -1.5) / a); elseif (b <= 9e-91) tmp = Float64(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 <= -8.5e-81) tmp = (b / -1.5) / a; elseif (b <= 9e-91) tmp = 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, -8.5e-81], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 9e-91], N[(N[Sqrt[N[(a * N[(c * -3.0), $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 -8.5 \cdot 10^{-81}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{elif}\;b \leq 9 \cdot 10^{-91}:\\
\;\;\;\;\frac{\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 < -8.5000000000000001e-81Initial program 60.4%
sqr-neg60.4%
sqr-neg60.4%
associate-*l*60.4%
Simplified60.4%
clear-num60.3%
associate-/r/60.4%
associate-/r*60.3%
metadata-eval60.3%
add-sqr-sqrt60.1%
sqrt-unprod60.3%
sqr-neg60.3%
sqrt-prod0.0%
add-sqr-sqrt26.9%
fma-neg26.9%
distribute-lft-neg-in26.9%
*-commutative26.9%
associate-*r*26.9%
metadata-eval26.9%
Applied egg-rr26.9%
Taylor expanded in a around 0 0.8%
*-commutative0.8%
Simplified0.8%
add-sqr-sqrt0.5%
sqrt-unprod25.7%
swap-sqr25.7%
metadata-eval25.7%
metadata-eval25.7%
swap-sqr25.7%
sqrt-unprod42.9%
add-sqr-sqrt89.1%
metadata-eval89.1%
div-inv89.3%
associate-/l/89.3%
associate-/r*89.4%
Applied egg-rr89.4%
if -8.5000000000000001e-81 < b < 8.99999999999999952e-91Initial program 79.5%
sqr-neg79.5%
sqr-neg79.5%
associate-*l*79.4%
Simplified79.4%
add-cube-cbrt78.9%
pow378.8%
associate-*r*78.7%
*-commutative78.7%
associate-*l*78.7%
Applied egg-rr78.7%
Taylor expanded in a around -inf 0.0%
mul-1-neg0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt73.6%
mul-1-neg73.6%
rem-cube-cbrt73.6%
Simplified73.6%
if 8.99999999999999952e-91 < b Initial program 17.2%
sqr-neg17.2%
sqr-neg17.2%
associate-*l*17.2%
Simplified17.2%
Taylor expanded in b around inf 87.7%
*-commutative87.7%
Simplified87.7%
Final simplification84.5%
(FPCore (a b c)
:precision binary64
(if (<= b -4.4e-155)
(/ (/ b -1.5) a)
(if (<= b 4.8e-108)
(* (sqrt (* c (/ -3.0 a))) (- -0.3333333333333333))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.4e-155) {
tmp = (b / -1.5) / a;
} else if (b <= 4.8e-108) {
tmp = sqrt((c * (-3.0 / a))) * -(-0.3333333333333333);
} 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 <= (-4.4d-155)) then
tmp = (b / (-1.5d0)) / a
else if (b <= 4.8d-108) then
tmp = sqrt((c * ((-3.0d0) / a))) * -(-0.3333333333333333d0)
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 <= -4.4e-155) {
tmp = (b / -1.5) / a;
} else if (b <= 4.8e-108) {
tmp = Math.sqrt((c * (-3.0 / a))) * -(-0.3333333333333333);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.4e-155: tmp = (b / -1.5) / a elif b <= 4.8e-108: tmp = math.sqrt((c * (-3.0 / a))) * -(-0.3333333333333333) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.4e-155) tmp = Float64(Float64(b / -1.5) / a); elseif (b <= 4.8e-108) tmp = Float64(sqrt(Float64(c * Float64(-3.0 / a))) * Float64(-(-0.3333333333333333))); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.4e-155) tmp = (b / -1.5) / a; elseif (b <= 4.8e-108) tmp = sqrt((c * (-3.0 / a))) * -(-0.3333333333333333); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.4e-155], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 4.8e-108], N[(N[Sqrt[N[(c * N[(-3.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (--0.3333333333333333)), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.4 \cdot 10^{-155}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{elif}\;b \leq 4.8 \cdot 10^{-108}:\\
\;\;\;\;\sqrt{c \cdot \frac{-3}{a}} \cdot \left(--0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.3999999999999998e-155Initial program 64.7%
sqr-neg64.7%
sqr-neg64.7%
associate-*l*64.6%
Simplified64.6%
clear-num64.6%
associate-/r/64.6%
associate-/r*64.5%
metadata-eval64.5%
add-sqr-sqrt64.4%
sqrt-unprod64.5%
sqr-neg64.5%
sqrt-prod0.0%
add-sqr-sqrt32.4%
fma-neg32.4%
distribute-lft-neg-in32.4%
*-commutative32.4%
associate-*r*32.4%
metadata-eval32.4%
Applied egg-rr32.4%
Taylor expanded in a around 0 1.0%
*-commutative1.0%
Simplified1.0%
add-sqr-sqrt0.6%
sqrt-unprod23.6%
swap-sqr23.6%
metadata-eval23.6%
metadata-eval23.6%
swap-sqr23.6%
sqrt-unprod38.4%
add-sqr-sqrt80.7%
metadata-eval80.7%
div-inv80.9%
associate-/l/80.9%
associate-/r*81.0%
Applied egg-rr81.0%
if -4.3999999999999998e-155 < b < 4.80000000000000034e-108Initial program 76.7%
sqr-neg76.7%
sqr-neg76.7%
associate-*l*76.6%
Simplified76.6%
add-cube-cbrt76.1%
pow376.1%
associate-*r*76.0%
*-commutative76.0%
associate-*l*75.9%
Applied egg-rr75.9%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt29.4%
rem-cube-cbrt29.7%
associate-/l*29.6%
Simplified29.6%
if 4.80000000000000034e-108 < b Initial program 18.0%
sqr-neg18.0%
sqr-neg18.0%
associate-*l*18.0%
Simplified18.0%
Taylor expanded in b around inf 85.9%
*-commutative85.9%
Simplified85.9%
Final simplification71.8%
(FPCore (a b c) :precision binary64 (if (<= b 3.7e-291) (/ (/ b -1.5) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.7e-291) {
tmp = (b / -1.5) / 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 <= 3.7d-291) then
tmp = (b / (-1.5d0)) / 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 <= 3.7e-291) {
tmp = (b / -1.5) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.7e-291: tmp = (b / -1.5) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.7e-291) tmp = Float64(Float64(b / -1.5) / 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 <= 3.7e-291) tmp = (b / -1.5) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.7e-291], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.7 \cdot 10^{-291}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 3.7000000000000001e-291Initial program 65.9%
sqr-neg65.9%
sqr-neg65.9%
associate-*l*65.9%
Simplified65.9%
clear-num65.8%
associate-/r/65.8%
associate-/r*65.8%
metadata-eval65.8%
add-sqr-sqrt65.0%
sqrt-unprod65.7%
sqr-neg65.7%
sqrt-prod0.7%
add-sqr-sqrt39.1%
fma-neg39.1%
distribute-lft-neg-in39.1%
*-commutative39.1%
associate-*r*39.0%
metadata-eval39.0%
Applied egg-rr39.0%
Taylor expanded in a around 0 1.4%
*-commutative1.4%
Simplified1.4%
add-sqr-sqrt1.0%
sqrt-unprod20.1%
swap-sqr20.1%
metadata-eval20.1%
metadata-eval20.1%
swap-sqr20.1%
sqrt-unprod32.2%
add-sqr-sqrt68.1%
metadata-eval68.1%
div-inv68.2%
associate-/l/68.2%
associate-/r*68.3%
Applied egg-rr68.3%
if 3.7000000000000001e-291 < b Initial program 34.2%
sqr-neg34.2%
sqr-neg34.2%
associate-*l*34.1%
Simplified34.1%
Taylor expanded in b around inf 66.6%
*-commutative66.6%
Simplified66.6%
(FPCore (a b c) :precision binary64 (if (<= b 3.7e-291) (/ b (* -1.5 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.7e-291) {
tmp = b / (-1.5 * 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 <= 3.7d-291) then
tmp = b / ((-1.5d0) * 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 <= 3.7e-291) {
tmp = b / (-1.5 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.7e-291: tmp = b / (-1.5 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.7e-291) tmp = Float64(b / Float64(-1.5 * 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 <= 3.7e-291) tmp = b / (-1.5 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.7e-291], N[(b / N[(-1.5 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.7 \cdot 10^{-291}:\\
\;\;\;\;\frac{b}{-1.5 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 3.7000000000000001e-291Initial program 65.9%
sqr-neg65.9%
sqr-neg65.9%
associate-*l*65.9%
Simplified65.9%
frac-2neg65.9%
div-inv65.8%
Applied egg-rr65.8%
*-commutative65.8%
*-commutative65.8%
associate-/r*65.8%
Simplified65.8%
Taylor expanded in b around -inf 68.1%
*-commutative68.1%
associate-*l/68.2%
associate-/l*68.1%
Simplified68.1%
clear-num68.1%
un-div-inv68.2%
div-inv68.2%
metadata-eval68.2%
Applied egg-rr68.2%
if 3.7000000000000001e-291 < b Initial program 34.2%
sqr-neg34.2%
sqr-neg34.2%
associate-*l*34.1%
Simplified34.1%
Taylor expanded in b around inf 66.6%
*-commutative66.6%
Simplified66.6%
Final simplification67.5%
(FPCore (a b c) :precision binary64 (if (<= b 3.7e-291) (* (/ b a) -0.6666666666666666) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.7e-291) {
tmp = (b / a) * -0.6666666666666666;
} 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 <= 3.7d-291) then
tmp = (b / a) * (-0.6666666666666666d0)
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 <= 3.7e-291) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.7e-291: tmp = (b / a) * -0.6666666666666666 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.7e-291) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3.7e-291) tmp = (b / a) * -0.6666666666666666; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.7e-291], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.7 \cdot 10^{-291}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 3.7000000000000001e-291Initial program 65.9%
sqr-neg65.9%
sqr-neg65.9%
associate-*l*65.9%
Simplified65.9%
Taylor expanded in b around -inf 68.1%
*-commutative68.1%
Simplified68.1%
if 3.7000000000000001e-291 < b Initial program 34.2%
sqr-neg34.2%
sqr-neg34.2%
associate-*l*34.1%
Simplified34.1%
Taylor expanded in b around inf 66.6%
*-commutative66.6%
Simplified66.6%
(FPCore (a b c) :precision binary64 (* (/ b a) -0.6666666666666666))
double code(double a, double b, double c) {
return (b / a) * -0.6666666666666666;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (b / a) * (-0.6666666666666666d0)
end function
public static double code(double a, double b, double c) {
return (b / a) * -0.6666666666666666;
}
def code(a, b, c): return (b / a) * -0.6666666666666666
function code(a, b, c) return Float64(Float64(b / a) * -0.6666666666666666) end
function tmp = code(a, b, c) tmp = (b / a) * -0.6666666666666666; end
code[a_, b_, c_] := N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{a} \cdot -0.6666666666666666
\end{array}
Initial program 51.5%
sqr-neg51.5%
sqr-neg51.5%
associate-*l*51.5%
Simplified51.5%
Taylor expanded in b around -inf 38.4%
*-commutative38.4%
Simplified38.4%
(FPCore (a b c) :precision binary64 (* b (/ -0.6666666666666666 a)))
double code(double a, double b, double c) {
return b * (-0.6666666666666666 / 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 * ((-0.6666666666666666d0) / a)
end function
public static double code(double a, double b, double c) {
return b * (-0.6666666666666666 / a);
}
def code(a, b, c): return b * (-0.6666666666666666 / a)
function code(a, b, c) return Float64(b * Float64(-0.6666666666666666 / a)) end
function tmp = code(a, b, c) tmp = b * (-0.6666666666666666 / a); end
code[a_, b_, c_] := N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \frac{-0.6666666666666666}{a}
\end{array}
Initial program 51.5%
sqr-neg51.5%
sqr-neg51.5%
associate-*l*51.5%
Simplified51.5%
frac-2neg51.5%
div-inv51.5%
Applied egg-rr51.4%
*-commutative51.4%
*-commutative51.4%
associate-/r*51.5%
Simplified51.5%
Taylor expanded in b around -inf 38.4%
*-commutative38.4%
associate-*l/38.4%
associate-/l*38.4%
Simplified38.4%
herbie shell --seed 2024132
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))