
(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 7 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 -7.6e+155)
(/ (* b -0.6666666666666666) a)
(if (<= b 2.7e-64)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.6e+155) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 2.7e-64) {
tmp = (sqrt(((b * b) - ((a * 3.0) * 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 <= (-7.6d+155)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 2.7d-64) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * 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 <= -7.6e+155) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 2.7e-64) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.6e+155: tmp = (b * -0.6666666666666666) / a elif b <= 2.7e-64: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.6e+155) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 2.7e-64) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * 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 <= -7.6e+155) tmp = (b * -0.6666666666666666) / a; elseif (b <= 2.7e-64) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.6e+155], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 2.7e-64], 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[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.6 \cdot 10^{+155}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 2.7 \cdot 10^{-64}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -7.6000000000000001e155Initial program 30.6%
/-rgt-identity30.6%
metadata-eval30.6%
associate-/l*30.6%
associate-*r/30.6%
*-commutative30.6%
associate-*l/30.6%
associate-*r/30.6%
metadata-eval30.6%
metadata-eval30.6%
times-frac30.6%
neg-mul-130.6%
distribute-rgt-neg-in30.6%
times-frac30.6%
metadata-eval30.6%
neg-mul-130.6%
Simplified30.6%
div-inv30.6%
fma-udef30.6%
add-sqr-sqrt21.1%
hypot-def58.3%
Applied egg-rr58.3%
Taylor expanded in b around -inf 97.7%
associate-*r/97.8%
Simplified97.8%
if -7.6000000000000001e155 < b < 2.69999999999999986e-64Initial program 89.5%
if 2.69999999999999986e-64 < b Initial program 11.2%
/-rgt-identity11.2%
metadata-eval11.2%
associate-/r/11.2%
metadata-eval11.2%
metadata-eval11.2%
times-frac11.2%
*-commutative11.2%
times-frac11.2%
*-commutative11.2%
associate-/r*11.2%
associate-*l/11.2%
Simplified11.2%
Taylor expanded in b around inf 93.9%
Final simplification92.6%
(FPCore (a b c)
:precision binary64
(if (<= b -7.6e+155)
(/ (* b -0.6666666666666666) a)
(if (<= b 2.2e-64)
(* -0.3333333333333333 (/ (- b (sqrt (- (* b b) (* 3.0 (* a c))))) a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.6e+155) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 2.2e-64) {
tmp = -0.3333333333333333 * ((b - sqrt(((b * b) - (3.0 * (a * c))))) / 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 <= (-7.6d+155)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 2.2d-64) then
tmp = (-0.3333333333333333d0) * ((b - sqrt(((b * b) - (3.0d0 * (a * c))))) / 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 <= -7.6e+155) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 2.2e-64) {
tmp = -0.3333333333333333 * ((b - Math.sqrt(((b * b) - (3.0 * (a * c))))) / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.6e+155: tmp = (b * -0.6666666666666666) / a elif b <= 2.2e-64: tmp = -0.3333333333333333 * ((b - math.sqrt(((b * b) - (3.0 * (a * c))))) / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.6e+155) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 2.2e-64) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c))))) / 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 <= -7.6e+155) tmp = (b * -0.6666666666666666) / a; elseif (b <= 2.2e-64) tmp = -0.3333333333333333 * ((b - sqrt(((b * b) - (3.0 * (a * c))))) / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.6e+155], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 2.2e-64], 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[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.6 \cdot 10^{+155}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 2.2 \cdot 10^{-64}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -7.6000000000000001e155Initial program 30.6%
/-rgt-identity30.6%
metadata-eval30.6%
associate-/l*30.6%
associate-*r/30.6%
*-commutative30.6%
associate-*l/30.6%
associate-*r/30.6%
metadata-eval30.6%
metadata-eval30.6%
times-frac30.6%
neg-mul-130.6%
distribute-rgt-neg-in30.6%
times-frac30.6%
metadata-eval30.6%
neg-mul-130.6%
Simplified30.6%
div-inv30.6%
fma-udef30.6%
add-sqr-sqrt21.1%
hypot-def58.3%
Applied egg-rr58.3%
Taylor expanded in b around -inf 97.7%
associate-*r/97.8%
Simplified97.8%
if -7.6000000000000001e155 < b < 2.2e-64Initial program 89.5%
/-rgt-identity89.5%
metadata-eval89.5%
associate-/l*89.5%
associate-*r/89.4%
*-commutative89.4%
associate-*l/89.5%
associate-*r/89.5%
metadata-eval89.5%
metadata-eval89.5%
times-frac89.5%
neg-mul-189.5%
distribute-rgt-neg-in89.5%
times-frac89.5%
metadata-eval89.5%
neg-mul-189.5%
Simplified89.5%
associate-*r*89.5%
*-commutative89.5%
metadata-eval89.5%
distribute-lft-neg-in89.5%
fma-neg89.5%
*-un-lft-identity89.5%
prod-diff89.2%
Applied egg-rr89.2%
*-rgt-identity89.2%
fma-neg89.2%
fma-udef89.2%
distribute-rgt-in89.2%
*-lft-identity89.2%
associate--r-89.2%
associate--r+89.2%
+-inverses89.5%
neg-sub089.5%
associate-*r*89.5%
*-commutative89.5%
*-commutative89.5%
*-commutative89.5%
distribute-lft-neg-in89.5%
metadata-eval89.5%
*-commutative89.5%
Simplified89.5%
if 2.2e-64 < b Initial program 11.2%
/-rgt-identity11.2%
metadata-eval11.2%
associate-/r/11.2%
metadata-eval11.2%
metadata-eval11.2%
times-frac11.2%
*-commutative11.2%
times-frac11.2%
*-commutative11.2%
associate-/r*11.2%
associate-*l/11.2%
Simplified11.2%
Taylor expanded in b around inf 93.9%
Final simplification92.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.08e-97)
(/ (* b -0.6666666666666666) a)
(if (<= b 1.1e-64)
(* -0.3333333333333333 (/ (- b (sqrt (* (* a c) -3.0))) a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.08e-97) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.1e-64) {
tmp = -0.3333333333333333 * ((b - 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.08d-97)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 1.1d-64) then
tmp = (-0.3333333333333333d0) * ((b - 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.08e-97) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.1e-64) {
tmp = -0.3333333333333333 * ((b - 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.08e-97: tmp = (b * -0.6666666666666666) / a elif b <= 1.1e-64: tmp = -0.3333333333333333 * ((b - 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.08e-97) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 1.1e-64) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(Float64(Float64(a * 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.08e-97) tmp = (b * -0.6666666666666666) / a; elseif (b <= 1.1e-64) tmp = -0.3333333333333333 * ((b - 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.08e-97], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.1e-64], N[(-0.3333333333333333 * N[(N[(b - N[Sqrt[N[(N[(a * c), $MachinePrecision] * -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.08 \cdot 10^{-97}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{-64}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{\left(a \cdot c\right) \cdot -3}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.0799999999999999e-97Initial program 61.6%
/-rgt-identity61.6%
metadata-eval61.6%
associate-/l*61.6%
associate-*r/61.6%
*-commutative61.6%
associate-*l/61.6%
associate-*r/61.6%
metadata-eval61.6%
metadata-eval61.6%
times-frac61.6%
neg-mul-161.6%
distribute-rgt-neg-in61.6%
times-frac61.6%
metadata-eval61.6%
neg-mul-161.6%
Simplified61.6%
div-inv61.6%
fma-udef61.6%
add-sqr-sqrt42.1%
hypot-def59.9%
Applied egg-rr59.9%
Taylor expanded in b around -inf 85.5%
associate-*r/85.6%
Simplified85.6%
if -1.0799999999999999e-97 < b < 1.1e-64Initial program 88.8%
/-rgt-identity88.8%
metadata-eval88.8%
associate-/l*88.8%
associate-*r/88.7%
*-commutative88.7%
associate-*l/88.8%
associate-*r/88.8%
metadata-eval88.8%
metadata-eval88.8%
times-frac88.8%
neg-mul-188.8%
distribute-rgt-neg-in88.8%
times-frac88.8%
metadata-eval88.8%
neg-mul-188.8%
Simplified88.8%
Taylor expanded in b around 0 88.0%
if 1.1e-64 < b Initial program 11.2%
/-rgt-identity11.2%
metadata-eval11.2%
associate-/r/11.2%
metadata-eval11.2%
metadata-eval11.2%
times-frac11.2%
*-commutative11.2%
times-frac11.2%
*-commutative11.2%
associate-/r*11.2%
associate-*l/11.2%
Simplified11.2%
Taylor expanded in b around inf 93.9%
Final simplification89.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.08e-97)
(/ (* b -0.6666666666666666) a)
(if (<= b 4.7e-67)
(* -0.3333333333333333 (/ (- b (sqrt (* c (* a -3.0)))) a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.08e-97) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 4.7e-67) {
tmp = -0.3333333333333333 * ((b - sqrt((c * (a * -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.08d-97)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 4.7d-67) then
tmp = (-0.3333333333333333d0) * ((b - sqrt((c * (a * (-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.08e-97) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 4.7e-67) {
tmp = -0.3333333333333333 * ((b - Math.sqrt((c * (a * -3.0)))) / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.08e-97: tmp = (b * -0.6666666666666666) / a elif b <= 4.7e-67: tmp = -0.3333333333333333 * ((b - math.sqrt((c * (a * -3.0)))) / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.08e-97) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 4.7e-67) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(Float64(c * Float64(a * -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.08e-97) tmp = (b * -0.6666666666666666) / a; elseif (b <= 4.7e-67) tmp = -0.3333333333333333 * ((b - sqrt((c * (a * -3.0)))) / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.08e-97], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 4.7e-67], N[(-0.3333333333333333 * N[(N[(b - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $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.08 \cdot 10^{-97}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 4.7 \cdot 10^{-67}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{c \cdot \left(a \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.0799999999999999e-97Initial program 61.6%
/-rgt-identity61.6%
metadata-eval61.6%
associate-/l*61.6%
associate-*r/61.6%
*-commutative61.6%
associate-*l/61.6%
associate-*r/61.6%
metadata-eval61.6%
metadata-eval61.6%
times-frac61.6%
neg-mul-161.6%
distribute-rgt-neg-in61.6%
times-frac61.6%
metadata-eval61.6%
neg-mul-161.6%
Simplified61.6%
div-inv61.6%
fma-udef61.6%
add-sqr-sqrt42.1%
hypot-def59.9%
Applied egg-rr59.9%
Taylor expanded in b around -inf 85.5%
associate-*r/85.6%
Simplified85.6%
if -1.0799999999999999e-97 < b < 4.70000000000000004e-67Initial program 88.8%
/-rgt-identity88.8%
metadata-eval88.8%
associate-/l*88.8%
associate-*r/88.7%
*-commutative88.7%
associate-*l/88.8%
associate-*r/88.8%
metadata-eval88.8%
metadata-eval88.8%
times-frac88.8%
neg-mul-188.8%
distribute-rgt-neg-in88.8%
times-frac88.8%
metadata-eval88.8%
neg-mul-188.8%
Simplified88.8%
Taylor expanded in b around 0 88.0%
*-commutative88.0%
associate-*l*88.1%
Simplified88.1%
if 4.70000000000000004e-67 < b Initial program 11.2%
/-rgt-identity11.2%
metadata-eval11.2%
associate-/r/11.2%
metadata-eval11.2%
metadata-eval11.2%
times-frac11.2%
*-commutative11.2%
times-frac11.2%
*-commutative11.2%
associate-/r*11.2%
associate-*l/11.2%
Simplified11.2%
Taylor expanded in b around inf 93.9%
Final simplification89.2%
(FPCore (a b c) :precision binary64 (if (<= b 2e-309) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2e-309) {
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 <= 2d-309) 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 <= 2e-309) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2e-309: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2e-309) 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 <= 2e-309) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2e-309], 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 \cdot 10^{-309}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 1.9999999999999988e-309Initial program 67.8%
/-rgt-identity67.8%
metadata-eval67.8%
associate-/r/67.8%
metadata-eval67.8%
metadata-eval67.8%
times-frac67.8%
*-commutative67.8%
times-frac67.7%
*-commutative67.7%
associate-/r*67.7%
associate-*l/67.6%
Simplified67.6%
Taylor expanded in b around -inf 67.1%
*-commutative67.1%
Simplified67.1%
if 1.9999999999999988e-309 < b Initial program 32.0%
/-rgt-identity32.0%
metadata-eval32.0%
associate-/r/32.0%
metadata-eval32.0%
metadata-eval32.0%
times-frac32.0%
*-commutative32.0%
times-frac32.0%
*-commutative32.0%
associate-/r*31.9%
associate-*l/31.9%
Simplified31.9%
Taylor expanded in b around inf 71.1%
Final simplification69.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (* b -0.6666666666666666) a) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (b * -0.6666666666666666) / a else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) 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 <= -5e-310) tmp = (b * -0.6666666666666666) / a; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], 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 -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 67.8%
/-rgt-identity67.8%
metadata-eval67.8%
associate-/l*67.8%
associate-*r/67.7%
*-commutative67.7%
associate-*l/67.8%
associate-*r/67.8%
metadata-eval67.8%
metadata-eval67.8%
times-frac67.8%
neg-mul-167.8%
distribute-rgt-neg-in67.8%
times-frac67.8%
metadata-eval67.8%
neg-mul-167.8%
Simplified67.8%
div-inv67.7%
fma-udef67.7%
add-sqr-sqrt52.8%
hypot-def67.0%
Applied egg-rr67.0%
Taylor expanded in b around -inf 67.1%
associate-*r/67.2%
Simplified67.2%
if -4.999999999999985e-310 < b Initial program 32.0%
/-rgt-identity32.0%
metadata-eval32.0%
associate-/r/32.0%
metadata-eval32.0%
metadata-eval32.0%
times-frac32.0%
*-commutative32.0%
times-frac32.0%
*-commutative32.0%
associate-/r*31.9%
associate-*l/31.9%
Simplified31.9%
Taylor expanded in b around inf 71.1%
Final simplification69.1%
(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 50.3%
/-rgt-identity50.3%
metadata-eval50.3%
associate-/r/50.3%
metadata-eval50.3%
metadata-eval50.3%
times-frac50.3%
*-commutative50.3%
times-frac50.3%
*-commutative50.3%
associate-/r*50.2%
associate-*l/50.2%
Simplified50.2%
Taylor expanded in b around inf 35.8%
Final simplification35.8%
herbie shell --seed 2023216
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))