
(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 11 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 (or (<= b 8.6e+25) (and (not (<= b 2.95e+27)) (<= b 9.4e+27)))
(+
(* -0.5625 (/ (* (pow a 2.0) (pow c 3.0)) (pow b 5.0)))
(+
(* -0.5 (/ c b))
(+
(* -0.375 (/ (* a (pow c 2.0)) (pow b 3.0)))
(*
-0.16666666666666666
(/
(+
(* 5.0625 (* (pow a 4.0) (pow c 4.0)))
(* (pow (* a c) 4.0) 1.265625))
(* a (pow b 7.0)))))))
(/ (log (exp (* a (* (/ c b) -1.5)))) (* a 3.0))))
double code(double a, double b, double c) {
double tmp;
if ((b <= 8.6e+25) || (!(b <= 2.95e+27) && (b <= 9.4e+27))) {
tmp = (-0.5625 * ((pow(a, 2.0) * pow(c, 3.0)) / pow(b, 5.0))) + ((-0.5 * (c / b)) + ((-0.375 * ((a * pow(c, 2.0)) / pow(b, 3.0))) + (-0.16666666666666666 * (((5.0625 * (pow(a, 4.0) * pow(c, 4.0))) + (pow((a * c), 4.0) * 1.265625)) / (a * pow(b, 7.0))))));
} else {
tmp = log(exp((a * ((c / b) * -1.5)))) / (a * 3.0);
}
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.6d+25) .or. (.not. (b <= 2.95d+27)) .and. (b <= 9.4d+27)) then
tmp = ((-0.5625d0) * (((a ** 2.0d0) * (c ** 3.0d0)) / (b ** 5.0d0))) + (((-0.5d0) * (c / b)) + (((-0.375d0) * ((a * (c ** 2.0d0)) / (b ** 3.0d0))) + ((-0.16666666666666666d0) * (((5.0625d0 * ((a ** 4.0d0) * (c ** 4.0d0))) + (((a * c) ** 4.0d0) * 1.265625d0)) / (a * (b ** 7.0d0))))))
else
tmp = log(exp((a * ((c / b) * (-1.5d0))))) / (a * 3.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if ((b <= 8.6e+25) || (!(b <= 2.95e+27) && (b <= 9.4e+27))) {
tmp = (-0.5625 * ((Math.pow(a, 2.0) * Math.pow(c, 3.0)) / Math.pow(b, 5.0))) + ((-0.5 * (c / b)) + ((-0.375 * ((a * Math.pow(c, 2.0)) / Math.pow(b, 3.0))) + (-0.16666666666666666 * (((5.0625 * (Math.pow(a, 4.0) * Math.pow(c, 4.0))) + (Math.pow((a * c), 4.0) * 1.265625)) / (a * Math.pow(b, 7.0))))));
} else {
tmp = Math.log(Math.exp((a * ((c / b) * -1.5)))) / (a * 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if (b <= 8.6e+25) or (not (b <= 2.95e+27) and (b <= 9.4e+27)): tmp = (-0.5625 * ((math.pow(a, 2.0) * math.pow(c, 3.0)) / math.pow(b, 5.0))) + ((-0.5 * (c / b)) + ((-0.375 * ((a * math.pow(c, 2.0)) / math.pow(b, 3.0))) + (-0.16666666666666666 * (((5.0625 * (math.pow(a, 4.0) * math.pow(c, 4.0))) + (math.pow((a * c), 4.0) * 1.265625)) / (a * math.pow(b, 7.0)))))) else: tmp = math.log(math.exp((a * ((c / b) * -1.5)))) / (a * 3.0) return tmp
function code(a, b, c) tmp = 0.0 if ((b <= 8.6e+25) || (!(b <= 2.95e+27) && (b <= 9.4e+27))) tmp = Float64(Float64(-0.5625 * Float64(Float64((a ^ 2.0) * (c ^ 3.0)) / (b ^ 5.0))) + Float64(Float64(-0.5 * Float64(c / b)) + Float64(Float64(-0.375 * Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0))) + Float64(-0.16666666666666666 * Float64(Float64(Float64(5.0625 * Float64((a ^ 4.0) * (c ^ 4.0))) + Float64((Float64(a * c) ^ 4.0) * 1.265625)) / Float64(a * (b ^ 7.0))))))); else tmp = Float64(log(exp(Float64(a * Float64(Float64(c / b) * -1.5)))) / Float64(a * 3.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if ((b <= 8.6e+25) || (~((b <= 2.95e+27)) && (b <= 9.4e+27))) tmp = (-0.5625 * (((a ^ 2.0) * (c ^ 3.0)) / (b ^ 5.0))) + ((-0.5 * (c / b)) + ((-0.375 * ((a * (c ^ 2.0)) / (b ^ 3.0))) + (-0.16666666666666666 * (((5.0625 * ((a ^ 4.0) * (c ^ 4.0))) + (((a * c) ^ 4.0) * 1.265625)) / (a * (b ^ 7.0)))))); else tmp = log(exp((a * ((c / b) * -1.5)))) / (a * 3.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[Or[LessEqual[b, 8.6e+25], And[N[Not[LessEqual[b, 2.95e+27]], $MachinePrecision], LessEqual[b, 9.4e+27]]], N[(N[(-0.5625 * N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.375 * N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.16666666666666666 * N[(N[(N[(5.0625 * N[(N[Power[a, 4.0], $MachinePrecision] * N[Power[c, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[(a * c), $MachinePrecision], 4.0], $MachinePrecision] * 1.265625), $MachinePrecision]), $MachinePrecision] / N[(a * N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Log[N[Exp[N[(a * N[(N[(c / b), $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8.6 \cdot 10^{+25} \lor \neg \left(b \leq 2.95 \cdot 10^{+27}\right) \land b \leq 9.4 \cdot 10^{+27}:\\
\;\;\;\;-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.16666666666666666 \cdot \frac{5.0625 \cdot \left({a}^{4} \cdot {c}^{4}\right) + {\left(a \cdot c\right)}^{4} \cdot 1.265625}{a \cdot {b}^{7}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(e^{a \cdot \left(\frac{c}{b} \cdot -1.5\right)}\right)}{a \cdot 3}\\
\end{array}
\end{array}
if b < 8.59999999999999996e25 or 2.95000000000000022e27 < b < 9.39999999999999952e27Initial program 29.1%
Taylor expanded in b around inf 88.2%
*-commutative88.2%
unpow-prod-down88.2%
pow-prod-down88.2%
pow-pow88.2%
metadata-eval88.2%
metadata-eval88.2%
Applied egg-rr88.2%
if 8.59999999999999996e25 < b < 2.95000000000000022e27 or 9.39999999999999952e27 < b Initial program 65.7%
Taylor expanded in b around inf 38.6%
associate-/l*38.6%
Simplified38.6%
log1p-expm1-u32.8%
log1p-udef79.1%
associate-*r/79.1%
Applied egg-rr79.1%
add-exp-log79.1%
log1p-def79.1%
log1p-expm1-u79.1%
div-inv79.1%
clear-num79.1%
*-commutative79.1%
associate-*l*79.1%
Applied egg-rr79.1%
Final simplification86.9%
(FPCore (a b c)
:precision binary64
(if (or (<= b 6.5e+25) (and (not (<= b 2.95e+27)) (<= b 1.7e+28)))
(+
(* -0.5625 (/ (* (pow a 2.0) (pow c 3.0)) (pow b 5.0)))
(+ (* -0.5 (/ c b)) (* -0.375 (/ (* a (pow c 2.0)) (pow b 3.0)))))
(/ (log (exp (* a (* (/ c b) -1.5)))) (* a 3.0))))
double code(double a, double b, double c) {
double tmp;
if ((b <= 6.5e+25) || (!(b <= 2.95e+27) && (b <= 1.7e+28))) {
tmp = (-0.5625 * ((pow(a, 2.0) * pow(c, 3.0)) / pow(b, 5.0))) + ((-0.5 * (c / b)) + (-0.375 * ((a * pow(c, 2.0)) / pow(b, 3.0))));
} else {
tmp = log(exp((a * ((c / b) * -1.5)))) / (a * 3.0);
}
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.5d+25) .or. (.not. (b <= 2.95d+27)) .and. (b <= 1.7d+28)) then
tmp = ((-0.5625d0) * (((a ** 2.0d0) * (c ** 3.0d0)) / (b ** 5.0d0))) + (((-0.5d0) * (c / b)) + ((-0.375d0) * ((a * (c ** 2.0d0)) / (b ** 3.0d0))))
else
tmp = log(exp((a * ((c / b) * (-1.5d0))))) / (a * 3.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if ((b <= 6.5e+25) || (!(b <= 2.95e+27) && (b <= 1.7e+28))) {
tmp = (-0.5625 * ((Math.pow(a, 2.0) * Math.pow(c, 3.0)) / Math.pow(b, 5.0))) + ((-0.5 * (c / b)) + (-0.375 * ((a * Math.pow(c, 2.0)) / Math.pow(b, 3.0))));
} else {
tmp = Math.log(Math.exp((a * ((c / b) * -1.5)))) / (a * 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if (b <= 6.5e+25) or (not (b <= 2.95e+27) and (b <= 1.7e+28)): tmp = (-0.5625 * ((math.pow(a, 2.0) * math.pow(c, 3.0)) / math.pow(b, 5.0))) + ((-0.5 * (c / b)) + (-0.375 * ((a * math.pow(c, 2.0)) / math.pow(b, 3.0)))) else: tmp = math.log(math.exp((a * ((c / b) * -1.5)))) / (a * 3.0) return tmp
function code(a, b, c) tmp = 0.0 if ((b <= 6.5e+25) || (!(b <= 2.95e+27) && (b <= 1.7e+28))) tmp = Float64(Float64(-0.5625 * Float64(Float64((a ^ 2.0) * (c ^ 3.0)) / (b ^ 5.0))) + Float64(Float64(-0.5 * Float64(c / b)) + Float64(-0.375 * Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0))))); else tmp = Float64(log(exp(Float64(a * Float64(Float64(c / b) * -1.5)))) / Float64(a * 3.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if ((b <= 6.5e+25) || (~((b <= 2.95e+27)) && (b <= 1.7e+28))) tmp = (-0.5625 * (((a ^ 2.0) * (c ^ 3.0)) / (b ^ 5.0))) + ((-0.5 * (c / b)) + (-0.375 * ((a * (c ^ 2.0)) / (b ^ 3.0)))); else tmp = log(exp((a * ((c / b) * -1.5)))) / (a * 3.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[Or[LessEqual[b, 6.5e+25], And[N[Not[LessEqual[b, 2.95e+27]], $MachinePrecision], LessEqual[b, 1.7e+28]]], N[(N[(-0.5625 * N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.375 * N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Log[N[Exp[N[(a * N[(N[(c / b), $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.5 \cdot 10^{+25} \lor \neg \left(b \leq 2.95 \cdot 10^{+27}\right) \land b \leq 1.7 \cdot 10^{+28}:\\
\;\;\;\;-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(e^{a \cdot \left(\frac{c}{b} \cdot -1.5\right)}\right)}{a \cdot 3}\\
\end{array}
\end{array}
if b < 6.50000000000000005e25 or 2.95000000000000022e27 < b < 1.7e28Initial program 29.1%
Taylor expanded in b around inf 87.5%
if 6.50000000000000005e25 < b < 2.95000000000000022e27 or 1.7e28 < b Initial program 65.7%
Taylor expanded in b around inf 38.6%
associate-/l*38.6%
Simplified38.6%
log1p-expm1-u32.8%
log1p-udef79.1%
associate-*r/79.1%
Applied egg-rr79.1%
add-exp-log79.1%
log1p-def79.1%
log1p-expm1-u79.1%
div-inv79.1%
clear-num79.1%
*-commutative79.1%
associate-*l*79.1%
Applied egg-rr79.1%
Final simplification86.3%
(FPCore (a b c) :precision binary64 (let* ((t_0 (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0)))) (if (<= t_0 -2e-21) t_0 (/ (* c -0.5) b))))
double code(double a, double b, double c) {
double t_0 = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
double tmp;
if (t_0 <= -2e-21) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = (sqrt(((b * b) - (c * (a * 3.0d0)))) - b) / (a * 3.0d0)
if (t_0 <= (-2d-21)) then
tmp = t_0
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
double tmp;
if (t_0 <= -2e-21) {
tmp = t_0;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): t_0 = (math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0) tmp = 0 if t_0 <= -2e-21: tmp = t_0 else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) t_0 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)) tmp = 0.0 if (t_0 <= -2e-21) tmp = t_0; else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) t_0 = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0); tmp = 0.0; if (t_0 <= -2e-21) tmp = t_0; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-21], t$95$0, N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-21}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -1.99999999999999982e-21Initial program 66.2%
if -1.99999999999999982e-21 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) Initial program 25.3%
Taylor expanded in b around inf 78.7%
associate-*r/78.7%
Simplified78.7%
Final simplification76.0%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (* c -0.5) b)))
(if (<= b 9.5e+22)
t_0
(if (<= b 5.6e+23)
(log (+ 1.0 (expm1 (* c (/ -0.5 b)))))
(if (<= b 8.5e+25)
t_0
(/ (log (exp (* a (* (/ c b) -1.5)))) (* a 3.0)))))))
double code(double a, double b, double c) {
double t_0 = (c * -0.5) / b;
double tmp;
if (b <= 9.5e+22) {
tmp = t_0;
} else if (b <= 5.6e+23) {
tmp = log((1.0 + expm1((c * (-0.5 / b)))));
} else if (b <= 8.5e+25) {
tmp = t_0;
} else {
tmp = log(exp((a * ((c / b) * -1.5)))) / (a * 3.0);
}
return tmp;
}
public static double code(double a, double b, double c) {
double t_0 = (c * -0.5) / b;
double tmp;
if (b <= 9.5e+22) {
tmp = t_0;
} else if (b <= 5.6e+23) {
tmp = Math.log((1.0 + Math.expm1((c * (-0.5 / b)))));
} else if (b <= 8.5e+25) {
tmp = t_0;
} else {
tmp = Math.log(Math.exp((a * ((c / b) * -1.5)))) / (a * 3.0);
}
return tmp;
}
def code(a, b, c): t_0 = (c * -0.5) / b tmp = 0 if b <= 9.5e+22: tmp = t_0 elif b <= 5.6e+23: tmp = math.log((1.0 + math.expm1((c * (-0.5 / b))))) elif b <= 8.5e+25: tmp = t_0 else: tmp = math.log(math.exp((a * ((c / b) * -1.5)))) / (a * 3.0) return tmp
function code(a, b, c) t_0 = Float64(Float64(c * -0.5) / b) tmp = 0.0 if (b <= 9.5e+22) tmp = t_0; elseif (b <= 5.6e+23) tmp = log(Float64(1.0 + expm1(Float64(c * Float64(-0.5 / b))))); elseif (b <= 8.5e+25) tmp = t_0; else tmp = Float64(log(exp(Float64(a * Float64(Float64(c / b) * -1.5)))) / Float64(a * 3.0)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]}, If[LessEqual[b, 9.5e+22], t$95$0, If[LessEqual[b, 5.6e+23], N[Log[N[(1.0 + N[(Exp[N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[b, 8.5e+25], t$95$0, N[(N[Log[N[Exp[N[(a * N[(N[(c / b), $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot -0.5}{b}\\
\mathbf{if}\;b \leq 9.5 \cdot 10^{+22}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{+23}:\\
\;\;\;\;\log \left(1 + \mathsf{expm1}\left(c \cdot \frac{-0.5}{b}\right)\right)\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{+25}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(e^{a \cdot \left(\frac{c}{b} \cdot -1.5\right)}\right)}{a \cdot 3}\\
\end{array}
\end{array}
if b < 9.49999999999999937e22 or 5.6e23 < b < 8.5000000000000007e25Initial program 27.2%
Taylor expanded in b around inf 81.5%
associate-*r/81.5%
Simplified81.5%
if 9.49999999999999937e22 < b < 5.6e23Initial program 72.0%
Taylor expanded in b around inf 33.8%
associate-*r/33.8%
associate-/l*33.8%
Simplified33.8%
log1p-expm1-u33.8%
log1p-udef84.7%
associate-/r/84.7%
Applied egg-rr84.7%
if 8.5000000000000007e25 < b Initial program 62.1%
Taylor expanded in b around inf 42.9%
associate-/l*42.8%
Simplified42.8%
log1p-expm1-u36.2%
log1p-udef69.9%
associate-*r/69.9%
Applied egg-rr69.9%
add-exp-log69.9%
log1p-def69.9%
log1p-expm1-u69.9%
div-inv69.9%
clear-num69.9%
*-commutative69.9%
associate-*l*69.9%
Applied egg-rr69.9%
Final simplification79.8%
(FPCore (a b c) :precision binary64 (if (<= b 7e+25) (+ (* -0.5 (/ c b)) (* -0.375 (/ (* a (pow c 2.0)) (pow b 3.0)))) (/ (log (exp (* a (* (/ c b) -1.5)))) (* a 3.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= 7e+25) {
tmp = (-0.5 * (c / b)) + (-0.375 * ((a * pow(c, 2.0)) / pow(b, 3.0)));
} else {
tmp = log(exp((a * ((c / b) * -1.5)))) / (a * 3.0);
}
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 <= 7d+25) then
tmp = ((-0.5d0) * (c / b)) + ((-0.375d0) * ((a * (c ** 2.0d0)) / (b ** 3.0d0)))
else
tmp = log(exp((a * ((c / b) * (-1.5d0))))) / (a * 3.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 7e+25) {
tmp = (-0.5 * (c / b)) + (-0.375 * ((a * Math.pow(c, 2.0)) / Math.pow(b, 3.0)));
} else {
tmp = Math.log(Math.exp((a * ((c / b) * -1.5)))) / (a * 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7e+25: tmp = (-0.5 * (c / b)) + (-0.375 * ((a * math.pow(c, 2.0)) / math.pow(b, 3.0))) else: tmp = math.log(math.exp((a * ((c / b) * -1.5)))) / (a * 3.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7e+25) tmp = Float64(Float64(-0.5 * Float64(c / b)) + Float64(-0.375 * Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0)))); else tmp = Float64(log(exp(Float64(a * Float64(Float64(c / b) * -1.5)))) / Float64(a * 3.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 7e+25) tmp = (-0.5 * (c / b)) + (-0.375 * ((a * (c ^ 2.0)) / (b ^ 3.0))); else tmp = log(exp((a * ((c / b) * -1.5)))) / (a * 3.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7e+25], N[(N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.375 * N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Log[N[Exp[N[(a * N[(N[(c / b), $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7 \cdot 10^{+25}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(e^{a \cdot \left(\frac{c}{b} \cdot -1.5\right)}\right)}{a \cdot 3}\\
\end{array}
\end{array}
if b < 6.99999999999999999e25Initial program 28.9%
Taylor expanded in b around inf 85.8%
if 6.99999999999999999e25 < b Initial program 62.1%
Taylor expanded in b around inf 42.9%
associate-/l*42.8%
Simplified42.8%
log1p-expm1-u36.2%
log1p-udef69.9%
associate-*r/69.9%
Applied egg-rr69.9%
add-exp-log69.9%
log1p-def69.9%
log1p-expm1-u69.9%
div-inv69.9%
clear-num69.9%
*-commutative69.9%
associate-*l*69.9%
Applied egg-rr69.9%
Final simplification83.2%
(FPCore (a b c) :precision binary64 (if (<= b 8e+25) (/ (* c -0.5) b) (/ (log (+ 1.0 (* a (* c (/ -1.5 b))))) (* a 3.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= 8e+25) {
tmp = (c * -0.5) / b;
} else {
tmp = log((1.0 + (a * (c * (-1.5 / b))))) / (a * 3.0);
}
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+25) then
tmp = (c * (-0.5d0)) / b
else
tmp = log((1.0d0 + (a * (c * ((-1.5d0) / b))))) / (a * 3.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 8e+25) {
tmp = (c * -0.5) / b;
} else {
tmp = Math.log((1.0 + (a * (c * (-1.5 / b))))) / (a * 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 8e+25: tmp = (c * -0.5) / b else: tmp = math.log((1.0 + (a * (c * (-1.5 / b))))) / (a * 3.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 8e+25) tmp = Float64(Float64(c * -0.5) / b); else tmp = Float64(log(Float64(1.0 + Float64(a * Float64(c * Float64(-1.5 / b))))) / Float64(a * 3.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 8e+25) tmp = (c * -0.5) / b; else tmp = log((1.0 + (a * (c * (-1.5 / b))))) / (a * 3.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 8e+25], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision], N[(N[Log[N[(1.0 + N[(a * N[(c * N[(-1.5 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8 \cdot 10^{+25}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(1 + a \cdot \left(c \cdot \frac{-1.5}{b}\right)\right)}{a \cdot 3}\\
\end{array}
\end{array}
if b < 8.00000000000000072e25Initial program 28.9%
Taylor expanded in b around inf 79.8%
associate-*r/79.8%
Simplified79.8%
if 8.00000000000000072e25 < b Initial program 62.1%
Taylor expanded in b around inf 42.9%
associate-/l*42.8%
Simplified42.8%
log1p-expm1-u36.2%
log1p-udef69.9%
associate-*r/69.9%
Applied egg-rr69.9%
Taylor expanded in a around 0 64.0%
+-commutative64.0%
associate-*r/64.0%
associate-*r*64.0%
*-commutative64.0%
associate-*r*64.0%
associate-*r/64.0%
*-commutative64.0%
associate-*r/64.0%
Simplified64.0%
Final simplification77.2%
(FPCore (a b c) :precision binary64 (if (<= b 8.2e+25) (/ (* c -0.5) b) (/ (+ b (- (/ (* a -1.5) (/ b c)) b)) (* a 3.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= 8.2e+25) {
tmp = (c * -0.5) / b;
} else {
tmp = (b + (((a * -1.5) / (b / c)) - b)) / (a * 3.0);
}
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.2d+25) then
tmp = (c * (-0.5d0)) / b
else
tmp = (b + (((a * (-1.5d0)) / (b / c)) - b)) / (a * 3.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 8.2e+25) {
tmp = (c * -0.5) / b;
} else {
tmp = (b + (((a * -1.5) / (b / c)) - b)) / (a * 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 8.2e+25: tmp = (c * -0.5) / b else: tmp = (b + (((a * -1.5) / (b / c)) - b)) / (a * 3.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 8.2e+25) tmp = Float64(Float64(c * -0.5) / b); else tmp = Float64(Float64(b + Float64(Float64(Float64(a * -1.5) / Float64(b / c)) - b)) / Float64(a * 3.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 8.2e+25) tmp = (c * -0.5) / b; else tmp = (b + (((a * -1.5) / (b / c)) - b)) / (a * 3.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 8.2e+25], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision], N[(N[(b + N[(N[(N[(a * -1.5), $MachinePrecision] / N[(b / c), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8.2 \cdot 10^{+25}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + \left(\frac{a \cdot -1.5}{\frac{b}{c}} - b\right)}{a \cdot 3}\\
\end{array}
\end{array}
if b < 8.19999999999999933e25Initial program 28.9%
Taylor expanded in b around inf 79.8%
associate-*r/79.8%
Simplified79.8%
if 8.19999999999999933e25 < b Initial program 62.1%
+-commutative62.1%
sqr-neg62.1%
unsub-neg62.1%
div-sub62.1%
--rgt-identity62.1%
div-sub62.1%
Simplified62.1%
Taylor expanded in b around inf 59.4%
associate--l+59.4%
associate-/l*59.4%
associate-*r/59.4%
Applied egg-rr59.4%
Final simplification76.5%
(FPCore (a b c) :precision binary64 (if (<= b 8.6e+25) (/ (* c -0.5) b) (if (<= b 4.7e+29) (/ (- b b) (* a 3.0)) (/ -0.5 (/ b c)))))
double code(double a, double b, double c) {
double tmp;
if (b <= 8.6e+25) {
tmp = (c * -0.5) / b;
} else if (b <= 4.7e+29) {
tmp = (b - b) / (a * 3.0);
} else {
tmp = -0.5 / (b / c);
}
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.6d+25) then
tmp = (c * (-0.5d0)) / b
else if (b <= 4.7d+29) then
tmp = (b - b) / (a * 3.0d0)
else
tmp = (-0.5d0) / (b / c)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 8.6e+25) {
tmp = (c * -0.5) / b;
} else if (b <= 4.7e+29) {
tmp = (b - b) / (a * 3.0);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 8.6e+25: tmp = (c * -0.5) / b elif b <= 4.7e+29: tmp = (b - b) / (a * 3.0) else: tmp = -0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 8.6e+25) tmp = Float64(Float64(c * -0.5) / b); elseif (b <= 4.7e+29) tmp = Float64(Float64(b - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 / Float64(b / c)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 8.6e+25) tmp = (c * -0.5) / b; elseif (b <= 4.7e+29) tmp = (b - b) / (a * 3.0); else tmp = -0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 8.6e+25], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision], If[LessEqual[b, 4.7e+29], N[(N[(b - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8.6 \cdot 10^{+25}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\mathbf{elif}\;b \leq 4.7 \cdot 10^{+29}:\\
\;\;\;\;\frac{b - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < 8.59999999999999996e25Initial program 28.9%
Taylor expanded in b around inf 79.8%
associate-*r/79.8%
Simplified79.8%
if 8.59999999999999996e25 < b < 4.7000000000000002e29Initial program 71.3%
+-commutative71.3%
sqr-neg71.3%
unsub-neg71.3%
div-sub71.3%
--rgt-identity71.3%
div-sub71.3%
Simplified71.3%
Taylor expanded in b around inf 65.5%
if 4.7000000000000002e29 < b Initial program 42.1%
Taylor expanded in b around inf 64.0%
associate-*r/64.0%
associate-/l*64.0%
Simplified64.0%
Final simplification77.4%
(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 34.2%
Taylor expanded in b around inf 73.9%
associate-*r/73.9%
associate-/l*73.7%
Simplified73.7%
associate-/r/73.6%
Applied egg-rr73.6%
Final simplification73.6%
(FPCore (a b c) :precision binary64 (/ -0.5 (/ b c)))
double code(double a, double b, double c) {
return -0.5 / (b / c);
}
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) / (b / c)
end function
public static double code(double a, double b, double c) {
return -0.5 / (b / c);
}
def code(a, b, c): return -0.5 / (b / c)
function code(a, b, c) return Float64(-0.5 / Float64(b / c)) end
function tmp = code(a, b, c) tmp = -0.5 / (b / c); end
code[a_, b_, c_] := N[(-0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-0.5}{\frac{b}{c}}
\end{array}
Initial program 34.2%
Taylor expanded in b around inf 73.9%
associate-*r/73.9%
associate-/l*73.7%
Simplified73.7%
Final simplification73.7%
(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(Float64(c * -0.5) / b) end
function tmp = code(a, b, c) tmp = (c * -0.5) / b; end
code[a_, b_, c_] := N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{c \cdot -0.5}{b}
\end{array}
Initial program 34.2%
Taylor expanded in b around inf 73.9%
associate-*r/73.9%
Simplified73.9%
Final simplification73.9%
herbie shell --seed 2024031
(FPCore (a b c)
:name "Cubic critical, wide range"
:precision binary64
:pre (and (and (and (< 4.930380657631324e-32 a) (< a 2.028240960365167e+31)) (and (< 4.930380657631324e-32 b) (< b 2.028240960365167e+31))) (and (< 4.930380657631324e-32 c) (< c 2.028240960365167e+31)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))