(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)) (t_1 (/ (* (cosh x) (/ y z)) x)))
(if (<= t_0 -3.2215213879243386e+31)
t_1
(if (<= t_0 1.0169092197592784e-21) (/ (* (cosh x) y) (* x z)) t_1))))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 t_1 = (cosh(x) * (y / z)) / x;
double tmp;
if (t_0 <= -3.2215213879243386e+31) {
tmp = t_1;
} else if (t_0 <= 1.0169092197592784e-21) {
tmp = (cosh(x) * y) / (x * z);
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = (cosh(x) * (y / x)) / z
t_1 = (cosh(x) * (y / z)) / x
if (t_0 <= (-3.2215213879243386d+31)) then
tmp = t_1
else if (t_0 <= 1.0169092197592784d-21) then
tmp = (cosh(x) * y) / (x * z)
else
tmp = t_1
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 t_1 = (Math.cosh(x) * (y / z)) / x;
double tmp;
if (t_0 <= -3.2215213879243386e+31) {
tmp = t_1;
} else if (t_0 <= 1.0169092197592784e-21) {
tmp = (Math.cosh(x) * y) / (x * z);
} else {
tmp = t_1;
}
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 t_1 = (math.cosh(x) * (y / z)) / x tmp = 0 if t_0 <= -3.2215213879243386e+31: tmp = t_1 elif t_0 <= 1.0169092197592784e-21: tmp = (math.cosh(x) * y) / (x * z) else: tmp = t_1 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) t_1 = Float64(Float64(cosh(x) * Float64(y / z)) / x) tmp = 0.0 if (t_0 <= -3.2215213879243386e+31) tmp = t_1; elseif (t_0 <= 1.0169092197592784e-21) tmp = Float64(Float64(cosh(x) * y) / Float64(x * z)); else tmp = t_1; 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; t_1 = (cosh(x) * (y / z)) / x; tmp = 0.0; if (t_0 <= -3.2215213879243386e+31) tmp = t_1; elseif (t_0 <= 1.0169092197592784e-21) tmp = (cosh(x) * y) / (x * z); else tmp = t_1; 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]}, Block[{t$95$1 = N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$0, -3.2215213879243386e+31], t$95$1, If[LessEqual[t$95$0, 1.0169092197592784e-21], N[(N[(N[Cosh[x], $MachinePrecision] * y), $MachinePrecision] / N[(x * z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
t_0 := \frac{\cosh x \cdot \frac{y}{x}}{z}\\
t_1 := \frac{\cosh x \cdot \frac{y}{z}}{x}\\
\mathbf{if}\;t_0 \leq -3.2215213879243386 \cdot 10^{+31}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 1.0169092197592784 \cdot 10^{-21}:\\
\;\;\;\;\frac{\cosh x \cdot y}{x \cdot z}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 7.8 |
|---|---|
| Target | 0.5 |
| Herbie | 0.3 |
if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < -3.22152138792433865e31 or 1.01690921975927844e-21 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) Initial program 13.2
Applied egg-rr12.1
Taylor expanded in z around 0 11.9
Applied egg-rr0.4
if -3.22152138792433865e31 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 1.01690921975927844e-21Initial program 0.2
Applied egg-rr0.8
Taylor expanded in z around 0 0.4
Applied egg-rr0.3
Final simplification0.3
herbie shell --seed 2022133
(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))