(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* (cosh x) (/ y x)) z)))
(if (<= t_0 -3.03197732379256e+304)
(/ y (* x z))
(if (<= t_0 4.894914819057092e+146) t_0 (/ (/ (cosh x) x) (/ z y))))))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)) / z;
double tmp;
if (t_0 <= -3.03197732379256e+304) {
tmp = y / (x * z);
} else if (t_0 <= 4.894914819057092e+146) {
tmp = t_0;
} else {
tmp = (cosh(x) / x) / (z / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (cosh(x) * (y / x)) / z
end function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (cosh(x) * (y / x)) / z
if (t_0 <= (-3.03197732379256d+304)) then
tmp = y / (x * z)
else if (t_0 <= 4.894914819057092d+146) then
tmp = t_0
else
tmp = (cosh(x) / x) / (z / y)
end if
code = tmp
end function
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)) / z;
double tmp;
if (t_0 <= -3.03197732379256e+304) {
tmp = y / (x * z);
} else if (t_0 <= 4.894914819057092e+146) {
tmp = t_0;
} else {
tmp = (Math.cosh(x) / x) / (z / y);
}
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)) / z tmp = 0 if t_0 <= -3.03197732379256e+304: tmp = y / (x * z) elif t_0 <= 4.894914819057092e+146: tmp = t_0 else: tmp = (math.cosh(x) / x) / (z / y) 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(Float64(cosh(x) * Float64(y / x)) / z) tmp = 0.0 if (t_0 <= -3.03197732379256e+304) tmp = Float64(y / Float64(x * z)); elseif (t_0 <= 4.894914819057092e+146) tmp = t_0; else tmp = Float64(Float64(cosh(x) / x) / Float64(z / y)); 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)) / z; tmp = 0.0; if (t_0 <= -3.03197732379256e+304) tmp = y / (x * z); elseif (t_0 <= 4.894914819057092e+146) tmp = t_0; else tmp = (cosh(x) / x) / (z / y); 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[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[t$95$0, -3.03197732379256e+304], N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4.894914819057092e+146], t$95$0, N[(N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision] / N[(z / y), $MachinePrecision]), $MachinePrecision]]]]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
t_0 := \frac{\cosh x \cdot \frac{y}{x}}{z}\\
\mathbf{if}\;t_0 \leq -3.03197732379256 \cdot 10^{+304}:\\
\;\;\;\;\frac{y}{x \cdot z}\\
\mathbf{elif}\;t_0 \leq 4.894914819057092 \cdot 10^{+146}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cosh x}{x}}{\frac{z}{y}}\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 7.7 |
|---|---|
| Target | 0.4 |
| Herbie | 0.4 |
if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < -3.03197732379256014e304Initial program 61.6
Simplified0.7
Taylor expanded in x around 0 1.7
if -3.03197732379256014e304 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 4.8949148190570921e146Initial program 0.2
if 4.8949148190570921e146 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) Initial program 22.1
Simplified0.6
Applied egg-rr17.5
Applied egg-rr0.6
Final simplification0.4
herbie shell --seed 2022153
(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))