
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -8.5e+154)
(/ (* b -0.6666666666666666) a)
(if (<= b 4.8e-99)
(/ (- (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 <= -8.5e+154) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 4.8e-99) {
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 <= (-8.5d+154)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 4.8d-99) 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 <= -8.5e+154) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 4.8e-99) {
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 <= -8.5e+154: tmp = (b * -0.6666666666666666) / a elif b <= 4.8e-99: 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 <= -8.5e+154) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 4.8e-99) 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 <= -8.5e+154) tmp = (b * -0.6666666666666666) / a; elseif (b <= 4.8e-99) 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, -8.5e+154], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 4.8e-99], 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 -8.5 \cdot 10^{+154}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 4.8 \cdot 10^{-99}:\\
\;\;\;\;\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 < -8.5000000000000002e154Initial program 31.0%
sqr-neg31.0%
sqr-neg31.0%
associate-*l*31.0%
Simplified31.0%
Taylor expanded in b around -inf 99.6%
*-commutative99.6%
Simplified99.6%
associate-*l/99.8%
Applied egg-rr99.8%
if -8.5000000000000002e154 < b < 4.8000000000000001e-99Initial program 82.7%
if 4.8000000000000001e-99 < b Initial program 15.3%
sqr-neg15.3%
sqr-neg15.3%
associate-*l*15.3%
Simplified15.3%
Taylor expanded in b around inf 86.5%
associate-*r/86.6%
Applied egg-rr86.6%
Final simplification86.8%
(FPCore (a b c)
:precision binary64
(if (<= b -2e+124)
(/ (* b -2.0) (* a 3.0))
(if (<= b 4.8e-99)
(* (- (sqrt (- (* b b) (* a (* 3.0 c)))) b) (/ 0.3333333333333333 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e+124) {
tmp = (b * -2.0) / (a * 3.0);
} else if (b <= 4.8e-99) {
tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) * (0.3333333333333333 / 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 <= (-2d+124)) then
tmp = (b * (-2.0d0)) / (a * 3.0d0)
else if (b <= 4.8d-99) then
tmp = (sqrt(((b * b) - (a * (3.0d0 * c)))) - b) * (0.3333333333333333d0 / 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 <= -2e+124) {
tmp = (b * -2.0) / (a * 3.0);
} else if (b <= 4.8e-99) {
tmp = (Math.sqrt(((b * b) - (a * (3.0 * c)))) - b) * (0.3333333333333333 / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e+124: tmp = (b * -2.0) / (a * 3.0) elif b <= 4.8e-99: tmp = (math.sqrt(((b * b) - (a * (3.0 * c)))) - b) * (0.3333333333333333 / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e+124) tmp = Float64(Float64(b * -2.0) / Float64(a * 3.0)); elseif (b <= 4.8e-99) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(3.0 * c)))) - b) * Float64(0.3333333333333333 / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e+124) tmp = (b * -2.0) / (a * 3.0); elseif (b <= 4.8e-99) tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) * (0.3333333333333333 / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e+124], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.8e-99], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(3.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{+124}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\
\mathbf{elif}\;b \leq 4.8 \cdot 10^{-99}:\\
\;\;\;\;\left(\sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - b\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.9999999999999999e124Initial program 40.0%
sqr-neg40.0%
sqr-neg40.0%
associate-*l*40.0%
Simplified40.0%
Taylor expanded in b around -inf 99.8%
*-commutative99.8%
Simplified99.8%
if -1.9999999999999999e124 < b < 4.8000000000000001e-99Initial program 81.8%
neg-sub081.8%
sqr-neg81.8%
associate-+l-81.8%
sub0-neg81.8%
neg-mul-181.8%
Simplified81.7%
associate-*r*81.7%
metadata-eval81.7%
distribute-rgt-neg-in81.7%
*-commutative81.7%
fma-neg81.7%
associate-*r*81.7%
*-commutative81.7%
associate-*l*81.7%
Applied egg-rr81.7%
*-commutative81.7%
Simplified81.7%
div-inv81.6%
clear-num81.7%
Applied egg-rr81.7%
if 4.8000000000000001e-99 < b Initial program 15.3%
sqr-neg15.3%
sqr-neg15.3%
associate-*l*15.3%
Simplified15.3%
Taylor expanded in b around inf 86.5%
associate-*r/86.6%
Applied egg-rr86.6%
Final simplification86.7%
(FPCore (a b c)
:precision binary64
(if (<= b -8.5e+154)
(/ (* b -0.6666666666666666) a)
(if (<= b 4.8e-99)
(* (/ (- (sqrt (- (* b b) (* a (* 3.0 c)))) b) a) 0.3333333333333333)
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8.5e+154) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 4.8e-99) {
tmp = ((sqrt(((b * b) - (a * (3.0 * c)))) - b) / a) * 0.3333333333333333;
} 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 <= (-8.5d+154)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 4.8d-99) then
tmp = ((sqrt(((b * b) - (a * (3.0d0 * c)))) - b) / a) * 0.3333333333333333d0
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 <= -8.5e+154) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 4.8e-99) {
tmp = ((Math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / a) * 0.3333333333333333;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.5e+154: tmp = (b * -0.6666666666666666) / a elif b <= 4.8e-99: tmp = ((math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / a) * 0.3333333333333333 else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8.5e+154) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 4.8e-99) tmp = Float64(Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(3.0 * c)))) - b) / a) * 0.3333333333333333); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8.5e+154) tmp = (b * -0.6666666666666666) / a; elseif (b <= 4.8e-99) tmp = ((sqrt(((b * b) - (a * (3.0 * c)))) - b) / a) * 0.3333333333333333; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8.5e+154], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 4.8e-99], N[(N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(3.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.5 \cdot 10^{+154}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 4.8 \cdot 10^{-99}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - b}{a} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -8.5000000000000002e154Initial program 31.0%
sqr-neg31.0%
sqr-neg31.0%
associate-*l*31.0%
Simplified31.0%
Taylor expanded in b around -inf 99.6%
*-commutative99.6%
Simplified99.6%
associate-*l/99.8%
Applied egg-rr99.8%
if -8.5000000000000002e154 < b < 4.8000000000000001e-99Initial program 82.7%
neg-sub082.7%
sqr-neg82.7%
associate-+l-82.7%
sub0-neg82.7%
neg-mul-182.7%
Simplified82.5%
associate-*r*82.5%
metadata-eval82.5%
distribute-rgt-neg-in82.5%
*-commutative82.5%
fma-neg82.5%
associate-*r*82.5%
*-commutative82.5%
associate-*l*82.5%
Applied egg-rr82.5%
*-commutative82.5%
Simplified82.5%
associate-/r/82.6%
Applied egg-rr82.6%
if 4.8000000000000001e-99 < b Initial program 15.3%
sqr-neg15.3%
sqr-neg15.3%
associate-*l*15.3%
Simplified15.3%
Taylor expanded in b around inf 86.5%
associate-*r/86.6%
Applied egg-rr86.6%
Final simplification86.7%
(FPCore (a b c)
:precision binary64
(if (<= b -8.5e+154)
(/ (* b -0.6666666666666666) a)
(if (<= b 1.9e-99)
(/ (- (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 <= -8.5e+154) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.9e-99) {
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 <= (-8.5d+154)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 1.9d-99) 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 <= -8.5e+154) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.9e-99) {
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 <= -8.5e+154: tmp = (b * -0.6666666666666666) / a elif b <= 1.9e-99: 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 <= -8.5e+154) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 1.9e-99) 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 <= -8.5e+154) tmp = (b * -0.6666666666666666) / a; elseif (b <= 1.9e-99) 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, -8.5e+154], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.9e-99], 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 -8.5 \cdot 10^{+154}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-99}:\\
\;\;\;\;\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 < -8.5000000000000002e154Initial program 31.0%
sqr-neg31.0%
sqr-neg31.0%
associate-*l*31.0%
Simplified31.0%
Taylor expanded in b around -inf 99.6%
*-commutative99.6%
Simplified99.6%
associate-*l/99.8%
Applied egg-rr99.8%
if -8.5000000000000002e154 < b < 1.8999999999999998e-99Initial program 82.7%
sqr-neg82.7%
sqr-neg82.7%
associate-*l*82.6%
Simplified82.6%
if 1.8999999999999998e-99 < b Initial program 15.3%
sqr-neg15.3%
sqr-neg15.3%
associate-*l*15.3%
Simplified15.3%
Taylor expanded in b around inf 86.5%
associate-*r/86.6%
Applied egg-rr86.6%
Final simplification86.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.35e-87)
(/ (- (- (/ (* a 1.5) (/ b c)) b) b) (* a 3.0))
(if (<= b 4.5e-99)
(* (/ 0.3333333333333333 a) (- (sqrt (* c (* a -3.0))) b))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.35e-87) {
tmp = ((((a * 1.5) / (b / c)) - b) - b) / (a * 3.0);
} else if (b <= 4.5e-99) {
tmp = (0.3333333333333333 / a) * (sqrt((c * (a * -3.0))) - b);
} 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-87)) then
tmp = ((((a * 1.5d0) / (b / c)) - b) - b) / (a * 3.0d0)
else if (b <= 4.5d-99) then
tmp = (0.3333333333333333d0 / a) * (sqrt((c * (a * (-3.0d0)))) - b)
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-87) {
tmp = ((((a * 1.5) / (b / c)) - b) - b) / (a * 3.0);
} else if (b <= 4.5e-99) {
tmp = (0.3333333333333333 / a) * (Math.sqrt((c * (a * -3.0))) - b);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.35e-87: tmp = ((((a * 1.5) / (b / c)) - b) - b) / (a * 3.0) elif b <= 4.5e-99: tmp = (0.3333333333333333 / a) * (math.sqrt((c * (a * -3.0))) - b) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.35e-87) tmp = Float64(Float64(Float64(Float64(Float64(a * 1.5) / Float64(b / c)) - b) - b) / Float64(a * 3.0)); elseif (b <= 4.5e-99) tmp = Float64(Float64(0.3333333333333333 / a) * Float64(sqrt(Float64(c * Float64(a * -3.0))) - b)); 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-87) tmp = ((((a * 1.5) / (b / c)) - b) - b) / (a * 3.0); elseif (b <= 4.5e-99) tmp = (0.3333333333333333 / a) * (sqrt((c * (a * -3.0))) - b); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.35e-87], N[(N[(N[(N[(N[(a * 1.5), $MachinePrecision] / N[(b / c), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.5e-99], N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.35 \cdot 10^{-87}:\\
\;\;\;\;\frac{\left(\frac{a \cdot 1.5}{\frac{b}{c}} - b\right) - b}{a \cdot 3}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-99}:\\
\;\;\;\;\frac{0.3333333333333333}{a} \cdot \left(\sqrt{c \cdot \left(a \cdot -3\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.34999999999999992e-87Initial program 64.6%
sqr-neg64.6%
sqr-neg64.6%
associate-*l*64.6%
Simplified64.6%
Taylor expanded in b around -inf 76.9%
+-commutative76.9%
mul-1-neg76.9%
unsub-neg76.9%
associate-/l*83.2%
associate-*r/83.2%
Simplified83.2%
if -1.34999999999999992e-87 < b < 4.5000000000000003e-99Initial program 77.1%
neg-sub077.1%
sqr-neg77.1%
associate-+l-77.1%
sub0-neg77.1%
neg-mul-177.1%
Simplified77.0%
associate-*r*77.0%
metadata-eval77.0%
distribute-rgt-neg-in77.0%
*-commutative77.0%
fma-neg77.0%
associate-*r*77.0%
*-commutative77.0%
associate-*l*77.0%
Applied egg-rr77.0%
*-commutative77.0%
Simplified77.0%
expm1-log1p-u57.1%
expm1-udef20.5%
div-inv20.5%
clear-num20.5%
Applied egg-rr20.5%
expm1-def57.0%
expm1-log1p77.0%
associate-*r*77.1%
*-commutative77.1%
cancel-sign-sub-inv77.1%
distribute-lft-neg-in77.1%
+-commutative77.1%
distribute-lft-neg-in77.1%
metadata-eval77.1%
fma-def77.0%
Simplified77.0%
Taylor expanded in a around inf 72.5%
*-commutative72.5%
*-commutative72.5%
associate-*l*72.5%
Simplified72.5%
if 4.5000000000000003e-99 < b Initial program 15.3%
sqr-neg15.3%
sqr-neg15.3%
associate-*l*15.3%
Simplified15.3%
Taylor expanded in b around inf 86.5%
associate-*r/86.6%
Applied egg-rr86.6%
Final simplification81.4%
(FPCore (a b c)
:precision binary64
(if (<= b -2.6e-87)
(/ (- (- (/ (* a 1.5) (/ b c)) b) b) (* a 3.0))
(if (<= b 1.76e-99)
(* 0.3333333333333333 (/ (- (sqrt (* (* a c) -3.0)) b) a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.6e-87) {
tmp = ((((a * 1.5) / (b / c)) - b) - b) / (a * 3.0);
} else if (b <= 1.76e-99) {
tmp = 0.3333333333333333 * ((sqrt(((a * c) * -3.0)) - 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 <= (-2.6d-87)) then
tmp = ((((a * 1.5d0) / (b / c)) - b) - b) / (a * 3.0d0)
else if (b <= 1.76d-99) then
tmp = 0.3333333333333333d0 * ((sqrt(((a * c) * (-3.0d0))) - 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 <= -2.6e-87) {
tmp = ((((a * 1.5) / (b / c)) - b) - b) / (a * 3.0);
} else if (b <= 1.76e-99) {
tmp = 0.3333333333333333 * ((Math.sqrt(((a * c) * -3.0)) - b) / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.6e-87: tmp = ((((a * 1.5) / (b / c)) - b) - b) / (a * 3.0) elif b <= 1.76e-99: tmp = 0.3333333333333333 * ((math.sqrt(((a * c) * -3.0)) - b) / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.6e-87) tmp = Float64(Float64(Float64(Float64(Float64(a * 1.5) / Float64(b / c)) - b) - b) / Float64(a * 3.0)); elseif (b <= 1.76e-99) tmp = Float64(0.3333333333333333 * Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) / a)); 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.6e-87) tmp = ((((a * 1.5) / (b / c)) - b) - b) / (a * 3.0); elseif (b <= 1.76e-99) tmp = 0.3333333333333333 * ((sqrt(((a * c) * -3.0)) - b) / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.6e-87], N[(N[(N[(N[(N[(a * 1.5), $MachinePrecision] / N[(b / c), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.76e-99], N[(0.3333333333333333 * N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.6 \cdot 10^{-87}:\\
\;\;\;\;\frac{\left(\frac{a \cdot 1.5}{\frac{b}{c}} - b\right) - b}{a \cdot 3}\\
\mathbf{elif}\;b \leq 1.76 \cdot 10^{-99}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -2.60000000000000002e-87Initial program 64.6%
sqr-neg64.6%
sqr-neg64.6%
associate-*l*64.6%
Simplified64.6%
Taylor expanded in b around -inf 76.9%
+-commutative76.9%
mul-1-neg76.9%
unsub-neg76.9%
associate-/l*83.2%
associate-*r/83.2%
Simplified83.2%
if -2.60000000000000002e-87 < b < 1.75999999999999991e-99Initial program 77.1%
neg-sub077.1%
sqr-neg77.1%
associate-+l-77.1%
sub0-neg77.1%
neg-mul-177.1%
Simplified77.0%
associate-*r*77.0%
metadata-eval77.0%
distribute-rgt-neg-in77.0%
*-commutative77.0%
fma-neg77.0%
associate-*r*77.0%
*-commutative77.0%
associate-*l*77.0%
Applied egg-rr77.0%
*-commutative77.0%
Simplified77.0%
associate-/r/77.1%
Applied egg-rr77.1%
Taylor expanded in b around 0 72.5%
if 1.75999999999999991e-99 < b Initial program 15.3%
sqr-neg15.3%
sqr-neg15.3%
associate-*l*15.3%
Simplified15.3%
Taylor expanded in b around inf 86.5%
associate-*r/86.6%
Applied egg-rr86.6%
Final simplification81.4%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b))) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} 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 <= (-1d-310)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))
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 <= -1e-310) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-310) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 70.0%
sqr-neg70.0%
sqr-neg70.0%
associate-*l*69.9%
Simplified69.9%
Taylor expanded in b around -inf 63.9%
if -9.999999999999969e-311 < b Initial program 30.2%
sqr-neg30.2%
sqr-neg30.2%
associate-*l*30.2%
Simplified30.2%
Taylor expanded in b around inf 66.4%
associate-*r/66.4%
Applied egg-rr66.4%
Final simplification65.1%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (/ (* b -2.0) (* a 3.0)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = (b * -2.0) / (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 <= (-1d-310)) then
tmp = (b * (-2.0d0)) / (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 <= -1e-310) {
tmp = (b * -2.0) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = (b * -2.0) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) tmp = Float64(Float64(b * -2.0) / 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 <= -1e-310) tmp = (b * -2.0) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], N[(N[(b * -2.0), $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 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 70.0%
sqr-neg70.0%
sqr-neg70.0%
associate-*l*69.9%
Simplified69.9%
Taylor expanded in b around -inf 63.5%
*-commutative63.5%
Simplified63.5%
if -9.999999999999969e-311 < b Initial program 30.2%
sqr-neg30.2%
sqr-neg30.2%
associate-*l*30.2%
Simplified30.2%
Taylor expanded in b around inf 66.4%
associate-*r/66.4%
Applied egg-rr66.4%
Final simplification64.9%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (* b (/ -0.6666666666666666 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1d-310)) then
tmp = b * ((-0.6666666666666666d0) / a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-310) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 70.0%
neg-sub070.0%
sqr-neg70.0%
associate-+l-70.0%
sub0-neg70.0%
neg-mul-170.0%
Simplified69.8%
associate-*r*69.8%
metadata-eval69.8%
distribute-rgt-neg-in69.8%
*-commutative69.8%
fma-neg69.8%
associate-*r*69.8%
*-commutative69.8%
associate-*l*69.8%
Applied egg-rr69.8%
*-commutative69.8%
Simplified69.8%
Taylor expanded in b around -inf 63.4%
associate-*r/63.3%
associate-/l*63.3%
Simplified63.3%
associate-/r/63.4%
Applied egg-rr63.4%
if -9.999999999999969e-311 < b Initial program 30.2%
sqr-neg30.2%
sqr-neg30.2%
associate-*l*30.2%
Simplified30.2%
Taylor expanded in b around inf 66.4%
Final simplification64.8%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1d-310)) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-310) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 70.0%
sqr-neg70.0%
sqr-neg70.0%
associate-*l*69.9%
Simplified69.9%
Taylor expanded in b around -inf 63.4%
*-commutative63.4%
Simplified63.4%
if -9.999999999999969e-311 < b Initial program 30.2%
sqr-neg30.2%
sqr-neg30.2%
associate-*l*30.2%
Simplified30.2%
Taylor expanded in b around inf 66.4%
Final simplification64.9%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (* -0.6666666666666666 (/ b a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-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 <= (-1d-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 <= -1e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-310) tmp = -0.6666666666666666 * (b / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 70.0%
sqr-neg70.0%
sqr-neg70.0%
associate-*l*69.9%
Simplified69.9%
Taylor expanded in b around -inf 63.4%
*-commutative63.4%
Simplified63.4%
if -9.999999999999969e-311 < b Initial program 30.2%
sqr-neg30.2%
sqr-neg30.2%
associate-*l*30.2%
Simplified30.2%
Taylor expanded in b around inf 66.4%
associate-*r/66.4%
Applied egg-rr66.4%
Final simplification64.9%
(FPCore (a b c) :precision binary64 (* -0.5 (/ c b)))
double code(double a, double b, double c) {
return -0.5 * (c / b);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-0.5d0) * (c / b)
end function
public static double code(double a, double b, double c) {
return -0.5 * (c / b);
}
def code(a, b, c): return -0.5 * (c / b)
function code(a, b, c) return Float64(-0.5 * Float64(c / b)) end
function tmp = code(a, b, c) tmp = -0.5 * (c / b); end
code[a_, b_, c_] := N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \frac{c}{b}
\end{array}
Initial program 50.4%
sqr-neg50.4%
sqr-neg50.4%
associate-*l*50.4%
Simplified50.4%
Taylor expanded in b around inf 33.8%
Final simplification33.8%
herbie shell --seed 2023271
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))