
(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 8 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 -4.4e+55)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 1.15e-40)
(/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.4e+55) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.15e-40) {
tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * 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 <= (-4.4d+55)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 1.15d-40) then
tmp = (sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (3.0d0 * 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 <= -4.4e+55) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.15e-40) {
tmp = (Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.4e+55: tmp = (b * -2.0) / (3.0 * a) elif b <= 1.15e-40: tmp = (math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.4e+55) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 1.15e-40) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * 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 <= -4.4e+55) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 1.15e-40) tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.4e+55], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.15e-40], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.4 \cdot 10^{+55}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.15 \cdot 10^{-40}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.40000000000000021e55Initial program 65.3%
Taylor expanded in b around -inf 95.8%
*-commutative95.8%
Simplified95.8%
if -4.40000000000000021e55 < b < 1.15e-40Initial program 77.8%
if 1.15e-40 < b Initial program 15.7%
Taylor expanded in b around inf 90.0%
*-commutative90.0%
associate-*l/90.1%
Simplified90.1%
Final simplification86.7%
(FPCore (a b c)
:precision binary64
(if (<= b -5.3e-71)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 1.4e-40)
(*
(/ 0.3333333333333333 a)
(- (pow (* c (/ a -0.3333333333333333)) 0.5) b))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.3e-71) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.4e-40) {
tmp = (0.3333333333333333 / a) * (pow((c * (a / -0.3333333333333333)), 0.5) - 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 <= (-5.3d-71)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 1.4d-40) then
tmp = (0.3333333333333333d0 / a) * (((c * (a / (-0.3333333333333333d0))) ** 0.5d0) - 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 <= -5.3e-71) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.4e-40) {
tmp = (0.3333333333333333 / a) * (Math.pow((c * (a / -0.3333333333333333)), 0.5) - b);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.3e-71: tmp = (b * -2.0) / (3.0 * a) elif b <= 1.4e-40: tmp = (0.3333333333333333 / a) * (math.pow((c * (a / -0.3333333333333333)), 0.5) - b) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.3e-71) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 1.4e-40) tmp = Float64(Float64(0.3333333333333333 / a) * Float64((Float64(c * Float64(a / -0.3333333333333333)) ^ 0.5) - 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 <= -5.3e-71) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 1.4e-40) tmp = (0.3333333333333333 / a) * (((c * (a / -0.3333333333333333)) ^ 0.5) - b); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.3e-71], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.4e-40], N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(N[Power[N[(c * N[(a / -0.3333333333333333), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.3 \cdot 10^{-71}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{-40}:\\
\;\;\;\;\frac{0.3333333333333333}{a} \cdot \left({\left(c \cdot \frac{a}{-0.3333333333333333}\right)}^{0.5} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.29999999999999999e-71Initial program 70.7%
Taylor expanded in b around -inf 88.6%
*-commutative88.6%
Simplified88.6%
if -5.29999999999999999e-71 < b < 1.4e-40Initial program 75.5%
add-sqr-sqrt75.3%
pow275.3%
pow1/275.3%
sqrt-pow175.3%
sub-neg75.3%
+-commutative75.3%
distribute-lft-neg-in75.3%
*-commutative75.3%
distribute-rgt-neg-in75.3%
metadata-eval75.3%
associate-*r*75.2%
*-commutative75.2%
fma-udef75.2%
pow275.2%
metadata-eval75.2%
Applied egg-rr75.2%
Taylor expanded in c around -inf 40.1%
unpow240.1%
exp-prod39.3%
exp-prod38.6%
pow-sqr38.6%
mul-1-neg38.6%
unsub-neg38.6%
*-commutative38.6%
Simplified38.6%
Taylor expanded in a around 0 39.8%
Simplified66.3%
if 1.4e-40 < b Initial program 15.7%
Taylor expanded in b around inf 90.0%
*-commutative90.0%
associate-*l/90.1%
Simplified90.1%
Final simplification82.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.15e-68)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 1.35e-40)
(/ (- (sqrt (* c (* a -3.0))) b) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e-68) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.35e-40) {
tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * 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 <= (-1.15d-68)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 1.35d-40) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (3.0d0 * 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 <= -1.15e-68) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.35e-40) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.15e-68: tmp = (b * -2.0) / (3.0 * a) elif b <= 1.35e-40: tmp = (math.sqrt((c * (a * -3.0))) - b) / (3.0 * a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.15e-68) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 1.35e-40) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(3.0 * 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 <= -1.15e-68) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 1.35e-40) tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.15e-68], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e-40], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.15 \cdot 10^{-68}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-40}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.14999999999999998e-68Initial program 70.7%
Taylor expanded in b around -inf 88.6%
*-commutative88.6%
Simplified88.6%
if -1.14999999999999998e-68 < b < 1.35e-40Initial program 75.5%
Taylor expanded in b around 0 66.2%
associate-*r*66.3%
*-commutative66.3%
*-commutative66.3%
Simplified66.3%
if 1.35e-40 < b Initial program 15.7%
Taylor expanded in b around inf 90.0%
*-commutative90.0%
associate-*l/90.1%
Simplified90.1%
Final simplification82.6%
(FPCore (a b c)
:precision binary64
(if (<= b -9.6e-119)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 1.5e-40)
(* 0.3333333333333333 (/ (pow (* c (/ a -0.3333333333333333)) 0.5) a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.6e-119) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.5e-40) {
tmp = 0.3333333333333333 * (pow((c * (a / -0.3333333333333333)), 0.5) / 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 <= (-9.6d-119)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 1.5d-40) then
tmp = 0.3333333333333333d0 * (((c * (a / (-0.3333333333333333d0))) ** 0.5d0) / 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 <= -9.6e-119) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.5e-40) {
tmp = 0.3333333333333333 * (Math.pow((c * (a / -0.3333333333333333)), 0.5) / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9.6e-119: tmp = (b * -2.0) / (3.0 * a) elif b <= 1.5e-40: tmp = 0.3333333333333333 * (math.pow((c * (a / -0.3333333333333333)), 0.5) / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9.6e-119) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 1.5e-40) tmp = Float64(0.3333333333333333 * Float64((Float64(c * Float64(a / -0.3333333333333333)) ^ 0.5) / 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 <= -9.6e-119) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 1.5e-40) tmp = 0.3333333333333333 * (((c * (a / -0.3333333333333333)) ^ 0.5) / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9.6e-119], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.5e-40], N[(0.3333333333333333 * N[(N[Power[N[(c * N[(a / -0.3333333333333333), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.6 \cdot 10^{-119}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.5 \cdot 10^{-40}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{{\left(c \cdot \frac{a}{-0.3333333333333333}\right)}^{0.5}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -9.60000000000000034e-119Initial program 72.7%
Taylor expanded in b around -inf 84.6%
*-commutative84.6%
Simplified84.6%
if -9.60000000000000034e-119 < b < 1.5000000000000001e-40Initial program 72.7%
add-sqr-sqrt72.6%
pow272.6%
pow1/272.6%
sqrt-pow172.6%
sub-neg72.6%
+-commutative72.6%
distribute-lft-neg-in72.6%
*-commutative72.6%
distribute-rgt-neg-in72.6%
metadata-eval72.6%
associate-*r*72.5%
*-commutative72.5%
fma-udef72.5%
pow272.5%
metadata-eval72.5%
Applied egg-rr72.5%
Taylor expanded in c around -inf 44.1%
unpow244.1%
exp-prod43.3%
exp-prod42.5%
pow-sqr42.5%
mul-1-neg42.5%
unsub-neg42.5%
*-commutative42.5%
Simplified42.5%
Taylor expanded in b around 0 43.8%
*-commutative43.8%
log-prod43.5%
+-commutative43.5%
log-prod43.8%
log-div63.5%
exp-to-pow67.8%
associate-/r/67.8%
*-commutative67.8%
associate-/l*67.9%
metadata-eval67.9%
Simplified67.9%
if 1.5000000000000001e-40 < b Initial program 15.7%
Taylor expanded in b around inf 90.0%
*-commutative90.0%
associate-*l/90.1%
Simplified90.1%
Final simplification82.2%
(FPCore (a b c) :precision binary64 (if (<= b 4e-278) (/ (* b -2.0) (* 3.0 a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 4e-278) {
tmp = (b * -2.0) / (3.0 * 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-278) then
tmp = (b * (-2.0d0)) / (3.0d0 * 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-278) {
tmp = (b * -2.0) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4e-278: tmp = (b * -2.0) / (3.0 * a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4e-278) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * 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 <= 4e-278) tmp = (b * -2.0) / (3.0 * a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4e-278], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4 \cdot 10^{-278}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 3.99999999999999975e-278Initial program 75.2%
Taylor expanded in b around -inf 70.3%
*-commutative70.3%
Simplified70.3%
if 3.99999999999999975e-278 < b Initial program 29.1%
Taylor expanded in b around inf 70.7%
*-commutative70.7%
associate-*l/70.7%
Simplified70.7%
Final simplification70.5%
(FPCore (a b c) :precision binary64 (if (<= b 8e+46) (* (/ b a) -0.6666666666666666) (/ (* c 0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 8e+46) {
tmp = (b / a) * -0.6666666666666666;
} 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 <= 8d+46) then
tmp = (b / a) * (-0.6666666666666666d0)
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 <= 8e+46) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c * 0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 8e+46: tmp = (b / a) * -0.6666666666666666 else: tmp = (c * 0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 8e+46) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(Float64(c * 0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 8e+46) tmp = (b / a) * -0.6666666666666666; else tmp = (c * 0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 8e+46], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(N[(c * 0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8 \cdot 10^{+46}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 0.5}{b}\\
\end{array}
\end{array}
if b < 7.9999999999999999e46Initial program 67.5%
Taylor expanded in b around -inf 52.6%
*-commutative52.6%
Simplified52.6%
if 7.9999999999999999e46 < b Initial program 15.5%
Taylor expanded in b around -inf 2.0%
*-commutative2.0%
fma-def2.0%
*-commutative2.0%
associate-/l*2.2%
associate-/r/2.2%
Simplified2.2%
Taylor expanded in b around 0 29.5%
associate-*r/29.5%
Simplified29.5%
Final simplification46.9%
(FPCore (a b c) :precision binary64 (if (<= b 3.6e-278) (* (/ b a) -0.6666666666666666) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.6e-278) {
tmp = (b / a) * -0.6666666666666666;
} 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 <= 3.6d-278) then
tmp = (b / a) * (-0.6666666666666666d0)
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 <= 3.6e-278) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.6e-278: tmp = (b / a) * -0.6666666666666666 else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.6e-278) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3.6e-278) tmp = (b / a) * -0.6666666666666666; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.6e-278], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.6 \cdot 10^{-278}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 3.59999999999999996e-278Initial program 75.2%
Taylor expanded in b around -inf 70.2%
*-commutative70.2%
Simplified70.2%
if 3.59999999999999996e-278 < b Initial program 29.1%
Taylor expanded in b around inf 70.7%
*-commutative70.7%
associate-*l/70.7%
Simplified70.7%
Final simplification70.4%
(FPCore (a b c) :precision binary64 (* (/ b a) -0.6666666666666666))
double code(double a, double b, double c) {
return (b / a) * -0.6666666666666666;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (b / a) * (-0.6666666666666666d0)
end function
public static double code(double a, double b, double c) {
return (b / a) * -0.6666666666666666;
}
def code(a, b, c): return (b / a) * -0.6666666666666666
function code(a, b, c) return Float64(Float64(b / a) * -0.6666666666666666) end
function tmp = code(a, b, c) tmp = (b / a) * -0.6666666666666666; end
code[a_, b_, c_] := N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{a} \cdot -0.6666666666666666
\end{array}
Initial program 54.7%
Taylor expanded in b around -inf 40.2%
*-commutative40.2%
Simplified40.2%
Final simplification40.2%
herbie shell --seed 2023320
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))