Average Error: 7.7 → 0.4
Time: 4.0s
Precision: binary64
\[\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} \]
(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}

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

Original7.7
Target0.4
Herbie0.4
\[\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 3 regimes
  2. if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < -3.03197732379256014e304

    1. Initial program 61.6

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

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

      \[\leadsto \color{blue}{\frac{y}{z \cdot x}} \]

    if -3.03197732379256014e304 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 4.8949148190570921e146

    1. Initial program 0.2

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]

    if 4.8949148190570921e146 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z)

    1. Initial program 22.1

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

      \[\leadsto \color{blue}{\frac{\cosh x}{x \cdot \frac{z}{y}}} \]
    3. Applied egg-rr17.5

      \[\leadsto \color{blue}{\frac{\frac{\cosh x}{x}}{z} \cdot y} \]
    4. Applied egg-rr0.6

      \[\leadsto \color{blue}{\frac{\frac{\cosh x}{x}}{\frac{z}{y}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\cosh x \cdot \frac{y}{x}}{z} \leq -3.03197732379256 \cdot 10^{+304}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{elif}\;\frac{\cosh x \cdot \frac{y}{x}}{z} \leq 4.894914819057092 \cdot 10^{+146}:\\ \;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cosh x}{x}}{\frac{z}{y}}\\ \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))