
(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 -5e+84)
(/ (* b (- (- 2.0) (* -1.5 (* a (/ c (pow b 2.0)))))) (* a 3.0))
(if (<= b 7.5e-106)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+84) {
tmp = (b * (-2.0 - (-1.5 * (a * (c / pow(b, 2.0)))))) / (a * 3.0);
} else if (b <= 7.5e-106) {
tmp = (sqrt(((b * b) - (c * (a * 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 <= (-5d+84)) then
tmp = (b * (-2.0d0 - ((-1.5d0) * (a * (c / (b ** 2.0d0)))))) / (a * 3.0d0)
else if (b <= 7.5d-106) then
tmp = (sqrt(((b * b) - (c * (a * 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 <= -5e+84) {
tmp = (b * (-2.0 - (-1.5 * (a * (c / Math.pow(b, 2.0)))))) / (a * 3.0);
} else if (b <= 7.5e-106) {
tmp = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e+84: tmp = (b * (-2.0 - (-1.5 * (a * (c / math.pow(b, 2.0)))))) / (a * 3.0) elif b <= 7.5e-106: tmp = (math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e+84) tmp = Float64(Float64(b * Float64(Float64(-2.0) - Float64(-1.5 * Float64(a * Float64(c / (b ^ 2.0)))))) / Float64(a * 3.0)); elseif (b <= 7.5e-106) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 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 <= -5e+84) tmp = (b * (-2.0 - (-1.5 * (a * (c / (b ^ 2.0)))))) / (a * 3.0); elseif (b <= 7.5e-106) tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e+84], N[(N[(b * N[((-2.0) - N[(-1.5 * N[(a * N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.5e-106], 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[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+84}:\\
\;\;\;\;\frac{b \cdot \left(\left(-2\right) - -1.5 \cdot \left(a \cdot \frac{c}{{b}^{2}}\right)\right)}{a \cdot 3}\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-106}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -5.0000000000000001e84Initial program 57.8%
sqr-neg57.8%
sqr-neg57.8%
associate-*l*57.8%
Simplified57.8%
Taylor expanded in b around -inf 85.9%
associate-*r*85.9%
mul-1-neg85.9%
associate-/l*93.6%
Simplified93.6%
if -5.0000000000000001e84 < b < 7.5000000000000002e-106Initial program 77.6%
if 7.5000000000000002e-106 < b Initial program 16.7%
sqr-neg16.7%
sqr-neg16.7%
associate-*l*16.8%
Simplified16.8%
Taylor expanded in b around inf 86.7%
*-commutative86.7%
Simplified86.7%
Final simplification84.9%
(FPCore (a b c)
:precision binary64
(if (<= b -7.6e+84)
(/ b (* -1.5 a))
(if (<= b 6.2e-104)
(/ (- (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 <= -7.6e+84) {
tmp = b / (-1.5 * a);
} else if (b <= 6.2e-104) {
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 <= (-7.6d+84)) then
tmp = b / ((-1.5d0) * a)
else if (b <= 6.2d-104) 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 <= -7.6e+84) {
tmp = b / (-1.5 * a);
} else if (b <= 6.2e-104) {
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 <= -7.6e+84: tmp = b / (-1.5 * a) elif b <= 6.2e-104: 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 <= -7.6e+84) tmp = Float64(b / Float64(-1.5 * a)); elseif (b <= 6.2e-104) 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 <= -7.6e+84) tmp = b / (-1.5 * a); elseif (b <= 6.2e-104) 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, -7.6e+84], N[(b / N[(-1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.2e-104], 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 -7.6 \cdot 10^{+84}:\\
\;\;\;\;\frac{b}{-1.5 \cdot a}\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{-104}:\\
\;\;\;\;\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 < -7.6000000000000002e84Initial program 57.8%
sqr-neg57.8%
sqr-neg57.8%
associate-*l*57.8%
Simplified57.8%
Applied egg-rr42.3%
Taylor expanded in b around -inf 93.4%
associate-*r/93.5%
*-commutative93.5%
associate-/l*93.3%
Simplified93.3%
add-cube-cbrt92.4%
pow392.4%
Applied egg-rr92.4%
rem-cube-cbrt93.3%
clear-num93.2%
un-div-inv93.3%
div-inv93.6%
metadata-eval93.6%
Applied egg-rr93.6%
if -7.6000000000000002e84 < b < 6.19999999999999951e-104Initial program 77.6%
sqr-neg77.6%
sqr-neg77.6%
associate-*l*77.6%
Simplified77.6%
if 6.19999999999999951e-104 < b Initial program 16.7%
sqr-neg16.7%
sqr-neg16.7%
associate-*l*16.8%
Simplified16.8%
Taylor expanded in b around inf 86.7%
*-commutative86.7%
Simplified86.7%
Final simplification84.8%
(FPCore (a b c)
:precision binary64
(if (<= b -2.8e+84)
(/ b (* -1.5 a))
(if (<= b 3.5e-104)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.8e+84) {
tmp = b / (-1.5 * a);
} else if (b <= 3.5e-104) {
tmp = (sqrt(((b * b) - (c * (a * 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.8d+84)) then
tmp = b / ((-1.5d0) * a)
else if (b <= 3.5d-104) then
tmp = (sqrt(((b * b) - (c * (a * 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.8e+84) {
tmp = b / (-1.5 * a);
} else if (b <= 3.5e-104) {
tmp = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.8e+84: tmp = b / (-1.5 * a) elif b <= 3.5e-104: tmp = (math.sqrt(((b * b) - (c * (a * 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.8e+84) tmp = Float64(b / Float64(-1.5 * a)); elseif (b <= 3.5e-104) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 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.8e+84) tmp = b / (-1.5 * a); elseif (b <= 3.5e-104) tmp = (sqrt(((b * b) - (c * (a * 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.8e+84], N[(b / N[(-1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.5e-104], 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[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.8 \cdot 10^{+84}:\\
\;\;\;\;\frac{b}{-1.5 \cdot a}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-104}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.79999999999999982e84Initial program 57.8%
sqr-neg57.8%
sqr-neg57.8%
associate-*l*57.8%
Simplified57.8%
Applied egg-rr42.3%
Taylor expanded in b around -inf 93.4%
associate-*r/93.5%
*-commutative93.5%
associate-/l*93.3%
Simplified93.3%
add-cube-cbrt92.4%
pow392.4%
Applied egg-rr92.4%
rem-cube-cbrt93.3%
clear-num93.2%
un-div-inv93.3%
div-inv93.6%
metadata-eval93.6%
Applied egg-rr93.6%
if -2.79999999999999982e84 < b < 3.50000000000000029e-104Initial program 77.6%
if 3.50000000000000029e-104 < b Initial program 16.7%
sqr-neg16.7%
sqr-neg16.7%
associate-*l*16.8%
Simplified16.8%
Taylor expanded in b around inf 86.7%
*-commutative86.7%
Simplified86.7%
Final simplification84.9%
(FPCore (a b c)
:precision binary64
(if (<= b -5e-84)
(/ b (* -1.5 a))
(if (<= b 7.8e-104)
(* 0.3333333333333333 (/ (+ b (sqrt (* (* a c) -3.0))) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-84) {
tmp = b / (-1.5 * a);
} else if (b <= 7.8e-104) {
tmp = 0.3333333333333333 * ((b + sqrt(((a * c) * -3.0))) / 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 <= (-5d-84)) then
tmp = b / ((-1.5d0) * a)
else if (b <= 7.8d-104) then
tmp = 0.3333333333333333d0 * ((b + sqrt(((a * c) * (-3.0d0)))) / 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 <= -5e-84) {
tmp = b / (-1.5 * a);
} else if (b <= 7.8e-104) {
tmp = 0.3333333333333333 * ((b + Math.sqrt(((a * c) * -3.0))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-84: tmp = b / (-1.5 * a) elif b <= 7.8e-104: tmp = 0.3333333333333333 * ((b + math.sqrt(((a * c) * -3.0))) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-84) tmp = Float64(b / Float64(-1.5 * a)); elseif (b <= 7.8e-104) tmp = Float64(0.3333333333333333 * Float64(Float64(b + sqrt(Float64(Float64(a * c) * -3.0))) / 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 <= -5e-84) tmp = b / (-1.5 * a); elseif (b <= 7.8e-104) tmp = 0.3333333333333333 * ((b + sqrt(((a * c) * -3.0))) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-84], N[(b / N[(-1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.8e-104], N[(0.3333333333333333 * N[(N[(b + N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-84}:\\
\;\;\;\;\frac{b}{-1.5 \cdot a}\\
\mathbf{elif}\;b \leq 7.8 \cdot 10^{-104}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{b + \sqrt{\left(a \cdot c\right) \cdot -3}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -5.0000000000000002e-84Initial program 70.8%
sqr-neg70.8%
sqr-neg70.8%
associate-*l*70.8%
Simplified70.8%
Applied egg-rr52.0%
Taylor expanded in b around -inf 87.4%
associate-*r/87.4%
*-commutative87.4%
associate-/l*87.3%
Simplified87.3%
add-cube-cbrt86.4%
pow386.4%
Applied egg-rr86.4%
rem-cube-cbrt87.3%
clear-num87.2%
un-div-inv87.3%
div-inv87.5%
metadata-eval87.5%
Applied egg-rr87.5%
if -5.0000000000000002e-84 < b < 7.8000000000000004e-104Initial program 68.4%
sqr-neg68.4%
sqr-neg68.4%
associate-*l*68.3%
Simplified68.3%
Taylor expanded in b around 0 66.9%
*-commutative66.9%
*-commutative66.9%
associate-*r*67.0%
Simplified67.0%
*-un-lft-identity67.0%
times-frac66.8%
metadata-eval66.8%
add-sqr-sqrt30.7%
sqrt-unprod66.1%
sqr-neg66.1%
sqrt-unprod35.9%
add-sqr-sqrt65.9%
*-commutative65.9%
*-commutative65.9%
associate-*r*67.4%
Applied egg-rr67.4%
if 7.8000000000000004e-104 < b Initial program 16.7%
sqr-neg16.7%
sqr-neg16.7%
associate-*l*16.8%
Simplified16.8%
Taylor expanded in b around inf 86.7%
*-commutative86.7%
Simplified86.7%
Final simplification82.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.95e-83)
(/ b (* -1.5 a))
(if (<= b 2.75e-104)
(/ (/ (+ b (sqrt (* (* a c) -3.0))) 3.0) a)
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.95e-83) {
tmp = b / (-1.5 * a);
} else if (b <= 2.75e-104) {
tmp = ((b + sqrt(((a * c) * -3.0))) / 3.0) / 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.95d-83)) then
tmp = b / ((-1.5d0) * a)
else if (b <= 2.75d-104) then
tmp = ((b + sqrt(((a * c) * (-3.0d0)))) / 3.0d0) / 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.95e-83) {
tmp = b / (-1.5 * a);
} else if (b <= 2.75e-104) {
tmp = ((b + Math.sqrt(((a * c) * -3.0))) / 3.0) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.95e-83: tmp = b / (-1.5 * a) elif b <= 2.75e-104: tmp = ((b + math.sqrt(((a * c) * -3.0))) / 3.0) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.95e-83) tmp = Float64(b / Float64(-1.5 * a)); elseif (b <= 2.75e-104) tmp = Float64(Float64(Float64(b + sqrt(Float64(Float64(a * c) * -3.0))) / 3.0) / 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.95e-83) tmp = b / (-1.5 * a); elseif (b <= 2.75e-104) tmp = ((b + sqrt(((a * c) * -3.0))) / 3.0) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.95e-83], N[(b / N[(-1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.75e-104], N[(N[(N[(b + N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.95 \cdot 10^{-83}:\\
\;\;\;\;\frac{b}{-1.5 \cdot a}\\
\mathbf{elif}\;b \leq 2.75 \cdot 10^{-104}:\\
\;\;\;\;\frac{\frac{b + \sqrt{\left(a \cdot c\right) \cdot -3}}{3}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.95e-83Initial program 70.8%
sqr-neg70.8%
sqr-neg70.8%
associate-*l*70.8%
Simplified70.8%
Applied egg-rr52.0%
Taylor expanded in b around -inf 87.4%
associate-*r/87.4%
*-commutative87.4%
associate-/l*87.3%
Simplified87.3%
add-cube-cbrt86.4%
pow386.4%
Applied egg-rr86.4%
rem-cube-cbrt87.3%
clear-num87.2%
un-div-inv87.3%
div-inv87.5%
metadata-eval87.5%
Applied egg-rr87.5%
if -1.95e-83 < b < 2.7499999999999999e-104Initial program 68.4%
sqr-neg68.4%
sqr-neg68.4%
associate-*l*68.3%
Simplified68.3%
Taylor expanded in b around 0 66.9%
div-inv66.9%
add-sqr-sqrt30.7%
sqrt-unprod66.2%
sqr-neg66.2%
sqrt-prod36.0%
add-sqr-sqrt66.0%
associate-*r*65.8%
*-commutative65.8%
Applied egg-rr65.8%
un-div-inv66.0%
*-commutative66.0%
associate-/r*66.0%
+-commutative66.0%
associate-*l*67.6%
Applied egg-rr67.6%
if 2.7499999999999999e-104 < b Initial program 16.7%
sqr-neg16.7%
sqr-neg16.7%
associate-*l*16.8%
Simplified16.8%
Taylor expanded in b around inf 86.7%
*-commutative86.7%
Simplified86.7%
Final simplification82.2%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (* b (/ -0.6666666666666666 a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
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 <= (-4d-310)) 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 <= -4e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) 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 <= -4e-310) tmp = b * (-0.6666666666666666 / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], 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 -4 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 69.7%
sqr-neg69.7%
sqr-neg69.7%
associate-*l*69.7%
Simplified69.7%
Applied egg-rr56.6%
Taylor expanded in b around -inf 69.2%
associate-*r/69.2%
*-commutative69.2%
associate-/l*69.1%
Simplified69.1%
if -3.999999999999988e-310 < b Initial program 31.0%
sqr-neg31.0%
sqr-neg31.0%
associate-*l*31.0%
Simplified31.0%
Taylor expanded in b around inf 54.6%
associate-/l*61.7%
Simplified61.7%
Taylor expanded in a around 0 70.0%
associate-*r/70.0%
*-rgt-identity70.0%
times-frac69.8%
/-rgt-identity69.8%
Simplified69.8%
Final simplification69.4%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (* -0.6666666666666666 (/ b a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
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 <= (-4d-310)) 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 <= -4e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(-0.6666666666666666 * Float64(b / 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 <= -4e-310) tmp = -0.6666666666666666 * (b / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 69.7%
sqr-neg69.7%
sqr-neg69.7%
associate-*l*69.7%
Simplified69.7%
Taylor expanded in b around -inf 69.2%
*-commutative69.2%
Simplified69.2%
if -3.999999999999988e-310 < b Initial program 31.0%
sqr-neg31.0%
sqr-neg31.0%
associate-*l*31.0%
Simplified31.0%
Taylor expanded in b around inf 54.6%
associate-/l*61.7%
Simplified61.7%
Taylor expanded in a around 0 70.0%
associate-*r/70.0%
*-rgt-identity70.0%
times-frac69.8%
/-rgt-identity69.8%
Simplified69.8%
Final simplification69.5%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (* -0.6666666666666666 (/ b a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-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 <= (-4d-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 <= -4e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-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 <= -4e-310) tmp = -0.6666666666666666 * (b / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-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 -4 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 69.7%
sqr-neg69.7%
sqr-neg69.7%
associate-*l*69.7%
Simplified69.7%
Taylor expanded in b around -inf 69.2%
*-commutative69.2%
Simplified69.2%
if -3.999999999999988e-310 < b Initial program 31.0%
sqr-neg31.0%
sqr-neg31.0%
associate-*l*31.0%
Simplified31.0%
Taylor expanded in b around inf 70.0%
*-commutative70.0%
Simplified70.0%
Final simplification69.6%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (/ -0.6666666666666666 (/ a b)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-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 <= (-4d-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 <= -4e-310) {
tmp = -0.6666666666666666 / (a / b);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = -0.6666666666666666 / (a / b) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-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 <= -4e-310) tmp = -0.6666666666666666 / (a / b); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-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 -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 69.7%
sqr-neg69.7%
sqr-neg69.7%
associate-*l*69.7%
Simplified69.7%
Taylor expanded in b around -inf 69.2%
*-commutative69.2%
Simplified69.2%
associate-*l/69.2%
Applied egg-rr69.2%
clear-num69.2%
inv-pow69.2%
*-un-lft-identity69.2%
*-commutative69.2%
times-frac69.2%
metadata-eval69.2%
Applied egg-rr69.2%
unpow-169.2%
associate-/r*69.2%
metadata-eval69.2%
Simplified69.2%
if -3.999999999999988e-310 < b Initial program 31.0%
sqr-neg31.0%
sqr-neg31.0%
associate-*l*31.0%
Simplified31.0%
Taylor expanded in b around inf 70.0%
*-commutative70.0%
Simplified70.0%
Final simplification69.6%
(FPCore (a b c) :precision binary64 (if (<= b 3.3e-308) (/ b (* -1.5 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.3e-308) {
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 <= 3.3d-308) 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 <= 3.3e-308) {
tmp = b / (-1.5 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.3e-308: tmp = b / (-1.5 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.3e-308) 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 <= 3.3e-308) tmp = b / (-1.5 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.3e-308], 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 3.3 \cdot 10^{-308}:\\
\;\;\;\;\frac{b}{-1.5 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 3.2999999999999998e-308Initial program 69.7%
sqr-neg69.7%
sqr-neg69.7%
associate-*l*69.7%
Simplified69.7%
Applied egg-rr56.6%
Taylor expanded in b around -inf 69.2%
associate-*r/69.2%
*-commutative69.2%
associate-/l*69.1%
Simplified69.1%
add-cube-cbrt68.4%
pow368.4%
Applied egg-rr68.4%
rem-cube-cbrt69.1%
clear-num69.1%
un-div-inv69.1%
div-inv69.3%
metadata-eval69.3%
Applied egg-rr69.3%
if 3.2999999999999998e-308 < b Initial program 31.0%
sqr-neg31.0%
sqr-neg31.0%
associate-*l*31.0%
Simplified31.0%
Taylor expanded in b around inf 70.0%
*-commutative70.0%
Simplified70.0%
Final simplification69.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 50.8%
sqr-neg50.8%
sqr-neg50.8%
associate-*l*50.8%
Simplified50.8%
Applied egg-rr48.8%
Taylor expanded in b around -inf 36.7%
associate-*r/36.7%
*-commutative36.7%
associate-/l*36.7%
Simplified36.7%
Final simplification36.7%
herbie shell --seed 2024073
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))