
(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 -8e+130)
(* (/ b a) -0.6666666666666666)
(if (<= b 1.75e-91)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8e+130) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 1.75e-91) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} 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 <= (-8d+130)) then
tmp = (b / a) * (-0.6666666666666666d0)
else if (b <= 1.75d-91) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
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 <= -8e+130) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 1.75e-91) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8e+130: tmp = (b / a) * -0.6666666666666666 elif b <= 1.75e-91: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8e+130) tmp = Float64(Float64(b / a) * -0.6666666666666666); elseif (b <= 1.75e-91) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8e+130) tmp = (b / a) * -0.6666666666666666; elseif (b <= 1.75e-91) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8e+130], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], If[LessEqual[b, 1.75e-91], 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[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8 \cdot 10^{+130}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{elif}\;b \leq 1.75 \cdot 10^{-91}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -8.0000000000000005e130Initial program 54.6%
sqr-neg54.6%
sqr-neg54.6%
associate-*l*54.6%
Simplified54.6%
Taylor expanded in b around -inf 96.1%
*-commutative96.1%
Simplified96.1%
if -8.0000000000000005e130 < b < 1.7499999999999999e-91Initial program 85.9%
if 1.7499999999999999e-91 < b Initial program 12.8%
sqr-neg12.8%
sqr-neg12.8%
associate-*l*12.8%
Simplified12.8%
Taylor expanded in b around inf 85.4%
Final simplification87.7%
(FPCore (a b c)
:precision binary64
(if (<= b -6.2e+154)
(* (/ b a) -0.6666666666666666)
(if (<= b 5.5e-91)
(* (/ (- (sqrt (- (* b b) (* a (* 3.0 c)))) b) a) 0.3333333333333333)
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.2e+154) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 5.5e-91) {
tmp = ((sqrt(((b * b) - (a * (3.0 * c)))) - b) / a) * 0.3333333333333333;
} 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 <= (-6.2d+154)) then
tmp = (b / a) * (-0.6666666666666666d0)
else if (b <= 5.5d-91) then
tmp = ((sqrt(((b * b) - (a * (3.0d0 * c)))) - b) / a) * 0.3333333333333333d0
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 <= -6.2e+154) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 5.5e-91) {
tmp = ((Math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / a) * 0.3333333333333333;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.2e+154: tmp = (b / a) * -0.6666666666666666 elif b <= 5.5e-91: tmp = ((math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / a) * 0.3333333333333333 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.2e+154) tmp = Float64(Float64(b / a) * -0.6666666666666666); elseif (b <= 5.5e-91) tmp = Float64(Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(3.0 * c)))) - b) / a) * 0.3333333333333333); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.2e+154) tmp = (b / a) * -0.6666666666666666; elseif (b <= 5.5e-91) tmp = ((sqrt(((b * b) - (a * (3.0 * c)))) - b) / a) * 0.3333333333333333; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.2e+154], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], If[LessEqual[b, 5.5e-91], 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[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.2 \cdot 10^{+154}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{elif}\;b \leq 5.5 \cdot 10^{-91}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - b}{a} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -6.2000000000000003e154Initial program 43.7%
sqr-neg43.7%
sqr-neg43.7%
associate-*l*43.7%
Simplified43.7%
Taylor expanded in b around -inf 95.2%
*-commutative95.2%
Simplified95.2%
if -6.2000000000000003e154 < b < 5.49999999999999965e-91Initial program 87.0%
neg-sub087.0%
sqr-neg87.0%
associate-+l-87.0%
sub0-neg87.0%
neg-mul-187.0%
Simplified86.9%
associate-*r*86.9%
metadata-eval86.9%
distribute-rgt-neg-in86.9%
*-commutative86.9%
fma-neg86.9%
associate-*r*86.9%
*-commutative86.9%
associate-*l*86.9%
Applied egg-rr86.9%
*-commutative86.9%
Simplified86.9%
associate-/r/87.0%
Applied egg-rr87.0%
if 5.49999999999999965e-91 < b Initial program 12.8%
sqr-neg12.8%
sqr-neg12.8%
associate-*l*12.8%
Simplified12.8%
Taylor expanded in b around inf 85.4%
Final simplification87.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.9e+129)
(* (/ b a) -0.6666666666666666)
(if (<= b 4.4e-91)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.9e+129) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 4.4e-91) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.9d+129)) then
tmp = (b / a) * (-0.6666666666666666d0)
else if (b <= 4.4d-91) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (a * 3.0d0)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.9e+129) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 4.4e-91) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.9e+129: tmp = (b / a) * -0.6666666666666666 elif b <= 4.4e-91: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.9e+129) tmp = Float64(Float64(b / a) * -0.6666666666666666); elseif (b <= 4.4e-91) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.9e+129) tmp = (b / a) * -0.6666666666666666; elseif (b <= 4.4e-91) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.9e+129], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], If[LessEqual[b, 4.4e-91], 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[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.9 \cdot 10^{+129}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{-91}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.90000000000000003e129Initial program 54.6%
sqr-neg54.6%
sqr-neg54.6%
associate-*l*54.6%
Simplified54.6%
Taylor expanded in b around -inf 96.1%
*-commutative96.1%
Simplified96.1%
if -1.90000000000000003e129 < b < 4.4000000000000002e-91Initial program 85.9%
sqr-neg85.9%
sqr-neg85.9%
associate-*l*85.8%
Simplified85.8%
if 4.4000000000000002e-91 < b Initial program 12.8%
sqr-neg12.8%
sqr-neg12.8%
associate-*l*12.8%
Simplified12.8%
Taylor expanded in b around inf 85.4%
Final simplification87.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.46e-71)
(+ (* (/ b a) -0.6666666666666666) (* (/ c b) 0.5))
(if (<= b 1.45e-91)
(* 0.3333333333333333 (/ (- (sqrt (* (* a c) -3.0)) b) a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.46e-71) {
tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5);
} else if (b <= 1.45e-91) {
tmp = 0.3333333333333333 * ((sqrt(((a * c) * -3.0)) - 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 <= (-1.46d-71)) then
tmp = ((b / a) * (-0.6666666666666666d0)) + ((c / b) * 0.5d0)
else if (b <= 1.45d-91) then
tmp = 0.3333333333333333d0 * ((sqrt(((a * c) * (-3.0d0))) - 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 <= -1.46e-71) {
tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5);
} else if (b <= 1.45e-91) {
tmp = 0.3333333333333333 * ((Math.sqrt(((a * c) * -3.0)) - b) / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.46e-71: tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5) elif b <= 1.45e-91: tmp = 0.3333333333333333 * ((math.sqrt(((a * c) * -3.0)) - b) / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.46e-71) tmp = Float64(Float64(Float64(b / a) * -0.6666666666666666) + Float64(Float64(c / b) * 0.5)); elseif (b <= 1.45e-91) tmp = Float64(0.3333333333333333 * Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - 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 <= -1.46e-71) tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5); elseif (b <= 1.45e-91) tmp = 0.3333333333333333 * ((sqrt(((a * c) * -3.0)) - b) / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.46e-71], N[(N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.45e-91], N[(0.3333333333333333 * N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.46 \cdot 10^{-71}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666 + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{-91}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.46e-71Initial program 76.1%
sqr-neg76.1%
sqr-neg76.1%
associate-*l*76.1%
Simplified76.1%
Taylor expanded in b around -inf 93.7%
if -1.46e-71 < b < 1.45e-91Initial program 75.6%
neg-sub075.6%
sqr-neg75.6%
associate-+l-75.6%
sub0-neg75.6%
neg-mul-175.6%
Simplified75.3%
associate-*r*75.3%
metadata-eval75.3%
distribute-rgt-neg-in75.3%
*-commutative75.3%
fma-neg75.3%
associate-*r*75.3%
*-commutative75.3%
associate-*l*75.3%
Applied egg-rr75.3%
*-commutative75.3%
Simplified75.3%
associate-/r/75.4%
Applied egg-rr75.4%
Taylor expanded in b around 0 71.4%
if 1.45e-91 < b Initial program 12.8%
sqr-neg12.8%
sqr-neg12.8%
associate-*l*12.8%
Simplified12.8%
Taylor expanded in b around inf 85.4%
Final simplification85.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.45e-69)
(+ (* (/ b a) -0.6666666666666666) (* (/ c b) 0.5))
(if (<= b 3.6e-91)
(/ (- (sqrt (* a (* c -3.0))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.45e-69) {
tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5);
} else if (b <= 3.6e-91) {
tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.45d-69)) then
tmp = ((b / a) * (-0.6666666666666666d0)) + ((c / b) * 0.5d0)
else if (b <= 3.6d-91) then
tmp = (sqrt((a * (c * (-3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.45e-69) {
tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5);
} else if (b <= 3.6e-91) {
tmp = (Math.sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.45e-69: tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5) elif b <= 3.6e-91: tmp = (math.sqrt((a * (c * -3.0))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.45e-69) tmp = Float64(Float64(Float64(b / a) * -0.6666666666666666) + Float64(Float64(c / b) * 0.5)); elseif (b <= 3.6e-91) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.45e-69) tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5); elseif (b <= 3.6e-91) tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.45e-69], N[(N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.6e-91], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.45 \cdot 10^{-69}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666 + \frac{c}{b} \cdot 0.5\\
\mathbf{elif}\;b \leq 3.6 \cdot 10^{-91}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.4499999999999999e-69Initial program 76.1%
sqr-neg76.1%
sqr-neg76.1%
associate-*l*76.1%
Simplified76.1%
Taylor expanded in b around -inf 93.7%
if -1.4499999999999999e-69 < b < 3.6e-91Initial program 75.6%
sqr-neg75.6%
sqr-neg75.6%
associate-*l*75.5%
Simplified75.5%
Taylor expanded in b around 0 71.5%
associate-*r*71.5%
*-commutative71.5%
associate-*l*71.5%
Simplified71.5%
if 3.6e-91 < b Initial program 12.8%
sqr-neg12.8%
sqr-neg12.8%
associate-*l*12.8%
Simplified12.8%
Taylor expanded in b around inf 85.4%
Final simplification85.2%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (+ (* (/ b a) -0.6666666666666666) (* (/ c b) 0.5)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-4d-310)) then
tmp = ((b / a) * (-0.6666666666666666d0)) + ((c / b) * 0.5d0)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(Float64(Float64(b / a) * -0.6666666666666666) + Float64(Float64(c / b) * 0.5)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4e-310) tmp = ((b / a) * -0.6666666666666666) + ((c / b) * 0.5); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666 + \frac{c}{b} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 76.5%
sqr-neg76.5%
sqr-neg76.5%
associate-*l*76.4%
Simplified76.4%
Taylor expanded in b around -inf 77.2%
if -3.999999999999988e-310 < b Initial program 28.4%
sqr-neg28.4%
sqr-neg28.4%
associate-*l*28.4%
Simplified28.4%
Taylor expanded in b around inf 70.5%
Final simplification73.8%
(FPCore (a b c) :precision binary64 (if (<= b 2.4e-308) (* (/ b a) -0.6666666666666666) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.4e-308) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 2.4d-308) then
tmp = (b / a) * (-0.6666666666666666d0)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.4e-308) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.4e-308: tmp = (b / a) * -0.6666666666666666 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.4e-308) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.4e-308) tmp = (b / a) * -0.6666666666666666; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.4e-308], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.4 \cdot 10^{-308}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.40000000000000008e-308Initial program 76.7%
sqr-neg76.7%
sqr-neg76.7%
associate-*l*76.6%
Simplified76.6%
Taylor expanded in b around -inf 76.3%
*-commutative76.3%
Simplified76.3%
if 2.40000000000000008e-308 < b Initial program 27.8%
sqr-neg27.8%
sqr-neg27.8%
associate-*l*27.8%
Simplified27.8%
Taylor expanded in b around inf 71.1%
Final simplification73.7%
(FPCore (a b c) :precision binary64 (if (<= b 2.4e-308) (/ (* b -0.6666666666666666) a) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.4e-308) {
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 <= 2.4d-308) 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 <= 2.4e-308) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.4e-308: tmp = (b * -0.6666666666666666) / a else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.4e-308) tmp = Float64(Float64(b * -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 <= 2.4e-308) tmp = (b * -0.6666666666666666) / a; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.4e-308], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.4 \cdot 10^{-308}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.40000000000000008e-308Initial program 76.7%
sqr-neg76.7%
sqr-neg76.7%
associate-*l*76.6%
Simplified76.6%
Taylor expanded in b around -inf 76.3%
*-commutative76.3%
Simplified76.3%
associate-*l/76.3%
Applied egg-rr76.3%
if 2.40000000000000008e-308 < b Initial program 27.8%
sqr-neg27.8%
sqr-neg27.8%
associate-*l*27.8%
Simplified27.8%
Taylor expanded in b around inf 71.1%
Final simplification73.7%
(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 52.2%
sqr-neg52.2%
sqr-neg52.2%
associate-*l*52.2%
Simplified52.2%
Taylor expanded in b around inf 36.8%
Final simplification36.8%
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
return 0.0;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 0.0d0
end function
public static double code(double a, double b, double c) {
return 0.0;
}
def code(a, b, c): return 0.0
function code(a, b, c) return 0.0 end
function tmp = code(a, b, c) tmp = 0.0; end
code[a_, b_, c_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 52.2%
sqr-neg52.2%
sqr-neg52.2%
associate-*l*52.2%
Simplified52.2%
fma-neg52.2%
*-commutative52.2%
distribute-rgt-neg-in52.2%
metadata-eval52.2%
associate-*r*52.2%
add-cube-cbrt50.7%
pow350.7%
Applied egg-rr30.1%
Taylor expanded in a around 0 29.5%
unpow1/331.2%
unpow231.2%
Simplified31.2%
Taylor expanded in b around 0 12.0%
Final simplification12.0%
herbie shell --seed 2023291
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))