
(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 -5e+139)
(/ b (* a -1.5))
(if (<= b 1.4e-92)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+139) {
tmp = b / (a * -1.5);
} else if (b <= 1.4e-92) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d+139)) then
tmp = b / (a * (-1.5d0))
else if (b <= 1.4d-92) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e+139) {
tmp = b / (a * -1.5);
} else if (b <= 1.4e-92) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e+139: tmp = b / (a * -1.5) elif b <= 1.4e-92: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e+139) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 1.4e-92) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e+139) tmp = b / (a * -1.5); elseif (b <= 1.4e-92) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e+139], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.4e-92], 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 / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+139}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{-92}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -5.0000000000000003e139Initial program 31.4%
sqr-neg31.4%
sqr-neg31.4%
associate-*l*31.4%
Simplified31.4%
Taylor expanded in b around -inf 90.3%
*-commutative90.3%
Simplified90.3%
*-commutative90.3%
clear-num90.3%
un-div-inv90.2%
Applied egg-rr90.2%
associate-/r/90.3%
Simplified90.3%
*-commutative90.3%
clear-num90.3%
un-div-inv90.4%
div-inv90.5%
metadata-eval90.5%
Applied egg-rr90.5%
if -5.0000000000000003e139 < b < 1.4e-92Initial program 88.5%
if 1.4e-92 < b Initial program 18.7%
sqr-neg18.7%
sqr-neg18.7%
associate-*l*18.7%
Simplified18.7%
Taylor expanded in b around inf 86.2%
*-commutative86.2%
Simplified86.2%
Final simplification87.8%
(FPCore (a b c)
:precision binary64
(if (<= b -2e+140)
(/ b (* a -1.5))
(if (<= b 2.85e-92)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e+140) {
tmp = b / (a * -1.5);
} else if (b <= 2.85e-92) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2d+140)) then
tmp = b / (a * (-1.5d0))
else if (b <= 2.85d-92) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2e+140) {
tmp = b / (a * -1.5);
} else if (b <= 2.85e-92) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e+140: tmp = b / (a * -1.5) elif b <= 2.85e-92: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e+140) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 2.85e-92) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e+140) tmp = b / (a * -1.5); elseif (b <= 2.85e-92) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e+140], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.85e-92], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{+140}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 2.85 \cdot 10^{-92}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.00000000000000012e140Initial program 31.4%
sqr-neg31.4%
sqr-neg31.4%
associate-*l*31.4%
Simplified31.4%
Taylor expanded in b around -inf 90.3%
*-commutative90.3%
Simplified90.3%
*-commutative90.3%
clear-num90.3%
un-div-inv90.2%
Applied egg-rr90.2%
associate-/r/90.3%
Simplified90.3%
*-commutative90.3%
clear-num90.3%
un-div-inv90.4%
div-inv90.5%
metadata-eval90.5%
Applied egg-rr90.5%
if -2.00000000000000012e140 < b < 2.85000000000000004e-92Initial program 88.5%
sqr-neg88.5%
sqr-neg88.5%
associate-*l*88.3%
Simplified88.3%
if 2.85000000000000004e-92 < b Initial program 18.7%
sqr-neg18.7%
sqr-neg18.7%
associate-*l*18.7%
Simplified18.7%
Taylor expanded in b around inf 86.2%
*-commutative86.2%
Simplified86.2%
Final simplification87.7%
(FPCore (a b c)
:precision binary64
(if (<= b -5e-62)
(/ b (* a -1.5))
(if (<= b 3e-92)
(/ (- (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 <= -5e-62) {
tmp = b / (a * -1.5);
} else if (b <= 3e-92) {
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 <= (-5d-62)) then
tmp = b / (a * (-1.5d0))
else if (b <= 3d-92) 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 <= -5e-62) {
tmp = b / (a * -1.5);
} else if (b <= 3e-92) {
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 <= -5e-62: tmp = b / (a * -1.5) elif b <= 3e-92: 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 <= -5e-62) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 3e-92) 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 <= -5e-62) tmp = b / (a * -1.5); elseif (b <= 3e-92) 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, -5e-62], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3e-92], 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 -5 \cdot 10^{-62}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 3 \cdot 10^{-92}:\\
\;\;\;\;\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 < -5.0000000000000002e-62Initial program 62.1%
sqr-neg62.1%
sqr-neg62.1%
associate-*l*62.1%
Simplified62.1%
Taylor expanded in b around -inf 85.0%
*-commutative85.0%
Simplified85.0%
*-commutative85.0%
clear-num84.9%
un-div-inv84.9%
Applied egg-rr84.9%
associate-/r/84.9%
Simplified84.9%
*-commutative84.9%
clear-num84.9%
un-div-inv85.0%
div-inv85.1%
metadata-eval85.1%
Applied egg-rr85.1%
if -5.0000000000000002e-62 < b < 3.00000000000000013e-92Initial program 85.5%
sqr-neg85.5%
sqr-neg85.5%
associate-*l*85.2%
Simplified85.2%
Taylor expanded in b around 0 78.5%
*-commutative78.5%
associate-*l*78.5%
*-commutative78.5%
*-commutative78.5%
Simplified78.5%
+-commutative78.5%
unsub-neg78.5%
*-commutative78.5%
associate-*l*78.8%
metadata-eval78.8%
distribute-lft-neg-in78.8%
*-commutative78.8%
distribute-rgt-neg-in78.8%
metadata-eval78.8%
Applied egg-rr78.8%
if 3.00000000000000013e-92 < b Initial program 18.7%
sqr-neg18.7%
sqr-neg18.7%
associate-*l*18.7%
Simplified18.7%
Taylor expanded in b around inf 86.2%
*-commutative86.2%
Simplified86.2%
Final simplification83.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.95e-65)
(/ b (* a -1.5))
(if (<= b 1.4e-92)
(* -0.3333333333333333 (/ (- b (sqrt (* c (* a -3.0)))) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.95e-65) {
tmp = b / (a * -1.5);
} else if (b <= 1.4e-92) {
tmp = -0.3333333333333333 * ((b - sqrt((c * (a * -3.0)))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.95d-65)) then
tmp = b / (a * (-1.5d0))
else if (b <= 1.4d-92) then
tmp = (-0.3333333333333333d0) * ((b - sqrt((c * (a * (-3.0d0))))) / a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.95e-65) {
tmp = b / (a * -1.5);
} else if (b <= 1.4e-92) {
tmp = -0.3333333333333333 * ((b - Math.sqrt((c * (a * -3.0)))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.95e-65: tmp = b / (a * -1.5) elif b <= 1.4e-92: tmp = -0.3333333333333333 * ((b - math.sqrt((c * (a * -3.0)))) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.95e-65) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 1.4e-92) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(Float64(c * Float64(a * -3.0)))) / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.95e-65) tmp = b / (a * -1.5); elseif (b <= 1.4e-92) tmp = -0.3333333333333333 * ((b - sqrt((c * (a * -3.0)))) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.95e-65], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.4e-92], N[(-0.3333333333333333 * N[(N[(b - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.95 \cdot 10^{-65}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{-92}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{c \cdot \left(a \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.9500000000000002e-65Initial program 62.1%
sqr-neg62.1%
sqr-neg62.1%
associate-*l*62.1%
Simplified62.1%
Taylor expanded in b around -inf 85.0%
*-commutative85.0%
Simplified85.0%
*-commutative85.0%
clear-num84.9%
un-div-inv84.9%
Applied egg-rr84.9%
associate-/r/84.9%
Simplified84.9%
*-commutative84.9%
clear-num84.9%
un-div-inv85.0%
div-inv85.1%
metadata-eval85.1%
Applied egg-rr85.1%
if -1.9500000000000002e-65 < b < 1.4e-92Initial program 85.5%
sqr-neg85.5%
sqr-neg85.5%
associate-*l*85.2%
Simplified85.2%
Taylor expanded in b around 0 78.5%
*-commutative78.5%
associate-*l*78.5%
*-commutative78.5%
*-commutative78.5%
Simplified78.5%
*-un-lft-identity78.5%
frac-2neg78.5%
Applied egg-rr78.8%
associate-*r/78.8%
*-commutative78.8%
times-frac78.5%
metadata-eval78.5%
Simplified78.5%
if 1.4e-92 < b Initial program 18.7%
sqr-neg18.7%
sqr-neg18.7%
associate-*l*18.7%
Simplified18.7%
Taylor expanded in b around inf 86.2%
*-commutative86.2%
Simplified86.2%
(FPCore (a b c) :precision binary64 (if (<= b -5e-311) (/ b (* a -1.5)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-311) {
tmp = b / (a * -1.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 <= (-5d-311)) then
tmp = b / (a * (-1.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 <= -5e-311) {
tmp = b / (a * -1.5);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-311: tmp = b / (a * -1.5) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-311) tmp = Float64(b / Float64(a * -1.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 <= -5e-311) tmp = b / (a * -1.5); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-311], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -5.00000000000023e-311Initial program 68.2%
sqr-neg68.2%
sqr-neg68.2%
associate-*l*68.1%
Simplified68.1%
Taylor expanded in b around -inf 67.1%
*-commutative67.1%
Simplified67.1%
*-commutative67.1%
clear-num67.0%
un-div-inv67.0%
Applied egg-rr67.0%
associate-/r/67.0%
Simplified67.0%
*-commutative67.0%
clear-num67.0%
un-div-inv67.1%
div-inv67.2%
metadata-eval67.2%
Applied egg-rr67.2%
if -5.00000000000023e-311 < b Initial program 37.3%
sqr-neg37.3%
sqr-neg37.3%
associate-*l*37.2%
Simplified37.2%
Taylor expanded in b around inf 65.1%
*-commutative65.1%
Simplified65.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-311) (* (/ b a) -0.6666666666666666) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-311) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-311)) then
tmp = (b / a) * (-0.6666666666666666d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-311) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-311: tmp = (b / a) * -0.6666666666666666 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-311) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-311) tmp = (b / a) * -0.6666666666666666; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-311], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -5.00000000000023e-311Initial program 68.2%
sqr-neg68.2%
sqr-neg68.2%
associate-*l*68.1%
Simplified68.1%
Taylor expanded in b around -inf 67.1%
*-commutative67.1%
Simplified67.1%
if -5.00000000000023e-311 < b Initial program 37.3%
sqr-neg37.3%
sqr-neg37.3%
associate-*l*37.2%
Simplified37.2%
Taylor expanded in b around inf 65.1%
*-commutative65.1%
Simplified65.1%
(FPCore (a b c) :precision binary64 (if (<= b 2.8e-308) (* (/ b a) -0.6666666666666666) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.8e-308) {
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 <= 2.8d-308) 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 <= 2.8e-308) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.8e-308: tmp = (b / a) * -0.6666666666666666 else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.8e-308) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(c * Float64(-0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.8e-308) tmp = (b / a) * -0.6666666666666666; else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.8e-308], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.8 \cdot 10^{-308}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 2.79999999999999984e-308Initial program 68.2%
sqr-neg68.2%
sqr-neg68.2%
associate-*l*68.1%
Simplified68.1%
Taylor expanded in b around -inf 67.1%
*-commutative67.1%
Simplified67.1%
if 2.79999999999999984e-308 < b Initial program 37.3%
sqr-neg37.3%
sqr-neg37.3%
associate-*l*37.2%
Simplified37.2%
Taylor expanded in b around inf 65.1%
*-commutative65.1%
Simplified65.1%
Taylor expanded in c around 0 65.1%
associate-*r/65.1%
*-commutative65.1%
associate-*r/64.9%
Simplified64.9%
(FPCore (a b c) :precision binary64 (if (<= b 2e-309) (* b (/ -0.6666666666666666 a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2e-309) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 2d-309) then
tmp = b * ((-0.6666666666666666d0) / a)
else
tmp = c * ((-0.5d0) / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2e-309) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2e-309: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2e-309) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(c * Float64(-0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2e-309) tmp = b * (-0.6666666666666666 / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2e-309], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2 \cdot 10^{-309}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 1.9999999999999988e-309Initial program 68.2%
sqr-neg68.2%
sqr-neg68.2%
associate-*l*68.1%
Simplified68.1%
Taylor expanded in b around -inf 67.1%
*-commutative67.1%
Simplified67.1%
*-commutative67.1%
clear-num67.0%
un-div-inv67.0%
Applied egg-rr67.0%
associate-/r/67.0%
Simplified67.0%
if 1.9999999999999988e-309 < b Initial program 37.3%
sqr-neg37.3%
sqr-neg37.3%
associate-*l*37.2%
Simplified37.2%
Taylor expanded in b around inf 65.1%
*-commutative65.1%
Simplified65.1%
Taylor expanded in c around 0 65.1%
associate-*r/65.1%
*-commutative65.1%
associate-*r/64.9%
Simplified64.9%
Final simplification65.8%
(FPCore (a b c) :precision binary64 (* c (/ -0.5 b)))
double code(double a, double b, double c) {
return c * (-0.5 / b);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = c * ((-0.5d0) / b)
end function
public static double code(double a, double b, double c) {
return c * (-0.5 / b);
}
def code(a, b, c): return c * (-0.5 / b)
function code(a, b, c) return Float64(c * Float64(-0.5 / b)) end
function tmp = code(a, b, c) tmp = c * (-0.5 / b); end
code[a_, b_, c_] := N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c \cdot \frac{-0.5}{b}
\end{array}
Initial program 50.3%
sqr-neg50.3%
sqr-neg50.3%
associate-*l*50.2%
Simplified50.2%
Taylor expanded in b around inf 38.5%
*-commutative38.5%
Simplified38.5%
Taylor expanded in c around 0 38.5%
associate-*r/38.5%
*-commutative38.5%
associate-*r/38.4%
Simplified38.4%
(FPCore (a b c) :precision binary64 (* b (/ 0.6666666666666666 a)))
double code(double a, double b, double c) {
return b * (0.6666666666666666 / a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = b * (0.6666666666666666d0 / a)
end function
public static double code(double a, double b, double c) {
return b * (0.6666666666666666 / a);
}
def code(a, b, c): return b * (0.6666666666666666 / a)
function code(a, b, c) return Float64(b * Float64(0.6666666666666666 / a)) end
function tmp = code(a, b, c) tmp = b * (0.6666666666666666 / a); end
code[a_, b_, c_] := N[(b * N[(0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \frac{0.6666666666666666}{a}
\end{array}
Initial program 50.3%
sqr-neg50.3%
sqr-neg50.3%
associate-*l*50.2%
Simplified50.2%
Taylor expanded in b around -inf 30.0%
*-commutative30.0%
Simplified30.0%
*-commutative30.0%
clear-num30.0%
un-div-inv30.0%
Applied egg-rr30.0%
associate-/r/30.0%
Simplified30.0%
frac-2neg30.0%
associate-*l/30.0%
distribute-lft-neg-in30.0%
distribute-rgt-neg-in30.0%
add-sqr-sqrt28.2%
sqrt-unprod20.7%
sqr-neg20.7%
sqrt-prod2.3%
add-sqr-sqrt2.8%
*-commutative2.8%
Applied egg-rr2.8%
distribute-frac-neg22.8%
distribute-frac-neg2.8%
distribute-rgt-neg-in2.8%
metadata-eval2.8%
associate-/l*2.8%
Simplified2.8%
herbie shell --seed 2024137
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))