
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -1.9e+153)
(- (* -0.5 (/ (- c) b)) (* 0.6666666666666666 (/ b a)))
(if (<= b 1.45e-94)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.9e+153) {
tmp = (-0.5 * (-c / b)) - (0.6666666666666666 * (b / a));
} else if (b <= 1.45e-94) {
tmp = (sqrt(((b * b) - (c * (a * 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.9d+153)) then
tmp = ((-0.5d0) * (-c / b)) - (0.6666666666666666d0 * (b / a))
else if (b <= 1.45d-94) then
tmp = (sqrt(((b * b) - (c * (a * 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.9e+153) {
tmp = (-0.5 * (-c / b)) - (0.6666666666666666 * (b / a));
} else if (b <= 1.45e-94) {
tmp = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.9e+153: tmp = (-0.5 * (-c / b)) - (0.6666666666666666 * (b / a)) elif b <= 1.45e-94: tmp = (math.sqrt(((b * b) - (c * (a * 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.9e+153) tmp = Float64(Float64(-0.5 * Float64(Float64(-c) / b)) - Float64(0.6666666666666666 * Float64(b / a))); elseif (b <= 1.45e-94) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 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.9e+153) tmp = (-0.5 * (-c / b)) - (0.6666666666666666 * (b / a)); elseif (b <= 1.45e-94) tmp = (sqrt(((b * b) - (c * (a * 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.9e+153], N[(N[(-0.5 * N[((-c) / b), $MachinePrecision]), $MachinePrecision] - N[(0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.45e-94], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.9 \cdot 10^{+153}:\\
\;\;\;\;-0.5 \cdot \frac{-c}{b} - 0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{-94}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.89999999999999983e153Initial program 42.8%
sqr-neg42.8%
sqr-neg42.8%
associate-*l*42.8%
Simplified42.8%
Taylor expanded in b around -inf 99.3%
Taylor expanded in c around 0 99.6%
if -1.89999999999999983e153 < b < 1.44999999999999998e-94Initial program 84.2%
if 1.44999999999999998e-94 < b Initial program 19.2%
sqr-neg19.2%
sqr-neg19.2%
associate-*l*19.2%
Simplified19.2%
Taylor expanded in b around inf 86.6%
*-commutative86.6%
Simplified86.6%
Final simplification87.5%
(FPCore (a b c)
:precision binary64
(if (<= b -2.4e+153)
(- (* -0.5 (/ (- c) b)) (* 0.6666666666666666 (/ b a)))
(if (<= b 1.12e-98)
(/ (- (sqrt (- (* b b) (* 3.0 (* c a)))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.4e+153) {
tmp = (-0.5 * (-c / b)) - (0.6666666666666666 * (b / a));
} else if (b <= 1.12e-98) {
tmp = (sqrt(((b * b) - (3.0 * (c * a)))) - 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.4d+153)) then
tmp = ((-0.5d0) * (-c / b)) - (0.6666666666666666d0 * (b / a))
else if (b <= 1.12d-98) then
tmp = (sqrt(((b * b) - (3.0d0 * (c * a)))) - 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.4e+153) {
tmp = (-0.5 * (-c / b)) - (0.6666666666666666 * (b / a));
} else if (b <= 1.12e-98) {
tmp = (Math.sqrt(((b * b) - (3.0 * (c * a)))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.4e+153: tmp = (-0.5 * (-c / b)) - (0.6666666666666666 * (b / a)) elif b <= 1.12e-98: tmp = (math.sqrt(((b * b) - (3.0 * (c * a)))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.4e+153) tmp = Float64(Float64(-0.5 * Float64(Float64(-c) / b)) - Float64(0.6666666666666666 * Float64(b / a))); elseif (b <= 1.12e-98) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(c * a)))) - 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.4e+153) tmp = (-0.5 * (-c / b)) - (0.6666666666666666 * (b / a)); elseif (b <= 1.12e-98) tmp = (sqrt(((b * b) - (3.0 * (c * a)))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.4e+153], N[(N[(-0.5 * N[((-c) / b), $MachinePrecision]), $MachinePrecision] - N[(0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.12e-98], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(c * a), $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.4 \cdot 10^{+153}:\\
\;\;\;\;-0.5 \cdot \frac{-c}{b} - 0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.12 \cdot 10^{-98}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -2.39999999999999992e153Initial program 42.8%
sqr-neg42.8%
sqr-neg42.8%
associate-*l*42.8%
Simplified42.8%
Taylor expanded in b around -inf 99.3%
Taylor expanded in c around 0 99.6%
if -2.39999999999999992e153 < b < 1.12e-98Initial program 84.2%
sqr-neg84.2%
sqr-neg84.2%
associate-*l*84.1%
Simplified84.1%
if 1.12e-98 < b Initial program 19.2%
sqr-neg19.2%
sqr-neg19.2%
associate-*l*19.2%
Simplified19.2%
Taylor expanded in b around inf 86.6%
*-commutative86.6%
Simplified86.6%
Final simplification87.5%
(FPCore (a b c)
:precision binary64
(if (<= b -2.1e-63)
(- (/ b (* a -3.0)) (/ (/ b 3.0) a))
(if (<= b 8.4e-97)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.1e-63) {
tmp = (b / (a * -3.0)) - ((b / 3.0) / a);
} else if (b <= 8.4e-97) {
tmp = (sqrt((c * (a * -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 <= (-2.1d-63)) then
tmp = (b / (a * (-3.0d0))) - ((b / 3.0d0) / a)
else if (b <= 8.4d-97) then
tmp = (sqrt((c * (a * (-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 <= -2.1e-63) {
tmp = (b / (a * -3.0)) - ((b / 3.0) / a);
} else if (b <= 8.4e-97) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.1e-63: tmp = (b / (a * -3.0)) - ((b / 3.0) / a) elif b <= 8.4e-97: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.1e-63) tmp = Float64(Float64(b / Float64(a * -3.0)) - Float64(Float64(b / 3.0) / a)); elseif (b <= 8.4e-97) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -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 <= -2.1e-63) tmp = (b / (a * -3.0)) - ((b / 3.0) / a); elseif (b <= 8.4e-97) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.1e-63], N[(N[(b / N[(a * -3.0), $MachinePrecision]), $MachinePrecision] - N[(N[(b / 3.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.4e-97], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $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.1 \cdot 10^{-63}:\\
\;\;\;\;\frac{b}{a \cdot -3} - \frac{\frac{b}{3}}{a}\\
\mathbf{elif}\;b \leq 8.4 \cdot 10^{-97}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -2.1e-63Initial program 72.1%
sqr-neg72.1%
sqr-neg72.1%
associate-*l*72.1%
Simplified72.1%
Applied egg-rr60.2%
Taylor expanded in b around -inf 85.5%
metadata-eval85.5%
times-frac85.6%
neg-mul-185.6%
*-commutative85.6%
distribute-neg-frac85.6%
distribute-neg-frac285.6%
distribute-rgt-neg-in85.6%
metadata-eval85.6%
Simplified85.6%
if -2.1e-63 < b < 8.4000000000000005e-97Initial program 76.1%
sqr-neg76.1%
sqr-neg76.1%
associate-*l*76.0%
Simplified76.0%
Taylor expanded in b around 0 70.8%
*-commutative70.8%
*-commutative70.8%
associate-*r*71.0%
Simplified71.0%
if 8.4000000000000005e-97 < b Initial program 19.2%
sqr-neg19.2%
sqr-neg19.2%
associate-*l*19.2%
Simplified19.2%
Taylor expanded in b around inf 86.6%
*-commutative86.6%
Simplified86.6%
Final simplification82.3%
(FPCore (a b c)
:precision binary64
(if (<= b -2.9e-65)
(- (/ b (* a -3.0)) (/ (/ b 3.0) a))
(if (<= b 4.5e-99)
(/ (- (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 <= -2.9e-65) {
tmp = (b / (a * -3.0)) - ((b / 3.0) / a);
} else if (b <= 4.5e-99) {
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 <= (-2.9d-65)) then
tmp = (b / (a * (-3.0d0))) - ((b / 3.0d0) / a)
else if (b <= 4.5d-99) 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 <= -2.9e-65) {
tmp = (b / (a * -3.0)) - ((b / 3.0) / a);
} else if (b <= 4.5e-99) {
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 <= -2.9e-65: tmp = (b / (a * -3.0)) - ((b / 3.0) / a) elif b <= 4.5e-99: 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 <= -2.9e-65) tmp = Float64(Float64(b / Float64(a * -3.0)) - Float64(Float64(b / 3.0) / a)); elseif (b <= 4.5e-99) tmp = Float64(Float64(sqrt(Float64(a * Float64(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 <= -2.9e-65) tmp = (b / (a * -3.0)) - ((b / 3.0) / a); elseif (b <= 4.5e-99) 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, -2.9e-65], N[(N[(b / N[(a * -3.0), $MachinePrecision]), $MachinePrecision] - N[(N[(b / 3.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.5e-99], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $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.9 \cdot 10^{-65}:\\
\;\;\;\;\frac{b}{a \cdot -3} - \frac{\frac{b}{3}}{a}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-99}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -2.8999999999999998e-65Initial program 72.1%
sqr-neg72.1%
sqr-neg72.1%
associate-*l*72.1%
Simplified72.1%
Applied egg-rr60.2%
Taylor expanded in b around -inf 85.5%
metadata-eval85.5%
times-frac85.6%
neg-mul-185.6%
*-commutative85.6%
distribute-neg-frac85.6%
distribute-neg-frac285.6%
distribute-rgt-neg-in85.6%
metadata-eval85.6%
Simplified85.6%
if -2.8999999999999998e-65 < b < 4.5000000000000003e-99Initial program 76.1%
sqr-neg76.1%
sqr-neg76.1%
associate-*l*76.0%
Simplified76.0%
Taylor expanded in b around 0 70.8%
*-commutative70.8%
associate-*r*70.9%
Simplified70.9%
if 4.5000000000000003e-99 < b Initial program 19.2%
sqr-neg19.2%
sqr-neg19.2%
associate-*l*19.2%
Simplified19.2%
Taylor expanded in b around inf 86.6%
*-commutative86.6%
Simplified86.6%
Final simplification82.3%
(FPCore (a b c)
:precision binary64
(if (<= b -4.2e-69)
(- (/ b (* a -3.0)) (/ (/ b 3.0) a))
(if (<= b 5.8e-98)
(/ (- (sqrt (* (* c a) -3.0)) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.2e-69) {
tmp = (b / (a * -3.0)) - ((b / 3.0) / a);
} else if (b <= 5.8e-98) {
tmp = (sqrt(((c * a) * -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 <= (-4.2d-69)) then
tmp = (b / (a * (-3.0d0))) - ((b / 3.0d0) / a)
else if (b <= 5.8d-98) then
tmp = (sqrt(((c * a) * (-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 <= -4.2e-69) {
tmp = (b / (a * -3.0)) - ((b / 3.0) / a);
} else if (b <= 5.8e-98) {
tmp = (Math.sqrt(((c * a) * -3.0)) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.2e-69: tmp = (b / (a * -3.0)) - ((b / 3.0) / a) elif b <= 5.8e-98: tmp = (math.sqrt(((c * a) * -3.0)) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.2e-69) tmp = Float64(Float64(b / Float64(a * -3.0)) - Float64(Float64(b / 3.0) / a)); elseif (b <= 5.8e-98) tmp = Float64(Float64(sqrt(Float64(Float64(c * a) * -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 <= -4.2e-69) tmp = (b / (a * -3.0)) - ((b / 3.0) / a); elseif (b <= 5.8e-98) tmp = (sqrt(((c * a) * -3.0)) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.2e-69], N[(N[(b / N[(a * -3.0), $MachinePrecision]), $MachinePrecision] - N[(N[(b / 3.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.8e-98], N[(N[(N[Sqrt[N[(N[(c * a), $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 -4.2 \cdot 10^{-69}:\\
\;\;\;\;\frac{b}{a \cdot -3} - \frac{\frac{b}{3}}{a}\\
\mathbf{elif}\;b \leq 5.8 \cdot 10^{-98}:\\
\;\;\;\;\frac{\sqrt{\left(c \cdot a\right) \cdot -3} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.1999999999999999e-69Initial program 72.1%
sqr-neg72.1%
sqr-neg72.1%
associate-*l*72.1%
Simplified72.1%
Applied egg-rr60.2%
Taylor expanded in b around -inf 85.5%
metadata-eval85.5%
times-frac85.6%
neg-mul-185.6%
*-commutative85.6%
distribute-neg-frac85.6%
distribute-neg-frac285.6%
distribute-rgt-neg-in85.6%
metadata-eval85.6%
Simplified85.6%
if -4.1999999999999999e-69 < b < 5.8e-98Initial program 76.1%
sqr-neg76.1%
sqr-neg76.1%
associate-*l*76.0%
Simplified76.0%
Taylor expanded in b around 0 70.8%
if 5.8e-98 < b Initial program 19.2%
sqr-neg19.2%
sqr-neg19.2%
associate-*l*19.2%
Simplified19.2%
Taylor expanded in b around inf 86.6%
*-commutative86.6%
Simplified86.6%
Final simplification82.2%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (- (* -0.5 (/ (- c) b)) (* 0.6666666666666666 (/ b a))) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = (-0.5 * (-c / b)) - (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-310)) then
tmp = ((-0.5d0) * (-c / b)) - (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-310) {
tmp = (-0.5 * (-c / b)) - (0.6666666666666666 * (b / a));
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = (-0.5 * (-c / b)) - (0.6666666666666666 * (b / a)) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(-0.5 * Float64(Float64(-c) / b)) - 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-310) tmp = (-0.5 * (-c / b)) - (0.6666666666666666 * (b / a)); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(N[(-0.5 * N[((-c) / b), $MachinePrecision]), $MachinePrecision] - N[(0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;-0.5 \cdot \frac{-c}{b} - 0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 74.7%
sqr-neg74.7%
sqr-neg74.7%
associate-*l*74.7%
Simplified74.7%
Taylor expanded in b around -inf 63.6%
Taylor expanded in c around 0 63.8%
if -1.999999999999994e-310 < b Initial program 28.9%
sqr-neg28.9%
sqr-neg28.9%
associate-*l*28.8%
Simplified28.8%
Taylor expanded in b around inf 71.9%
*-commutative71.9%
Simplified71.9%
Final simplification67.7%
(FPCore (a b c) :precision binary64 (if (<= b 3e-303) (* (/ (* b 2.0) -3.0) (/ 1.0 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 3e-303) {
tmp = ((b * 2.0) / -3.0) * (1.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 <= 3d-303) then
tmp = ((b * 2.0d0) / (-3.0d0)) * (1.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 <= 3e-303) {
tmp = ((b * 2.0) / -3.0) * (1.0 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3e-303: tmp = ((b * 2.0) / -3.0) * (1.0 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3e-303) tmp = Float64(Float64(Float64(b * 2.0) / -3.0) * Float64(1.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 <= 3e-303) tmp = ((b * 2.0) / -3.0) * (1.0 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3e-303], N[(N[(N[(b * 2.0), $MachinePrecision] / -3.0), $MachinePrecision] * N[(1.0 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3 \cdot 10^{-303}:\\
\;\;\;\;\frac{b \cdot 2}{-3} \cdot \frac{1}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 3.00000000000000028e-303Initial program 74.9%
sqr-neg74.9%
sqr-neg74.9%
associate-*l*74.9%
Simplified74.9%
Applied egg-rr66.7%
Taylor expanded in b around -inf 63.1%
*-commutative63.1%
Simplified63.1%
if 3.00000000000000028e-303 < b Initial program 28.3%
sqr-neg28.3%
sqr-neg28.3%
associate-*l*28.2%
Simplified28.2%
Taylor expanded in b around inf 72.5%
*-commutative72.5%
Simplified72.5%
Final simplification67.5%
(FPCore (a b c) :precision binary64 (if (<= b 2.9e-303) (/ (* b -2.0) (* a 3.0)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.9e-303) {
tmp = (b * -2.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 <= 2.9d-303) then
tmp = (b * (-2.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 <= 2.9e-303) {
tmp = (b * -2.0) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.9e-303: tmp = (b * -2.0) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.9e-303) tmp = Float64(Float64(b * -2.0) / 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.9e-303) tmp = (b * -2.0) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.9e-303], N[(N[(b * -2.0), $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.9 \cdot 10^{-303}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.90000000000000014e-303Initial program 74.9%
sqr-neg74.9%
sqr-neg74.9%
associate-*l*74.9%
Simplified74.9%
Taylor expanded in b around -inf 63.1%
*-commutative63.1%
Simplified63.1%
if 2.90000000000000014e-303 < b Initial program 28.3%
sqr-neg28.3%
sqr-neg28.3%
associate-*l*28.2%
Simplified28.2%
Taylor expanded in b around inf 72.5%
*-commutative72.5%
Simplified72.5%
Final simplification67.5%
(FPCore (a b c) :precision binary64 (if (<= b 2.9e-303) (* b (/ -0.6666666666666666 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.9e-303) {
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.9d-303) 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.9e-303) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.9e-303: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.9e-303) 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.9e-303) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.9e-303], 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.9 \cdot 10^{-303}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.90000000000000014e-303Initial program 74.9%
sqr-neg74.9%
sqr-neg74.9%
associate-*l*74.9%
Simplified74.9%
Applied egg-rr66.7%
Taylor expanded in b around -inf 62.9%
*-commutative62.9%
associate-*l/63.0%
associate-/l*63.0%
Simplified63.0%
if 2.90000000000000014e-303 < b Initial program 28.3%
sqr-neg28.3%
sqr-neg28.3%
associate-*l*28.2%
Simplified28.2%
Taylor expanded in b around inf 72.5%
*-commutative72.5%
Simplified72.5%
Final simplification67.5%
(FPCore (a b c) :precision binary64 (if (<= b 2.9e-303) (* b (/ -0.6666666666666666 a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.9e-303) {
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 <= 2.9d-303) 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 <= 2.9e-303) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.9e-303: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.9e-303) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(c * Float64(-0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.9e-303) tmp = b * (-0.6666666666666666 / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.9e-303], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.9 \cdot 10^{-303}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 2.90000000000000014e-303Initial program 74.9%
sqr-neg74.9%
sqr-neg74.9%
associate-*l*74.9%
Simplified74.9%
Applied egg-rr66.7%
Taylor expanded in b around -inf 62.9%
*-commutative62.9%
associate-*l/63.0%
associate-/l*63.0%
Simplified63.0%
if 2.90000000000000014e-303 < b Initial program 28.3%
sqr-neg28.3%
sqr-neg28.3%
associate-*l*28.2%
Simplified28.2%
Applied egg-rr34.4%
un-div-inv34.4%
div-inv34.4%
metadata-eval34.4%
Applied egg-rr34.4%
associate-/l*34.4%
Applied egg-rr34.4%
Taylor expanded in b around inf 0.0%
*-commutative0.0%
associate-/l*0.0%
associate-*r*0.0%
*-commutative0.0%
associate-*r/0.0%
unpow20.0%
rem-square-sqrt72.3%
metadata-eval72.3%
Simplified72.3%
(FPCore (a b c) :precision binary64 (if (<= b 4.5e+14) (* b (/ -0.6666666666666666 a)) (* (/ c b) 0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 4.5e+14) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * 0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 4.5d+14) then
tmp = b * ((-0.6666666666666666d0) / a)
else
tmp = (c / b) * 0.5d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 4.5e+14) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * 0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4.5e+14: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * 0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4.5e+14) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(Float64(c / b) * 0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 4.5e+14) tmp = b * (-0.6666666666666666 / a); else tmp = (c / b) * 0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4.5e+14], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.5 \cdot 10^{+14}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot 0.5\\
\end{array}
\end{array}
if b < 4.5e14Initial program 69.1%
sqr-neg69.1%
sqr-neg69.1%
associate-*l*69.0%
Simplified69.0%
Applied egg-rr62.9%
Taylor expanded in b around -inf 47.6%
*-commutative47.6%
associate-*l/47.6%
associate-/l*47.6%
Simplified47.6%
if 4.5e14 < b Initial program 13.6%
sqr-neg13.6%
sqr-neg13.6%
associate-*l*13.6%
Simplified13.6%
Taylor expanded in b around inf 76.5%
*-commutative76.5%
associate-/l*78.0%
associate-*r*78.0%
*-commutative78.0%
associate-*r/77.9%
Simplified77.9%
add-sqr-sqrt54.1%
sqrt-unprod47.9%
pow247.9%
associate-/l*47.9%
Applied egg-rr47.9%
unpow247.9%
rem-sqrt-square57.3%
*-commutative57.3%
Simplified57.3%
Taylor expanded in a around 0 69.7%
pow169.7%
fabs-mul69.7%
add-sqr-sqrt24.4%
fabs-sqr24.4%
add-sqr-sqrt27.6%
associate-*r*27.6%
metadata-eval27.6%
metadata-eval27.6%
Applied egg-rr27.6%
unpow127.6%
Simplified27.6%
Final simplification41.8%
(FPCore (a b c) :precision binary64 (* (/ c b) 0.5))
double code(double a, double b, double c) {
return (c / b) * 0.5;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (c / b) * 0.5d0
end function
public static double code(double a, double b, double c) {
return (c / b) * 0.5;
}
def code(a, b, c): return (c / b) * 0.5
function code(a, b, c) return Float64(Float64(c / b) * 0.5) end
function tmp = code(a, b, c) tmp = (c / b) * 0.5; end
code[a_, b_, c_] := N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b} \cdot 0.5
\end{array}
Initial program 52.9%
sqr-neg52.9%
sqr-neg52.9%
associate-*l*52.8%
Simplified52.8%
Taylor expanded in b around inf 27.5%
*-commutative27.5%
associate-/l*29.0%
associate-*r*29.0%
*-commutative29.0%
associate-*r/29.0%
Simplified29.0%
add-sqr-sqrt19.1%
sqrt-unprod18.0%
pow218.0%
associate-/l*18.0%
Applied egg-rr18.0%
unpow218.0%
rem-sqrt-square21.2%
*-commutative21.2%
Simplified21.2%
Taylor expanded in a around 0 25.5%
pow125.5%
fabs-mul25.5%
add-sqr-sqrt8.4%
fabs-sqr8.4%
add-sqr-sqrt10.4%
associate-*r*10.4%
metadata-eval10.4%
metadata-eval10.4%
Applied egg-rr10.4%
unpow110.4%
Simplified10.4%
Final simplification10.4%
herbie shell --seed 2024108
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))