
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -1.5e+33)
(+ (/ (* b -0.6666666666666666) a) (* (/ c b) 0.5))
(if (<= b 8e-127)
(* (- (pow (fma b b (* c (* a -3.0))) 0.5) b) (/ 1.0 (* a 3.0)))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e+33) {
tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5);
} else if (b <= 8e-127) {
tmp = (pow(fma(b, b, (c * (a * -3.0))), 0.5) - b) * (1.0 / (a * 3.0));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.5e+33) tmp = Float64(Float64(Float64(b * -0.6666666666666666) / a) + Float64(Float64(c / b) * 0.5)); elseif (b <= 8e-127) tmp = Float64(Float64((fma(b, b, Float64(c * Float64(a * -3.0))) ^ 0.5) - b) * Float64(1.0 / Float64(a * 3.0))); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.5e+33], N[(N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e-127], N[(N[(N[Power[N[(b * b + N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] - b), $MachinePrecision] * N[(1.0 / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \cdot 10^{+33}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 8 \cdot 10^{-127}:\\
\;\;\;\;\left({\left(\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)\right)}^{0.5} - b\right) \cdot \frac{1}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.49999999999999992e33Initial program 56.6%
add-sqr-sqrt56.6%
pow256.6%
pow1/256.6%
sqrt-pow156.6%
fma-neg56.8%
*-commutative56.8%
distribute-rgt-neg-in56.8%
*-commutative56.8%
distribute-rgt-neg-in56.8%
metadata-eval56.8%
metadata-eval56.8%
Applied egg-rr56.8%
Taylor expanded in b around -inf 96.3%
associate-*r*96.3%
metadata-eval96.3%
*-commutative96.3%
Simplified96.3%
associate-*r/96.3%
Applied egg-rr96.3%
if -1.49999999999999992e33 < b < 8.0000000000000002e-127Initial program 84.4%
add-sqr-sqrt84.0%
pow284.0%
pow1/284.0%
sqrt-pow184.1%
fma-neg84.1%
*-commutative84.1%
distribute-rgt-neg-in84.1%
*-commutative84.1%
distribute-rgt-neg-in84.1%
metadata-eval84.1%
metadata-eval84.1%
Applied egg-rr84.1%
div-inv84.1%
pow-pow84.4%
metadata-eval84.4%
*-commutative84.4%
Applied egg-rr84.4%
if 8.0000000000000002e-127 < b Initial program 21.4%
Taylor expanded in b around inf 84.7%
Final simplification88.3%
(FPCore (a b c)
:precision binary64
(if (<= b -1.5e+33)
(+ (/ (* b -0.6666666666666666) a) (* (/ c b) 0.5))
(if (<= b 1.35e-126)
(/ (- (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 <= -1.5e+33) {
tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5);
} else if (b <= 1.35e-126) {
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 <= (-1.5d+33)) then
tmp = ((b * (-0.6666666666666666d0)) / a) + ((c / b) * 0.5d0)
else if (b <= 1.35d-126) 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 <= -1.5e+33) {
tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5);
} else if (b <= 1.35e-126) {
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 <= -1.5e+33: tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5) elif b <= 1.35e-126: 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 <= -1.5e+33) tmp = Float64(Float64(Float64(b * -0.6666666666666666) / a) + Float64(Float64(c / b) * 0.5)); elseif (b <= 1.35e-126) 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 <= -1.5e+33) tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5); elseif (b <= 1.35e-126) 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, -1.5e+33], N[(N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e-126], 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 -1.5 \cdot 10^{+33}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-126}:\\
\;\;\;\;\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 < -1.49999999999999992e33Initial program 56.6%
add-sqr-sqrt56.6%
pow256.6%
pow1/256.6%
sqrt-pow156.6%
fma-neg56.8%
*-commutative56.8%
distribute-rgt-neg-in56.8%
*-commutative56.8%
distribute-rgt-neg-in56.8%
metadata-eval56.8%
metadata-eval56.8%
Applied egg-rr56.8%
Taylor expanded in b around -inf 96.3%
associate-*r*96.3%
metadata-eval96.3%
*-commutative96.3%
Simplified96.3%
associate-*r/96.3%
Applied egg-rr96.3%
if -1.49999999999999992e33 < b < 1.34999999999999998e-126Initial program 84.4%
if 1.34999999999999998e-126 < b Initial program 21.4%
Taylor expanded in b around inf 84.7%
Final simplification88.3%
(FPCore (a b c)
:precision binary64
(if (<= b -2.2e-71)
(+ (/ (* b -0.6666666666666666) a) (* (/ c b) 0.5))
(if (<= b 1.35e-126)
(* 0.3333333333333333 (/ (- (sqrt (* c (* a -3.0))) b) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.2e-71) {
tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5);
} else if (b <= 1.35e-126) {
tmp = 0.3333333333333333 * ((sqrt((c * (a * -3.0))) - 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 <= (-2.2d-71)) then
tmp = ((b * (-0.6666666666666666d0)) / a) + ((c / b) * 0.5d0)
else if (b <= 1.35d-126) then
tmp = 0.3333333333333333d0 * ((sqrt((c * (a * (-3.0d0)))) - 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 <= -2.2e-71) {
tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5);
} else if (b <= 1.35e-126) {
tmp = 0.3333333333333333 * ((Math.sqrt((c * (a * -3.0))) - b) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.2e-71: tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5) elif b <= 1.35e-126: tmp = 0.3333333333333333 * ((math.sqrt((c * (a * -3.0))) - b) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.2e-71) tmp = Float64(Float64(Float64(b * -0.6666666666666666) / a) + Float64(Float64(c / b) * 0.5)); elseif (b <= 1.35e-126) tmp = Float64(0.3333333333333333 * Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - 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 <= -2.2e-71) tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5); elseif (b <= 1.35e-126) tmp = 0.3333333333333333 * ((sqrt((c * (a * -3.0))) - b) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.2e-71], N[(N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e-126], N[(0.3333333333333333 * N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.2 \cdot 10^{-71}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-126}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.19999999999999997e-71Initial program 64.8%
add-sqr-sqrt64.7%
pow264.7%
pow1/264.7%
sqrt-pow164.7%
fma-neg64.9%
*-commutative64.9%
distribute-rgt-neg-in64.9%
*-commutative64.9%
distribute-rgt-neg-in64.9%
metadata-eval64.9%
metadata-eval64.9%
Applied egg-rr64.9%
Taylor expanded in b around -inf 90.9%
associate-*r*90.9%
metadata-eval90.9%
*-commutative90.9%
Simplified90.9%
associate-*r/91.0%
Applied egg-rr91.0%
if -2.19999999999999997e-71 < b < 1.34999999999999998e-126Initial program 81.5%
add-sqr-sqrt81.2%
pow281.2%
pow1/281.2%
sqrt-pow181.3%
fma-neg81.3%
*-commutative81.3%
distribute-rgt-neg-in81.3%
*-commutative81.3%
distribute-rgt-neg-in81.3%
metadata-eval81.3%
metadata-eval81.3%
Applied egg-rr81.3%
Taylor expanded in b around 0 75.3%
Taylor expanded in c around 0 45.1%
Simplified75.4%
if 1.34999999999999998e-126 < b Initial program 21.4%
Taylor expanded in b around inf 84.7%
Final simplification84.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.5e-70)
(+ (/ (* b -0.6666666666666666) a) (* (/ c b) 0.5))
(if (<= b 2.5e-127)
(* 0.3333333333333333 (/ (- (sqrt (* -3.0 (* a c))) b) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e-70) {
tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5);
} else if (b <= 2.5e-127) {
tmp = 0.3333333333333333 * ((sqrt((-3.0 * (a * c))) - 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 <= (-1.5d-70)) then
tmp = ((b * (-0.6666666666666666d0)) / a) + ((c / b) * 0.5d0)
else if (b <= 2.5d-127) then
tmp = 0.3333333333333333d0 * ((sqrt(((-3.0d0) * (a * c))) - 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 <= -1.5e-70) {
tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5);
} else if (b <= 2.5e-127) {
tmp = 0.3333333333333333 * ((Math.sqrt((-3.0 * (a * c))) - b) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.5e-70: tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5) elif b <= 2.5e-127: tmp = 0.3333333333333333 * ((math.sqrt((-3.0 * (a * c))) - b) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.5e-70) tmp = Float64(Float64(Float64(b * -0.6666666666666666) / a) + Float64(Float64(c / b) * 0.5)); elseif (b <= 2.5e-127) tmp = Float64(0.3333333333333333 * Float64(Float64(sqrt(Float64(-3.0 * Float64(a * c))) - 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 <= -1.5e-70) tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5); elseif (b <= 2.5e-127) tmp = 0.3333333333333333 * ((sqrt((-3.0 * (a * c))) - b) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.5e-70], N[(N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.5e-127], N[(0.3333333333333333 * N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \cdot 10^{-70}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 2.5 \cdot 10^{-127}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{-3 \cdot \left(a \cdot c\right)} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.5000000000000001e-70Initial program 64.8%
add-sqr-sqrt64.7%
pow264.7%
pow1/264.7%
sqrt-pow164.7%
fma-neg64.9%
*-commutative64.9%
distribute-rgt-neg-in64.9%
*-commutative64.9%
distribute-rgt-neg-in64.9%
metadata-eval64.9%
metadata-eval64.9%
Applied egg-rr64.9%
Taylor expanded in b around -inf 90.9%
associate-*r*90.9%
metadata-eval90.9%
*-commutative90.9%
Simplified90.9%
associate-*r/91.0%
Applied egg-rr91.0%
if -1.5000000000000001e-70 < b < 2.4999999999999999e-127Initial program 81.5%
add-sqr-sqrt81.2%
pow281.2%
pow1/281.2%
sqrt-pow181.3%
fma-neg81.3%
*-commutative81.3%
distribute-rgt-neg-in81.3%
*-commutative81.3%
distribute-rgt-neg-in81.3%
metadata-eval81.3%
metadata-eval81.3%
Applied egg-rr81.3%
Taylor expanded in b around 0 75.3%
Taylor expanded in c around 0 45.1%
Simplified75.4%
Taylor expanded in c around 0 75.6%
*-commutative75.6%
Simplified75.6%
if 2.4999999999999999e-127 < b Initial program 21.4%
Taylor expanded in b around inf 84.7%
Final simplification85.0%
(FPCore (a b c)
:precision binary64
(if (<= b -1.14e-69)
(+ (/ (* b -0.6666666666666666) a) (* (/ c b) 0.5))
(if (<= b 1.9e-126)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.14e-69) {
tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5);
} else if (b <= 1.9e-126) {
tmp = (sqrt((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 <= (-1.14d-69)) then
tmp = ((b * (-0.6666666666666666d0)) / a) + ((c / b) * 0.5d0)
else if (b <= 1.9d-126) then
tmp = (sqrt((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 <= -1.14e-69) {
tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5);
} else if (b <= 1.9e-126) {
tmp = (Math.sqrt((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 <= -1.14e-69: tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5) elif b <= 1.9e-126: tmp = (math.sqrt((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 <= -1.14e-69) tmp = Float64(Float64(Float64(b * -0.6666666666666666) / a) + Float64(Float64(c / b) * 0.5)); elseif (b <= 1.9e-126) tmp = Float64(Float64(sqrt(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 <= -1.14e-69) tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5); elseif (b <= 1.9e-126) tmp = (sqrt((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, -1.14e-69], N[(N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.9e-126], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $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 -1.14 \cdot 10^{-69}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-126}:\\
\;\;\;\;\frac{\sqrt{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 < -1.14000000000000006e-69Initial program 64.8%
add-sqr-sqrt64.7%
pow264.7%
pow1/264.7%
sqrt-pow164.7%
fma-neg64.9%
*-commutative64.9%
distribute-rgt-neg-in64.9%
*-commutative64.9%
distribute-rgt-neg-in64.9%
metadata-eval64.9%
metadata-eval64.9%
Applied egg-rr64.9%
Taylor expanded in b around -inf 90.9%
associate-*r*90.9%
metadata-eval90.9%
*-commutative90.9%
Simplified90.9%
associate-*r/91.0%
Applied egg-rr91.0%
if -1.14000000000000006e-69 < b < 1.8999999999999999e-126Initial program 81.5%
Taylor expanded in b around 0 75.5%
*-commutative75.5%
*-commutative75.5%
*-commutative75.5%
associate-*r*75.6%
Simplified75.6%
if 1.8999999999999999e-126 < b Initial program 21.4%
Taylor expanded in b around inf 84.7%
Final simplification85.0%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} 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)) + ((c / b) * 0.5d0)
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)) + ((c / b) * 0.5);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); 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)) + ((c / b) * 0.5); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $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} + \frac{c}{b} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 70.5%
Taylor expanded in b around -inf 70.8%
if -1.999999999999994e-310 < b Initial program 34.3%
Taylor expanded in b around inf 66.3%
Final simplification68.8%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (+ (/ (* b -0.6666666666666666) a) (* (/ c b) 0.5)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5);
} 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 * (-0.6666666666666666d0)) / a) + ((c / b) * 0.5d0)
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 * -0.6666666666666666) / a) + ((c / b) * 0.5);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = ((b * -0.6666666666666666) / a) + ((c / b) * 0.5) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(Float64(b * -0.6666666666666666) / a) + Float64(Float64(c / b) * 0.5)); 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 * -0.6666666666666666) / a) + ((c / b) * 0.5); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $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 \cdot -0.6666666666666666}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 70.5%
add-sqr-sqrt70.3%
pow270.3%
pow1/270.3%
sqrt-pow170.3%
fma-neg70.5%
*-commutative70.5%
distribute-rgt-neg-in70.5%
*-commutative70.5%
distribute-rgt-neg-in70.5%
metadata-eval70.5%
metadata-eval70.5%
Applied egg-rr70.5%
Taylor expanded in b around -inf 70.8%
associate-*r*70.8%
metadata-eval70.8%
*-commutative70.8%
Simplified70.8%
associate-*r/70.8%
Applied egg-rr70.8%
if -1.999999999999994e-310 < b Initial program 34.3%
Taylor expanded in b around inf 66.3%
Final simplification68.9%
(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.5%
Taylor expanded in b around -inf 70.5%
*-commutative70.5%
Simplified70.5%
if -1.999999999999994e-310 < b Initial program 34.3%
Taylor expanded in b around inf 66.3%
Final simplification68.7%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ (* b -0.6666666666666666) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
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 <= (-2d-310)) 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 <= -2e-310) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = (b * -0.6666666666666666) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(b * -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 <= -2e-310) tmp = (b * -0.6666666666666666) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $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 \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 70.5%
Taylor expanded in b around -inf 70.5%
*-commutative70.5%
Simplified70.5%
associate-*l/70.5%
Applied egg-rr70.5%
if -1.999999999999994e-310 < b Initial program 34.3%
Taylor expanded in b around inf 66.3%
Final simplification68.7%
(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 55.0%
Taylor expanded in b around inf 29.6%
Final simplification29.6%
herbie shell --seed 2023187
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))