
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -1.7e+86)
(/ b (* a -1.5))
(if (<= b 4.4e-16)
(/ (- (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.7e+86) {
tmp = b / (a * -1.5);
} else if (b <= 4.4e-16) {
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.7d+86)) then
tmp = b / (a * (-1.5d0))
else if (b <= 4.4d-16) 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.7e+86) {
tmp = b / (a * -1.5);
} else if (b <= 4.4e-16) {
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.7e+86: tmp = b / (a * -1.5) elif b <= 4.4e-16: 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.7e+86) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 4.4e-16) 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.7e+86) tmp = b / (a * -1.5); elseif (b <= 4.4e-16) 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.7e+86], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.4e-16], 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.7 \cdot 10^{+86}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{-16}:\\
\;\;\;\;\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.6999999999999999e86Initial program 52.4%
sqr-neg52.4%
sqr-neg52.4%
associate-*l*52.4%
Simplified52.4%
Applied egg-rr55.7%
Taylor expanded in b around -inf 94.6%
associate-*r/94.5%
*-commutative94.5%
associate-/l*94.5%
Simplified94.5%
clear-num94.5%
div-inv94.5%
metadata-eval94.5%
*-commutative94.5%
un-div-inv94.6%
*-commutative94.6%
Applied egg-rr94.6%
if -1.6999999999999999e86 < b < 4.40000000000000001e-16Initial program 81.0%
if 4.40000000000000001e-16 < b Initial program 15.0%
sqr-neg15.0%
sqr-neg15.0%
associate-*l*15.0%
Simplified15.0%
Taylor expanded in b around inf 67.6%
expm1-log1p-u64.5%
expm1-undefine32.1%
associate-/l*32.4%
Applied egg-rr32.4%
expm1-define64.9%
associate-*r*65.0%
Simplified65.0%
Taylor expanded in a around 0 87.3%
associate-*r/87.3%
Simplified87.3%
Final simplification85.7%
(FPCore (a b c)
:precision binary64
(if (<= b -3e+86)
(/ b (* a -1.5))
(if (<= b 5.8e-15)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3e+86) {
tmp = b / (a * -1.5);
} else if (b <= 5.8e-15) {
tmp = (sqrt(((b * b) - (3.0 * (a * 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 <= (-3d+86)) then
tmp = b / (a * (-1.5d0))
else if (b <= 5.8d-15) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * 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 <= -3e+86) {
tmp = b / (a * -1.5);
} else if (b <= 5.8e-15) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3e+86: tmp = b / (a * -1.5) elif b <= 5.8e-15: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3e+86) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 5.8e-15) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * 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 <= -3e+86) tmp = b / (a * -1.5); elseif (b <= 5.8e-15) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3e+86], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.8e-15], 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 * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3 \cdot 10^{+86}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 5.8 \cdot 10^{-15}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -2.99999999999999977e86Initial program 52.4%
sqr-neg52.4%
sqr-neg52.4%
associate-*l*52.4%
Simplified52.4%
Applied egg-rr55.7%
Taylor expanded in b around -inf 94.6%
associate-*r/94.5%
*-commutative94.5%
associate-/l*94.5%
Simplified94.5%
clear-num94.5%
div-inv94.5%
metadata-eval94.5%
*-commutative94.5%
un-div-inv94.6%
*-commutative94.6%
Applied egg-rr94.6%
if -2.99999999999999977e86 < b < 5.80000000000000037e-15Initial program 81.0%
sqr-neg81.0%
sqr-neg81.0%
associate-*l*80.9%
Simplified80.9%
if 5.80000000000000037e-15 < b Initial program 15.0%
sqr-neg15.0%
sqr-neg15.0%
associate-*l*15.0%
Simplified15.0%
Taylor expanded in b around inf 67.6%
expm1-log1p-u64.5%
expm1-undefine32.1%
associate-/l*32.4%
Applied egg-rr32.4%
expm1-define64.9%
associate-*r*65.0%
Simplified65.0%
Taylor expanded in a around 0 87.3%
associate-*r/87.3%
Simplified87.3%
Final simplification85.6%
(FPCore (a b c)
:precision binary64
(if (<= b -2.45e-110)
(/ b (* a -1.5))
(if (<= b 4.3e-16)
(/ (- (sqrt (* a (* c -3.0))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.45e-110) {
tmp = b / (a * -1.5);
} else if (b <= 4.3e-16) {
tmp = (sqrt((a * (c * -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 <= (-2.45d-110)) then
tmp = b / (a * (-1.5d0))
else if (b <= 4.3d-16) then
tmp = (sqrt((a * (c * (-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 <= -2.45e-110) {
tmp = b / (a * -1.5);
} else if (b <= 4.3e-16) {
tmp = (Math.sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.45e-110: tmp = b / (a * -1.5) elif b <= 4.3e-16: tmp = (math.sqrt((a * (c * -3.0))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.45e-110) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 4.3e-16) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -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 <= -2.45e-110) tmp = b / (a * -1.5); elseif (b <= 4.3e-16) tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.45e-110], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.3e-16], N[(N[(N[Sqrt[N[(a * N[(c * -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 -2.45 \cdot 10^{-110}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 4.3 \cdot 10^{-16}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -2.4499999999999999e-110Initial program 67.0%
sqr-neg67.0%
sqr-neg67.0%
associate-*l*67.0%
Simplified67.0%
Applied egg-rr60.3%
Taylor expanded in b around -inf 85.9%
associate-*r/85.8%
*-commutative85.8%
associate-/l*85.8%
Simplified85.8%
clear-num85.8%
div-inv85.8%
metadata-eval85.8%
*-commutative85.8%
un-div-inv85.9%
*-commutative85.9%
Applied egg-rr85.9%
if -2.4499999999999999e-110 < b < 4.2999999999999999e-16Initial program 78.3%
sqr-neg78.3%
sqr-neg78.3%
associate-*l*78.2%
Simplified78.2%
Taylor expanded in b around 0 76.2%
*-commutative76.2%
associate-*r*76.3%
Simplified76.3%
+-commutative76.3%
unsub-neg76.3%
Applied egg-rr76.3%
if 4.2999999999999999e-16 < b Initial program 15.0%
sqr-neg15.0%
sqr-neg15.0%
associate-*l*15.0%
Simplified15.0%
Taylor expanded in b around inf 67.6%
expm1-log1p-u64.5%
expm1-undefine32.1%
associate-/l*32.4%
Applied egg-rr32.4%
expm1-define64.9%
associate-*r*65.0%
Simplified65.0%
Taylor expanded in a around 0 87.3%
associate-*r/87.3%
Simplified87.3%
Final simplification82.9%
(FPCore (a b c)
:precision binary64
(if (<= b -2.35e-110)
(/ b (* a -1.5))
(if (<= b 4.5e-16)
(/ (- (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 <= -2.35e-110) {
tmp = b / (a * -1.5);
} else if (b <= 4.5e-16) {
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 <= (-2.35d-110)) then
tmp = b / (a * (-1.5d0))
else if (b <= 4.5d-16) 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 <= -2.35e-110) {
tmp = b / (a * -1.5);
} else if (b <= 4.5e-16) {
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 <= -2.35e-110: tmp = b / (a * -1.5) elif b <= 4.5e-16: 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 <= -2.35e-110) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 4.5e-16) 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 <= -2.35e-110) tmp = b / (a * -1.5); elseif (b <= 4.5e-16) 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, -2.35e-110], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.5e-16], 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 -2.35 \cdot 10^{-110}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-16}:\\
\;\;\;\;\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 < -2.34999999999999996e-110Initial program 67.0%
sqr-neg67.0%
sqr-neg67.0%
associate-*l*67.0%
Simplified67.0%
Applied egg-rr60.3%
Taylor expanded in b around -inf 85.9%
associate-*r/85.8%
*-commutative85.8%
associate-/l*85.8%
Simplified85.8%
clear-num85.8%
div-inv85.8%
metadata-eval85.8%
*-commutative85.8%
un-div-inv85.9%
*-commutative85.9%
Applied egg-rr85.9%
if -2.34999999999999996e-110 < b < 4.5000000000000002e-16Initial program 78.3%
sqr-neg78.3%
sqr-neg78.3%
associate-*l*78.2%
Simplified78.2%
Taylor expanded in b around 0 76.2%
*-commutative76.2%
*-commutative76.2%
associate-*r*76.3%
Simplified76.3%
if 4.5000000000000002e-16 < b Initial program 15.0%
sqr-neg15.0%
sqr-neg15.0%
associate-*l*15.0%
Simplified15.0%
Taylor expanded in b around inf 67.6%
expm1-log1p-u64.5%
expm1-undefine32.1%
associate-/l*32.4%
Applied egg-rr32.4%
expm1-define64.9%
associate-*r*65.0%
Simplified65.0%
Taylor expanded in a around 0 87.3%
associate-*r/87.3%
Simplified87.3%
Final simplification83.0%
(FPCore (a b c)
:precision binary64
(if (<= b -2.45e-110)
(* b (- (* 0.6666666666666666 (/ -1.0 a)) (* -0.5 (/ c (pow b 2.0)))))
(if (<= b 4.3e-16)
(/ (- (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 <= -2.45e-110) {
tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / pow(b, 2.0))));
} else if (b <= 4.3e-16) {
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 <= (-2.45d-110)) then
tmp = b * ((0.6666666666666666d0 * ((-1.0d0) / a)) - ((-0.5d0) * (c / (b ** 2.0d0))))
else if (b <= 4.3d-16) 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 <= -2.45e-110) {
tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / Math.pow(b, 2.0))));
} else if (b <= 4.3e-16) {
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 <= -2.45e-110: tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / math.pow(b, 2.0)))) elif b <= 4.3e-16: 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 <= -2.45e-110) tmp = Float64(b * Float64(Float64(0.6666666666666666 * Float64(-1.0 / a)) - Float64(-0.5 * Float64(c / (b ^ 2.0))))); elseif (b <= 4.3e-16) 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 <= -2.45e-110) tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / (b ^ 2.0)))); elseif (b <= 4.3e-16) 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, -2.45e-110], N[(b * N[(N[(0.6666666666666666 * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision] - N[(-0.5 * N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.3e-16], 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 -2.45 \cdot 10^{-110}:\\
\;\;\;\;b \cdot \left(0.6666666666666666 \cdot \frac{-1}{a} - -0.5 \cdot \frac{c}{{b}^{2}}\right)\\
\mathbf{elif}\;b \leq 4.3 \cdot 10^{-16}:\\
\;\;\;\;\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 < -2.4499999999999999e-110Initial program 67.0%
sqr-neg67.0%
sqr-neg67.0%
associate-*l*67.0%
Simplified67.0%
Taylor expanded in b around -inf 86.6%
if -2.4499999999999999e-110 < b < 4.2999999999999999e-16Initial program 78.3%
sqr-neg78.3%
sqr-neg78.3%
associate-*l*78.2%
Simplified78.2%
Taylor expanded in b around 0 76.2%
*-commutative76.2%
*-commutative76.2%
associate-*r*76.3%
Simplified76.3%
if 4.2999999999999999e-16 < b Initial program 15.0%
sqr-neg15.0%
sqr-neg15.0%
associate-*l*15.0%
Simplified15.0%
Taylor expanded in b around inf 67.6%
expm1-log1p-u64.5%
expm1-undefine32.1%
associate-/l*32.4%
Applied egg-rr32.4%
expm1-define64.9%
associate-*r*65.0%
Simplified65.0%
Taylor expanded in a around 0 87.3%
associate-*r/87.3%
Simplified87.3%
Final simplification83.2%
(FPCore (a b c) :precision binary64 (if (<= b 1.3e-300) (* b (/ -0.6666666666666666 a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.3e-300) {
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 <= 1.3d-300) 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 <= 1.3e-300) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.3e-300: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.3e-300) 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 <= 1.3e-300) tmp = b * (-0.6666666666666666 / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.3e-300], 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 1.3 \cdot 10^{-300}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 1.29999999999999998e-300Initial program 73.6%
sqr-neg73.6%
sqr-neg73.6%
associate-*l*73.5%
Simplified73.5%
Applied egg-rr70.2%
Taylor expanded in b around -inf 62.0%
associate-*r/62.0%
*-commutative62.0%
associate-/l*62.0%
Simplified62.0%
if 1.29999999999999998e-300 < b Initial program 35.8%
sqr-neg35.8%
sqr-neg35.8%
associate-*l*35.7%
Simplified35.7%
Taylor expanded in c around 0 58.6%
associate-*r/58.6%
metadata-eval58.6%
Simplified58.6%
Taylor expanded in a around 0 63.1%
Final simplification62.5%
(FPCore (a b c) :precision binary64 (if (<= b 1.3e-300) (* (/ b a) -0.6666666666666666) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.3e-300) {
tmp = (b / a) * -0.6666666666666666;
} 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.3d-300) then
tmp = (b / a) * (-0.6666666666666666d0)
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.3e-300) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.3e-300: tmp = (b / a) * -0.6666666666666666 else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.3e-300) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(c * Float64(-0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.3e-300) tmp = (b / a) * -0.6666666666666666; else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.3e-300], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.3 \cdot 10^{-300}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 1.29999999999999998e-300Initial program 73.6%
sqr-neg73.6%
sqr-neg73.6%
associate-*l*73.5%
Simplified73.5%
Taylor expanded in b around -inf 62.0%
*-commutative62.0%
Simplified62.0%
if 1.29999999999999998e-300 < b Initial program 35.8%
sqr-neg35.8%
sqr-neg35.8%
associate-*l*35.7%
Simplified35.7%
Taylor expanded in c around 0 58.6%
associate-*r/58.6%
metadata-eval58.6%
Simplified58.6%
Taylor expanded in a around 0 63.1%
Final simplification62.5%
(FPCore (a b c) :precision binary64 (if (<= b 1.3e-300) (* (/ b a) -0.6666666666666666) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.3e-300) {
tmp = (b / a) * -0.6666666666666666;
} 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.3d-300) then
tmp = (b / a) * (-0.6666666666666666d0)
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.3e-300) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.3e-300: tmp = (b / a) * -0.6666666666666666 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.3e-300) tmp = Float64(Float64(b / a) * -0.6666666666666666); 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.3e-300) tmp = (b / a) * -0.6666666666666666; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.3e-300], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.3 \cdot 10^{-300}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 1.29999999999999998e-300Initial program 73.6%
sqr-neg73.6%
sqr-neg73.6%
associate-*l*73.5%
Simplified73.5%
Taylor expanded in b around -inf 62.0%
*-commutative62.0%
Simplified62.0%
if 1.29999999999999998e-300 < b Initial program 35.8%
sqr-neg35.8%
sqr-neg35.8%
associate-*l*35.7%
Simplified35.7%
Taylor expanded in b around inf 63.2%
*-commutative63.2%
Simplified63.2%
Final simplification62.6%
(FPCore (a b c) :precision binary64 (if (<= b 1.8e-300) (/ b (* a -1.5)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.8e-300) {
tmp = b / (a * -1.5);
} 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.8d-300) then
tmp = b / (a * (-1.5d0))
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.8e-300) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.8e-300: tmp = b / (a * -1.5) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.8e-300) tmp = Float64(b / Float64(a * -1.5)); 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.8e-300) tmp = b / (a * -1.5); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.8e-300], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.8 \cdot 10^{-300}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 1.80000000000000008e-300Initial program 73.6%
sqr-neg73.6%
sqr-neg73.6%
associate-*l*73.5%
Simplified73.5%
Applied egg-rr70.2%
Taylor expanded in b around -inf 62.0%
associate-*r/62.0%
*-commutative62.0%
associate-/l*62.0%
Simplified62.0%
clear-num61.9%
div-inv62.0%
metadata-eval62.0%
*-commutative62.0%
un-div-inv62.1%
*-commutative62.1%
Applied egg-rr62.1%
if 1.80000000000000008e-300 < b Initial program 35.8%
sqr-neg35.8%
sqr-neg35.8%
associate-*l*35.7%
Simplified35.7%
Taylor expanded in b around inf 63.2%
*-commutative63.2%
Simplified63.2%
Final simplification62.6%
(FPCore (a b c) :precision binary64 (if (<= b 1.35e-300) (/ b (* a -1.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.35e-300) {
tmp = b / (a * -1.5);
} 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.35d-300) then
tmp = b / (a * (-1.5d0))
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.35e-300) {
tmp = b / (a * -1.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.35e-300: tmp = b / (a * -1.5) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.35e-300) tmp = Float64(b / Float64(a * -1.5)); 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.35e-300) tmp = b / (a * -1.5); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.35e-300], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.35 \cdot 10^{-300}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 1.34999999999999998e-300Initial program 73.6%
sqr-neg73.6%
sqr-neg73.6%
associate-*l*73.5%
Simplified73.5%
Applied egg-rr70.2%
Taylor expanded in b around -inf 62.0%
associate-*r/62.0%
*-commutative62.0%
associate-/l*62.0%
Simplified62.0%
clear-num61.9%
div-inv62.0%
metadata-eval62.0%
*-commutative62.0%
un-div-inv62.1%
*-commutative62.1%
Applied egg-rr62.1%
if 1.34999999999999998e-300 < b Initial program 35.8%
sqr-neg35.8%
sqr-neg35.8%
associate-*l*35.7%
Simplified35.7%
Taylor expanded in b around inf 47.7%
expm1-log1p-u45.7%
expm1-undefine21.4%
associate-/l*21.6%
Applied egg-rr21.6%
expm1-define48.4%
associate-*r*48.5%
Simplified48.5%
Taylor expanded in a around 0 63.2%
associate-*r/63.3%
Simplified63.3%
Final simplification62.6%
(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 56.2%
sqr-neg56.2%
sqr-neg56.2%
associate-*l*56.1%
Simplified56.1%
Applied egg-rr56.1%
Taylor expanded in b around -inf 34.6%
associate-*r/34.6%
*-commutative34.6%
associate-/l*34.6%
Simplified34.6%
Final simplification34.6%
herbie shell --seed 2024067
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))