
(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 10 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 -1.25e+103)
(/ (* b -0.6666666666666666) a)
(if (<= b 3.9e-63)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e+103) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 3.9e-63) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / 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.25d+103)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 3.9d-63) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e+103) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 3.9e-63) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.25e+103: tmp = (b * -0.6666666666666666) / a elif b <= 3.9e-63: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.25e+103) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 3.9e-63) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.25e+103) tmp = (b * -0.6666666666666666) / a; elseif (b <= 3.9e-63) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.25e+103], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 3.9e-63], 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 * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.25 \cdot 10^{+103}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 3.9 \cdot 10^{-63}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.25e103Initial program 48.7%
Taylor expanded in b around -inf 98.0%
*-commutative98.0%
Simplified98.0%
associate-*l/98.1%
Applied egg-rr98.1%
if -1.25e103 < b < 3.90000000000000022e-63Initial program 78.4%
if 3.90000000000000022e-63 < b Initial program 11.4%
Taylor expanded in b around inf 91.3%
associate-*r/91.3%
Simplified91.3%
Final simplification87.0%
(FPCore (a b c)
:precision binary64
(if (<= b -3.6e-52)
(/ (* b -0.6666666666666666) a)
(if (<= b 5.2e-64)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e-52) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 5.2e-64) {
tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / 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 <= (-3.6d-52)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 5.2d-64) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e-52) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 5.2e-64) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.6e-52: tmp = (b * -0.6666666666666666) / a elif b <= 5.2e-64: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.6e-52) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 5.2e-64) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.6e-52) tmp = (b * -0.6666666666666666) / a; elseif (b <= 5.2e-64) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.6e-52], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 5.2e-64], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.6 \cdot 10^{-52}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 5.2 \cdot 10^{-64}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.59999999999999988e-52Initial program 64.9%
Taylor expanded in b around -inf 94.2%
*-commutative94.2%
Simplified94.2%
associate-*l/94.2%
Applied egg-rr94.2%
if -3.59999999999999988e-52 < b < 5.2e-64Initial program 72.3%
prod-diff71.8%
distribute-rgt-neg-in71.8%
*-commutative71.8%
distribute-rgt-neg-in71.8%
metadata-eval71.8%
*-commutative71.8%
fma-udef71.8%
distribute-lft-neg-in71.8%
distribute-rgt-neg-in71.8%
*-commutative71.8%
distribute-rgt-neg-in71.8%
metadata-eval71.8%
*-commutative71.8%
associate-*l*71.7%
Applied egg-rr71.7%
Taylor expanded in b around 0 64.0%
distribute-rgt-out64.4%
*-commutative64.4%
metadata-eval64.4%
associate-*r*64.6%
neg-mul-164.6%
unsub-neg64.6%
Simplified64.6%
if 5.2e-64 < b Initial program 11.4%
Taylor expanded in b around inf 91.3%
associate-*r/91.3%
Simplified91.3%
Final simplification83.4%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e-79)
(/ (* b -0.6666666666666666) a)
(if (<= b 1.26e-70)
(* 0.3333333333333333 (/ (sqrt (* -3.0 (* a c))) a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-79) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.26e-70) {
tmp = 0.3333333333333333 * (sqrt((-3.0 * (a * c))) / a);
} else {
tmp = (c * -0.5) / 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 <= (-6.5d-79)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 1.26d-70) then
tmp = 0.3333333333333333d0 * (sqrt(((-3.0d0) * (a * c))) / a)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-79) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.26e-70) {
tmp = 0.3333333333333333 * (Math.sqrt((-3.0 * (a * c))) / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.5e-79: tmp = (b * -0.6666666666666666) / a elif b <= 1.26e-70: tmp = 0.3333333333333333 * (math.sqrt((-3.0 * (a * c))) / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.5e-79) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 1.26e-70) tmp = Float64(0.3333333333333333 * Float64(sqrt(Float64(-3.0 * Float64(a * c))) / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.5e-79) tmp = (b * -0.6666666666666666) / a; elseif (b <= 1.26e-70) tmp = 0.3333333333333333 * (sqrt((-3.0 * (a * c))) / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-79], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.26e-70], N[(0.3333333333333333 * N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-79}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 1.26 \cdot 10^{-70}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{-3 \cdot \left(a \cdot c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -6.5000000000000003e-79Initial program 67.9%
Taylor expanded in b around -inf 90.6%
*-commutative90.6%
Simplified90.6%
associate-*l/90.7%
Applied egg-rr90.7%
if -6.5000000000000003e-79 < b < 1.2600000000000001e-70Initial program 69.5%
prod-diff69.0%
distribute-rgt-neg-in69.0%
*-commutative69.0%
distribute-rgt-neg-in69.0%
metadata-eval69.0%
*-commutative69.0%
fma-udef69.0%
distribute-lft-neg-in69.0%
distribute-rgt-neg-in69.0%
*-commutative69.0%
distribute-rgt-neg-in69.0%
metadata-eval69.0%
*-commutative69.0%
associate-*l*68.9%
Applied egg-rr68.9%
Taylor expanded in b around 0 63.4%
associate-*l/63.4%
distribute-rgt-out63.9%
*-commutative63.9%
metadata-eval63.9%
associate-*r*63.9%
*-lft-identity63.9%
*-commutative63.9%
associate-*l*63.8%
*-commutative63.8%
Simplified63.8%
Taylor expanded in a around 0 63.9%
if 1.2600000000000001e-70 < b Initial program 11.4%
Taylor expanded in b around inf 91.3%
associate-*r/91.3%
Simplified91.3%
Final simplification82.8%
(FPCore (a b c)
:precision binary64
(if (<= b -8.8e-80)
(/ (* b -0.6666666666666666) a)
(if (<= b 2.55e-64)
(/ (* 0.3333333333333333 (sqrt (* a (* c -3.0)))) a)
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8.8e-80) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 2.55e-64) {
tmp = (0.3333333333333333 * sqrt((a * (c * -3.0)))) / a;
} else {
tmp = (c * -0.5) / 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 <= (-8.8d-80)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 2.55d-64) then
tmp = (0.3333333333333333d0 * sqrt((a * (c * (-3.0d0))))) / a
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -8.8e-80) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 2.55e-64) {
tmp = (0.3333333333333333 * Math.sqrt((a * (c * -3.0)))) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.8e-80: tmp = (b * -0.6666666666666666) / a elif b <= 2.55e-64: tmp = (0.3333333333333333 * math.sqrt((a * (c * -3.0)))) / a else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8.8e-80) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 2.55e-64) tmp = Float64(Float64(0.3333333333333333 * sqrt(Float64(a * Float64(c * -3.0)))) / a); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8.8e-80) tmp = (b * -0.6666666666666666) / a; elseif (b <= 2.55e-64) tmp = (0.3333333333333333 * sqrt((a * (c * -3.0)))) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8.8e-80], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 2.55e-64], N[(N[(0.3333333333333333 * N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.8 \cdot 10^{-80}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 2.55 \cdot 10^{-64}:\\
\;\;\;\;\frac{0.3333333333333333 \cdot \sqrt{a \cdot \left(c \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -8.80000000000000041e-80Initial program 67.9%
Taylor expanded in b around -inf 90.6%
*-commutative90.6%
Simplified90.6%
associate-*l/90.7%
Applied egg-rr90.7%
if -8.80000000000000041e-80 < b < 2.54999999999999992e-64Initial program 69.5%
prod-diff69.0%
distribute-rgt-neg-in69.0%
*-commutative69.0%
distribute-rgt-neg-in69.0%
metadata-eval69.0%
*-commutative69.0%
fma-udef69.0%
distribute-lft-neg-in69.0%
distribute-rgt-neg-in69.0%
*-commutative69.0%
distribute-rgt-neg-in69.0%
metadata-eval69.0%
*-commutative69.0%
associate-*l*68.9%
Applied egg-rr68.9%
Taylor expanded in b around 0 63.4%
associate-*l/63.4%
distribute-rgt-out63.9%
*-commutative63.9%
metadata-eval63.9%
associate-*r*63.9%
*-lft-identity63.9%
*-commutative63.9%
associate-*l*63.8%
*-commutative63.8%
Simplified63.8%
associate-*r/63.9%
Applied egg-rr63.9%
if 2.54999999999999992e-64 < b Initial program 11.4%
Taylor expanded in b around inf 91.3%
associate-*r/91.3%
Simplified91.3%
Final simplification82.8%
(FPCore (a b c) :precision binary64 (if (<= b 1.08e+22) (* b (/ -1.3333333333333333 a)) (* 0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.08e+22) {
tmp = b * (-1.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 <= 1.08d+22) then
tmp = b * ((-1.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 <= 1.08e+22) {
tmp = b * (-1.3333333333333333 / a);
} else {
tmp = 0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.08e+22: tmp = b * (-1.3333333333333333 / a) else: tmp = 0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.08e+22) tmp = Float64(b * Float64(-1.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 <= 1.08e+22) tmp = b * (-1.3333333333333333 / a); else tmp = 0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.08e+22], N[(b * N[(-1.3333333333333333 / 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^{+22}:\\
\;\;\;\;b \cdot \frac{-1.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 1.08e22Initial program 64.2%
+-commutative64.2%
sqr-neg64.2%
unsub-neg64.2%
div-sub64.2%
--rgt-identity64.2%
div-sub64.2%
Simplified64.1%
*-un-lft-identity64.1%
*-un-lft-identity64.1%
prod-diff64.1%
Applied egg-rr31.6%
+-commutative31.6%
associate-+l+31.6%
associate-*r*31.5%
*-commutative31.5%
associate-*l*31.5%
fma-udef31.5%
*-rgt-identity31.5%
Simplified31.5%
Taylor expanded in b around inf 2.5%
*-commutative2.5%
Simplified2.5%
*-commutative2.5%
metadata-eval2.5%
times-frac2.5%
associate-/l*2.5%
add-sqr-sqrt1.3%
sqrt-unprod10.0%
*-commutative10.0%
*-commutative10.0%
swap-sqr10.0%
metadata-eval10.0%
metadata-eval10.0%
swap-sqr10.0%
sqrt-unprod9.7%
add-sqr-sqrt20.4%
Applied egg-rr20.4%
associate-/r/20.4%
*-commutative20.4%
associate-*r/20.4%
times-frac20.4%
metadata-eval20.4%
metadata-eval20.4%
distribute-rgt-neg-in20.4%
associate-*l/20.4%
distribute-neg-frac20.4%
distribute-rgt-neg-in20.4%
metadata-eval20.4%
metadata-eval20.4%
associate-*l*20.4%
associate-*r/20.4%
associate-*l*20.4%
associate-*r/20.4%
metadata-eval20.4%
Simplified20.4%
if 1.08e22 < b Initial program 11.4%
Taylor expanded in b around -inf 2.4%
fma-def2.4%
associate-*r/2.4%
Simplified2.4%
Taylor expanded in b around 0 23.4%
Final simplification21.3%
(FPCore (a b c) :precision binary64 (if (<= b 3.25e+22) (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.25e+22) {
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 <= 3.25d+22) 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 <= 3.25e+22) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = 0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.25e+22: tmp = -0.6666666666666666 * (b / a) else: tmp = 0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.25e+22) 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 <= 3.25e+22) tmp = -0.6666666666666666 * (b / a); else tmp = 0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.25e+22], 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 3.25 \cdot 10^{+22}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 3.2499999999999999e22Initial program 64.2%
Taylor expanded in b around -inf 50.2%
*-commutative50.2%
Simplified50.2%
if 3.2499999999999999e22 < b Initial program 11.4%
Taylor expanded in b around -inf 2.4%
fma-def2.4%
associate-*r/2.4%
Simplified2.4%
Taylor expanded in b around 0 23.4%
Final simplification42.7%
(FPCore (a b c) :precision binary64 (if (<= b 6.4e-291) (* -0.6666666666666666 (/ b a)) (/ -0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.4e-291) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 / (b / c);
}
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.4d-291) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = (-0.5d0) / (b / c)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 6.4e-291) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.4e-291: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.4e-291) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(-0.5 / Float64(b / c)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 6.4e-291) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.4e-291], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.4 \cdot 10^{-291}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < 6.4000000000000003e-291Initial program 70.0%
Taylor expanded in b around -inf 65.6%
*-commutative65.6%
Simplified65.6%
if 6.4000000000000003e-291 < b Initial program 24.9%
Taylor expanded in b around inf 73.4%
associate-*r/73.4%
associate-/l*72.8%
Simplified72.8%
Final simplification68.9%
(FPCore (a b c) :precision binary64 (if (<= b 6.4e-291) (* -0.6666666666666666 (/ b a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.4e-291) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c * -0.5) / 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 <= 6.4d-291) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 6.4e-291) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.4e-291: tmp = -0.6666666666666666 * (b / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.4e-291) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 6.4e-291) tmp = -0.6666666666666666 * (b / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.4e-291], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.4 \cdot 10^{-291}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 6.4000000000000003e-291Initial program 70.0%
Taylor expanded in b around -inf 65.6%
*-commutative65.6%
Simplified65.6%
if 6.4000000000000003e-291 < b Initial program 24.9%
Taylor expanded in b around inf 73.4%
associate-*r/73.4%
Simplified73.4%
Final simplification69.2%
(FPCore (a b c) :precision binary64 (if (<= b 6.4e-291) (/ (* b -0.6666666666666666) a) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.4e-291) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c * -0.5) / 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 <= 6.4d-291) then
tmp = (b * (-0.6666666666666666d0)) / a
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 6.4e-291) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.4e-291: tmp = (b * -0.6666666666666666) / a else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.4e-291) tmp = Float64(Float64(b * -0.6666666666666666) / a); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 6.4e-291) tmp = (b * -0.6666666666666666) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.4e-291], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.4 \cdot 10^{-291}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 6.4000000000000003e-291Initial program 70.0%
Taylor expanded in b around -inf 65.6%
*-commutative65.6%
Simplified65.6%
associate-*l/65.6%
Applied egg-rr65.6%
if 6.4000000000000003e-291 < b Initial program 24.9%
Taylor expanded in b around inf 73.4%
associate-*r/73.4%
Simplified73.4%
Final simplification69.2%
(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 49.4%
Taylor expanded in b around -inf 36.6%
fma-def36.6%
associate-*r/36.6%
Simplified36.6%
Taylor expanded in b around 0 8.8%
Final simplification8.8%
herbie shell --seed 2024021
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))