(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (cosh x) (/ y x))))
(if (<= t_0 (- INFINITY))
(* (cosh x) (/ (/ y z) x))
(if (<= t_0 2e+293) (/ t_0 z) (/ y (* z (/ x (cosh x))))))))double code(double x, double y, double z) {
return (cosh(x) * (y / x)) / z;
}
double code(double x, double y, double z) {
double t_0 = cosh(x) * (y / x);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = cosh(x) * ((y / z) / x);
} else if (t_0 <= 2e+293) {
tmp = t_0 / z;
} else {
tmp = y / (z * (x / cosh(x)));
}
return tmp;
}
public static double code(double x, double y, double z) {
return (Math.cosh(x) * (y / x)) / z;
}
public static double code(double x, double y, double z) {
double t_0 = Math.cosh(x) * (y / x);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = Math.cosh(x) * ((y / z) / x);
} else if (t_0 <= 2e+293) {
tmp = t_0 / z;
} else {
tmp = y / (z * (x / Math.cosh(x)));
}
return tmp;
}
def code(x, y, z): return (math.cosh(x) * (y / x)) / z
def code(x, y, z): t_0 = math.cosh(x) * (y / x) tmp = 0 if t_0 <= -math.inf: tmp = math.cosh(x) * ((y / z) / x) elif t_0 <= 2e+293: tmp = t_0 / z else: tmp = y / (z * (x / math.cosh(x))) return tmp
function code(x, y, z) return Float64(Float64(cosh(x) * Float64(y / x)) / z) end
function code(x, y, z) t_0 = Float64(cosh(x) * Float64(y / x)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(cosh(x) * Float64(Float64(y / z) / x)); elseif (t_0 <= 2e+293) tmp = Float64(t_0 / z); else tmp = Float64(y / Float64(z * Float64(x / cosh(x)))); end return tmp end
function tmp = code(x, y, z) tmp = (cosh(x) * (y / x)) / z; end
function tmp_2 = code(x, y, z) t_0 = cosh(x) * (y / x); tmp = 0.0; if (t_0 <= -Inf) tmp = cosh(x) * ((y / z) / x); elseif (t_0 <= 2e+293) tmp = t_0 / z; else tmp = y / (z * (x / cosh(x))); end tmp_2 = tmp; end
code[x_, y_, z_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[Cosh[x], $MachinePrecision] * N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+293], N[(t$95$0 / z), $MachinePrecision], N[(y / N[(z * N[(x / N[Cosh[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
t_0 := \cosh x \cdot \frac{y}{x}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+293}:\\
\;\;\;\;\frac{t_0}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z \cdot \frac{x}{\cosh x}}\\
\end{array}
Results
| Original | 7.5 |
|---|---|
| Target | 0.5 |
| Herbie | 0.3 |
if (*.f64 (cosh.f64 x) (/.f64 y x)) < -inf.0Initial program 64.0
Simplified0.9
Applied egg-rr0.8
if -inf.0 < (*.f64 (cosh.f64 x) (/.f64 y x)) < 1.9999999999999998e293Initial program 0.3
if 1.9999999999999998e293 < (*.f64 (cosh.f64 x) (/.f64 y x)) Initial program 54.9
Simplified0.7
Applied egg-rr0.8
Applied egg-rr0.7
Final simplification0.3
herbie shell --seed 2022190
(FPCore (x y z)
:name "Linear.Quaternion:$ctan from linear-1.19.1.3"
:precision binary64
:herbie-target
(if (< y -4.618902267687042e-52) (* (/ (/ y z) x) (cosh x)) (if (< y 1.038530535935153e-39) (/ (/ (* (cosh x) y) x) z) (* (/ (/ y z) x) (cosh x))))
(/ (* (cosh x) (/ y x)) z))