(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
(+
(/ (/ y z) x)
(* (/ y z) (+ (* x 0.5) (* 0.041666666666666664 (pow x 3.0)))))))
(if (<= t_0 -1.675492548169809e-21)
t_1
(if (<= t_0 1.0788965712164023e-57) t_0 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 = ((y / z) / x) + ((y / z) * ((x * 0.5) + (0.041666666666666664 * pow(x, 3.0))));
double tmp;
if (t_0 <= -1.675492548169809e-21) {
tmp = t_1;
} else if (t_0 <= 1.0788965712164023e-57) {
tmp = t_0;
} 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 = ((y / z) / x) + ((y / z) * ((x * 0.5d0) + (0.041666666666666664d0 * (x ** 3.0d0))))
if (t_0 <= (-1.675492548169809d-21)) then
tmp = t_1
else if (t_0 <= 1.0788965712164023d-57) then
tmp = t_0
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 = ((y / z) / x) + ((y / z) * ((x * 0.5) + (0.041666666666666664 * Math.pow(x, 3.0))));
double tmp;
if (t_0 <= -1.675492548169809e-21) {
tmp = t_1;
} else if (t_0 <= 1.0788965712164023e-57) {
tmp = t_0;
} 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 = ((y / z) / x) + ((y / z) * ((x * 0.5) + (0.041666666666666664 * math.pow(x, 3.0)))) tmp = 0 if t_0 <= -1.675492548169809e-21: tmp = t_1 elif t_0 <= 1.0788965712164023e-57: tmp = t_0 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(Float64(y / z) / x) + Float64(Float64(y / z) * Float64(Float64(x * 0.5) + Float64(0.041666666666666664 * (x ^ 3.0))))) tmp = 0.0 if (t_0 <= -1.675492548169809e-21) tmp = t_1; elseif (t_0 <= 1.0788965712164023e-57) tmp = t_0; 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 = ((y / z) / x) + ((y / z) * ((x * 0.5) + (0.041666666666666664 * (x ^ 3.0)))); tmp = 0.0; if (t_0 <= -1.675492548169809e-21) tmp = t_1; elseif (t_0 <= 1.0788965712164023e-57) tmp = t_0; 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[(y / z), $MachinePrecision] / x), $MachinePrecision] + N[(N[(y / z), $MachinePrecision] * N[(N[(x * 0.5), $MachinePrecision] + N[(0.041666666666666664 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1.675492548169809e-21], t$95$1, If[LessEqual[t$95$0, 1.0788965712164023e-57], t$95$0, 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{\frac{y}{z}}{x} + \frac{y}{z} \cdot \left(x \cdot 0.5 + 0.041666666666666664 \cdot {x}^{3}\right)\\
\mathbf{if}\;t_0 \leq -1.675492548169809 \cdot 10^{-21}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 1.0788965712164023 \cdot 10^{-57}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 8.1 |
|---|---|
| Target | 0.5 |
| Herbie | 0.8 |
if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < -1.67549254816980894e-21 or 1.0788965712164023e-57 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) Initial program 12.2
Simplified0.8
Taylor expanded in x around 0 10.7
Simplified1.0
if -1.67549254816980894e-21 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 1.0788965712164023e-57Initial program 0.2
Final simplification0.8
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))