
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -5.5e+131)
(/ (/ b -1.5) a)
(if (<= b 5.8e-121)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e+131) {
tmp = (b / -1.5) / a;
} else if (b <= 5.8e-121) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5.5d+131)) then
tmp = (b / (-1.5d0)) / a
else if (b <= 5.8d-121) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e+131) {
tmp = (b / -1.5) / a;
} else if (b <= 5.8e-121) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.5e+131: tmp = (b / -1.5) / a elif b <= 5.8e-121: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.5e+131) tmp = Float64(Float64(b / -1.5) / a); elseif (b <= 5.8e-121) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.5e+131) tmp = (b / -1.5) / a; elseif (b <= 5.8e-121) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.5e+131], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 5.8e-121], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{+131}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{elif}\;b \leq 5.8 \cdot 10^{-121}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -5.49999999999999971e131Initial program 45.8%
sqr-neg45.8%
sqr-neg45.8%
associate-*l*45.8%
Simplified45.8%
Taylor expanded in b around -inf 97.9%
*-commutative97.9%
Simplified97.9%
*-commutative97.9%
clear-num97.7%
un-div-inv97.7%
Applied egg-rr97.7%
div-inv97.7%
metadata-eval97.7%
clear-num97.9%
times-frac97.8%
*-commutative97.8%
times-frac97.8%
Applied egg-rr97.8%
associate-*l/98.0%
*-lft-identity98.0%
Simplified98.0%
if -5.49999999999999971e131 < b < 5.8e-121Initial program 84.4%
if 5.8e-121 < b Initial program 16.8%
sqr-neg16.8%
sqr-neg16.8%
associate-*l*16.8%
Simplified16.8%
Taylor expanded in b around inf 85.1%
*-commutative85.1%
Simplified85.1%
Final simplification87.3%
(FPCore (a b c)
:precision binary64
(if (<= b -8.2e+129)
(/ (/ b -1.5) a)
(if (<= b 7e-118)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8.2e+129) {
tmp = (b / -1.5) / a;
} else if (b <= 7e-118) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-8.2d+129)) then
tmp = (b / (-1.5d0)) / a
else if (b <= 7d-118) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -8.2e+129) {
tmp = (b / -1.5) / a;
} else if (b <= 7e-118) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.2e+129: tmp = (b / -1.5) / a elif b <= 7e-118: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8.2e+129) tmp = Float64(Float64(b / -1.5) / a); elseif (b <= 7e-118) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8.2e+129) tmp = (b / -1.5) / a; elseif (b <= 7e-118) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8.2e+129], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 7e-118], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.2 \cdot 10^{+129}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{elif}\;b \leq 7 \cdot 10^{-118}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -8.2000000000000005e129Initial program 45.8%
sqr-neg45.8%
sqr-neg45.8%
associate-*l*45.8%
Simplified45.8%
Taylor expanded in b around -inf 97.9%
*-commutative97.9%
Simplified97.9%
*-commutative97.9%
clear-num97.7%
un-div-inv97.7%
Applied egg-rr97.7%
div-inv97.7%
metadata-eval97.7%
clear-num97.9%
times-frac97.8%
*-commutative97.8%
times-frac97.8%
Applied egg-rr97.8%
associate-*l/98.0%
*-lft-identity98.0%
Simplified98.0%
if -8.2000000000000005e129 < b < 7e-118Initial program 84.4%
sqr-neg84.4%
sqr-neg84.4%
associate-*l*84.3%
Simplified84.3%
if 7e-118 < b Initial program 16.8%
sqr-neg16.8%
sqr-neg16.8%
associate-*l*16.8%
Simplified16.8%
Taylor expanded in b around inf 85.1%
*-commutative85.1%
Simplified85.1%
Final simplification87.3%
(FPCore (a b c)
:precision binary64
(if (<= b -2.3e-130)
(/ (/ b -1.5) a)
(if (<= b 1.55e-118)
(/ (- (sqrt (* (* a c) -3.0)) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.3e-130) {
tmp = (b / -1.5) / a;
} else if (b <= 1.55e-118) {
tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2.3d-130)) then
tmp = (b / (-1.5d0)) / a
else if (b <= 1.55d-118) then
tmp = (sqrt(((a * c) * (-3.0d0))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.3e-130) {
tmp = (b / -1.5) / a;
} else if (b <= 1.55e-118) {
tmp = (Math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.3e-130: tmp = (b / -1.5) / a elif b <= 1.55e-118: tmp = (math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.3e-130) tmp = Float64(Float64(b / -1.5) / a); elseif (b <= 1.55e-118) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.3e-130) tmp = (b / -1.5) / a; elseif (b <= 1.55e-118) tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.3e-130], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.55e-118], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.3 \cdot 10^{-130}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{elif}\;b \leq 1.55 \cdot 10^{-118}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.3000000000000001e-130Initial program 67.5%
sqr-neg67.5%
sqr-neg67.5%
associate-*l*67.4%
Simplified67.4%
Taylor expanded in b around -inf 83.5%
*-commutative83.5%
Simplified83.5%
*-commutative83.5%
clear-num83.4%
un-div-inv83.5%
Applied egg-rr83.5%
div-inv83.4%
metadata-eval83.4%
clear-num83.5%
times-frac83.6%
*-commutative83.6%
times-frac83.6%
Applied egg-rr83.6%
associate-*l/83.7%
*-lft-identity83.7%
Simplified83.7%
if -2.3000000000000001e-130 < b < 1.5500000000000001e-118Initial program 80.4%
sqr-neg80.4%
sqr-neg80.4%
associate-*l*80.3%
Simplified80.3%
Taylor expanded in b around 0 75.4%
if 1.5500000000000001e-118 < b Initial program 16.8%
sqr-neg16.8%
sqr-neg16.8%
associate-*l*16.8%
Simplified16.8%
Taylor expanded in b around inf 85.1%
*-commutative85.1%
Simplified85.1%
Final simplification82.7%
(FPCore (a b c) :precision binary64 (if (<= b 1.55e-307) (/ (/ b -1.5) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.55e-307) {
tmp = (b / -1.5) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1.55d-307) then
tmp = (b / (-1.5d0)) / a
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.55e-307) {
tmp = (b / -1.5) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.55e-307: tmp = (b / -1.5) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.55e-307) tmp = Float64(Float64(b / -1.5) / a); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.55e-307) tmp = (b / -1.5) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.55e-307], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.55 \cdot 10^{-307}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.5499999999999999e-307Initial program 70.7%
sqr-neg70.7%
sqr-neg70.7%
associate-*l*70.6%
Simplified70.6%
Taylor expanded in b around -inf 72.3%
*-commutative72.3%
Simplified72.3%
*-commutative72.3%
clear-num72.2%
un-div-inv72.3%
Applied egg-rr72.3%
div-inv72.2%
metadata-eval72.2%
clear-num72.3%
times-frac72.4%
*-commutative72.4%
times-frac72.3%
Applied egg-rr72.3%
associate-*l/72.4%
*-lft-identity72.4%
Simplified72.4%
if 1.5499999999999999e-307 < b Initial program 29.1%
sqr-neg29.1%
sqr-neg29.1%
associate-*l*29.1%
Simplified29.1%
Taylor expanded in b around inf 71.6%
*-commutative71.6%
Simplified71.6%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ b (* -1.5 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = b / (-1.5 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2d-310)) then
tmp = b / ((-1.5d0) * a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = b / (-1.5 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = b / (-1.5 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(b / Float64(-1.5 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = b / (-1.5 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(b / N[(-1.5 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{-1.5 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 70.7%
sqr-neg70.7%
sqr-neg70.7%
associate-*l*70.6%
Simplified70.6%
Taylor expanded in b around -inf 72.3%
*-commutative72.3%
Simplified72.3%
Taylor expanded in b around 0 72.3%
*-commutative72.3%
associate-*l/72.3%
associate-/l*72.2%
Simplified72.2%
clear-num72.1%
un-div-inv72.2%
div-inv72.4%
metadata-eval72.4%
Applied egg-rr72.4%
if -1.999999999999994e-310 < b Initial program 29.1%
sqr-neg29.1%
sqr-neg29.1%
associate-*l*29.1%
Simplified29.1%
Taylor expanded in b around inf 71.6%
*-commutative71.6%
Simplified71.6%
Final simplification72.0%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ -0.6666666666666666 (/ a b)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = -0.6666666666666666 / (a / b);
} 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 <= (-2d-310)) then
tmp = (-0.6666666666666666d0) / (a / b)
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 <= -2e-310) {
tmp = -0.6666666666666666 / (a / b);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = -0.6666666666666666 / (a / b) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(-0.6666666666666666 / Float64(a / b)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = -0.6666666666666666 / (a / b); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 70.7%
sqr-neg70.7%
sqr-neg70.7%
associate-*l*70.6%
Simplified70.6%
Taylor expanded in b around -inf 72.3%
*-commutative72.3%
Simplified72.3%
*-commutative72.3%
clear-num72.2%
un-div-inv72.3%
Applied egg-rr72.3%
if -1.999999999999994e-310 < b Initial program 29.1%
sqr-neg29.1%
sqr-neg29.1%
associate-*l*29.1%
Simplified29.1%
Taylor expanded in b around inf 71.6%
*-commutative71.6%
Simplified71.6%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (* -0.6666666666666666 (/ b a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = -0.6666666666666666 * (b / 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 <= (-2d-310)) then
tmp = (-0.6666666666666666d0) * (b / 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 <= -2e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(-0.6666666666666666 * Float64(b / 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 <= -2e-310) tmp = -0.6666666666666666 * (b / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 70.7%
sqr-neg70.7%
sqr-neg70.7%
associate-*l*70.6%
Simplified70.6%
Taylor expanded in b around -inf 72.3%
*-commutative72.3%
Simplified72.3%
if -1.999999999999994e-310 < b Initial program 29.1%
sqr-neg29.1%
sqr-neg29.1%
associate-*l*29.1%
Simplified29.1%
Taylor expanded in b around inf 71.6%
*-commutative71.6%
Simplified71.6%
Final simplification71.9%
(FPCore (a b c) :precision binary64 (* -0.6666666666666666 (/ b a)))
double code(double a, double b, double c) {
return -0.6666666666666666 * (b / a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-0.6666666666666666d0) * (b / a)
end function
public static double code(double a, double b, double c) {
return -0.6666666666666666 * (b / a);
}
def code(a, b, c): return -0.6666666666666666 * (b / a)
function code(a, b, c) return Float64(-0.6666666666666666 * Float64(b / a)) end
function tmp = code(a, b, c) tmp = -0.6666666666666666 * (b / a); end
code[a_, b_, c_] := N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.6666666666666666 \cdot \frac{b}{a}
\end{array}
Initial program 48.8%
sqr-neg48.8%
sqr-neg48.8%
associate-*l*48.7%
Simplified48.7%
Taylor expanded in b around -inf 35.7%
*-commutative35.7%
Simplified35.7%
Final simplification35.7%
(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 48.8%
sqr-neg48.8%
sqr-neg48.8%
associate-*l*48.7%
Simplified48.7%
Taylor expanded in b around -inf 35.7%
*-commutative35.7%
Simplified35.7%
Taylor expanded in b around 0 35.7%
*-commutative35.7%
associate-*l/35.7%
associate-/l*35.6%
Simplified35.6%
herbie shell --seed 2024148
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))