Average Error: 8.1 → 0.8
Time: 3.8s
Precision: binary64
\[\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} \]
(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}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original8.1
Target0.5
Herbie0.8
\[\begin{array}{l} \mathbf{if}\;y < -4.618902267687042 \cdot 10^{-52}:\\ \;\;\;\;\frac{\frac{y}{z}}{x} \cdot \cosh x\\ \mathbf{elif}\;y < 1.038530535935153 \cdot 10^{-39}:\\ \;\;\;\;\frac{\frac{\cosh x \cdot y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z}}{x} \cdot \cosh x\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. 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)

    1. Initial program 12.2

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Simplified0.8

      \[\leadsto \color{blue}{\frac{\cosh x}{x \cdot \frac{z}{y}}} \]
    3. Taylor expanded in x around 0 10.7

      \[\leadsto \color{blue}{0.5 \cdot \frac{y \cdot x}{z} + \left(\frac{y}{z \cdot x} + 0.041666666666666664 \cdot \frac{y \cdot {x}^{3}}{z}\right)} \]
    4. Simplified1.0

      \[\leadsto \color{blue}{\frac{\frac{y}{z}}{x} + \frac{y}{z} \cdot \left(x \cdot 0.5 + 0.041666666666666664 \cdot {x}^{3}\right)} \]

    if -1.67549254816980894e-21 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 1.0788965712164023e-57

    1. Initial program 0.2

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\cosh x \cdot \frac{y}{x}}{z} \leq -1.675492548169809 \cdot 10^{-21}:\\ \;\;\;\;\frac{\frac{y}{z}}{x} + \frac{y}{z} \cdot \left(x \cdot 0.5 + 0.041666666666666664 \cdot {x}^{3}\right)\\ \mathbf{elif}\;\frac{\cosh x \cdot \frac{y}{x}}{z} \leq 1.0788965712164023 \cdot 10^{-57}:\\ \;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z}}{x} + \frac{y}{z} \cdot \left(x \cdot 0.5 + 0.041666666666666664 \cdot {x}^{3}\right)\\ \end{array} \]

Reproduce

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))