Linear.Quaternion:$ctan from linear-1.19.1.3

Percentage Accurate: 84.3% → 99.6%
Time: 8.4s
Alternatives: 8
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \frac{\cosh x \cdot \frac{y}{x}}{z} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
double code(double x, double y, double z) {
	return (cosh(x) * (y / x)) / z;
}
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
public static double code(double x, double y, double z) {
	return (Math.cosh(x) * (y / x)) / z;
}
def code(x, y, z):
	return (math.cosh(x) * (y / x)) / z
function code(x, y, z)
	return Float64(Float64(cosh(x) * Float64(y / x)) / z)
end
function tmp = code(x, y, z)
	tmp = (cosh(x) * (y / x)) / z;
end
code[x_, y_, z_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}

\\
\frac{\cosh x \cdot \frac{y}{x}}{z}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 84.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\cosh x \cdot \frac{y}{x}}{z} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
double code(double x, double y, double z) {
	return (cosh(x) * (y / x)) / z;
}
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
public static double code(double x, double y, double z) {
	return (Math.cosh(x) * (y / x)) / z;
}
def code(x, y, z):
	return (math.cosh(x) * (y / x)) / z
function code(x, y, z)
	return Float64(Float64(cosh(x) * Float64(y / x)) / z)
end
function tmp = code(x, y, z)
	tmp = (cosh(x) * (y / x)) / z;
end
code[x_, y_, z_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}

\\
\frac{\cosh x \cdot \frac{y}{x}}{z}
\end{array}

Alternative 1: 99.6% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ y_s \cdot \begin{array}{l} \mathbf{if}\;y_m \leq 4 \cdot 10^{+43}:\\ \;\;\;\;\frac{y_m \cdot \frac{\cosh x}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cosh x}{\frac{z}{y_m}}}{x}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (*
  y_s
  (if (<= y_m 4e+43)
    (/ (* y_m (/ (cosh x) x)) z)
    (/ (/ (cosh x) (/ z y_m)) x))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (y_m <= 4e+43) {
		tmp = (y_m * (cosh(x) / x)) / z;
	} else {
		tmp = (cosh(x) / (z / y_m)) / x;
	}
	return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y_m <= 4d+43) then
        tmp = (y_m * (cosh(x) / x)) / z
    else
        tmp = (cosh(x) / (z / y_m)) / x
    end if
    code = y_s * tmp
end function
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (y_m <= 4e+43) {
		tmp = (y_m * (Math.cosh(x) / x)) / z;
	} else {
		tmp = (Math.cosh(x) / (z / y_m)) / x;
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if y_m <= 4e+43:
		tmp = (y_m * (math.cosh(x) / x)) / z
	else:
		tmp = (math.cosh(x) / (z / y_m)) / x
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (y_m <= 4e+43)
		tmp = Float64(Float64(y_m * Float64(cosh(x) / x)) / z);
	else
		tmp = Float64(Float64(cosh(x) / Float64(z / y_m)) / x);
	end
	return Float64(y_s * tmp)
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (y_m <= 4e+43)
		tmp = (y_m * (cosh(x) / x)) / z;
	else
		tmp = (cosh(x) / (z / y_m)) / x;
	end
	tmp_2 = y_s * tmp;
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 4e+43], N[(N[(y$95$m * N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[Cosh[x], $MachinePrecision] / N[(z / y$95$m), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;y_m \leq 4 \cdot 10^{+43}:\\
\;\;\;\;\frac{y_m \cdot \frac{\cosh x}{x}}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cosh x}{\frac{z}{y_m}}}{x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 4.00000000000000006e43

    1. Initial program 84.1%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. expm1-log1p-u52.8%

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cosh x \cdot \frac{y}{x}\right)\right)}}{z} \]
      2. expm1-udef43.4%

        \[\leadsto \frac{\color{blue}{e^{\mathsf{log1p}\left(\cosh x \cdot \frac{y}{x}\right)} - 1}}{z} \]
    4. Applied egg-rr43.4%

      \[\leadsto \frac{\color{blue}{e^{\mathsf{log1p}\left(\cosh x \cdot \frac{y}{x}\right)} - 1}}{z} \]
    5. Step-by-step derivation
      1. expm1-def52.8%

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cosh x \cdot \frac{y}{x}\right)\right)}}{z} \]
      2. expm1-log1p84.1%

        \[\leadsto \frac{\color{blue}{\cosh x \cdot \frac{y}{x}}}{z} \]
      3. associate-*r/97.6%

        \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{x}}}{z} \]
      4. associate-*l/97.6%

        \[\leadsto \frac{\color{blue}{\frac{\cosh x}{x} \cdot y}}{z} \]
      5. *-commutative97.6%

        \[\leadsto \frac{\color{blue}{y \cdot \frac{\cosh x}{x}}}{z} \]
    6. Simplified97.6%

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

    if 4.00000000000000006e43 < y

    1. Initial program 90.3%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. associate-*l/90.2%

        \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
    3. Simplified90.2%

      \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate-/r/88.2%

        \[\leadsto \color{blue}{\frac{\cosh x}{\frac{z}{\frac{y}{x}}}} \]
      2. associate-/r/97.8%

        \[\leadsto \frac{\cosh x}{\color{blue}{\frac{z}{y} \cdot x}} \]
      3. associate-/r*99.8%

        \[\leadsto \color{blue}{\frac{\frac{\cosh x}{\frac{z}{y}}}{x}} \]
    6. Applied egg-rr99.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 4 \cdot 10^{+43}:\\ \;\;\;\;\frac{y \cdot \frac{\cosh x}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cosh x}{\frac{z}{y}}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 67.0% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ y_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 2 \cdot 10^{-21}:\\ \;\;\;\;\frac{y_m}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cosh x}{z} \cdot \frac{y_m}{x}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (* y_s (if (<= x 2e-21) (/ y_m (* x z)) (* (/ (cosh x) z) (/ y_m x)))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 2e-21) {
		tmp = y_m / (x * z);
	} else {
		tmp = (cosh(x) / z) * (y_m / x);
	}
	return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 2d-21) then
        tmp = y_m / (x * z)
    else
        tmp = (cosh(x) / z) * (y_m / x)
    end if
    code = y_s * tmp
end function
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 2e-21) {
		tmp = y_m / (x * z);
	} else {
		tmp = (Math.cosh(x) / z) * (y_m / x);
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if x <= 2e-21:
		tmp = y_m / (x * z)
	else:
		tmp = (math.cosh(x) / z) * (y_m / x)
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (x <= 2e-21)
		tmp = Float64(y_m / Float64(x * z));
	else
		tmp = Float64(Float64(cosh(x) / z) * Float64(y_m / x));
	end
	return Float64(y_s * tmp)
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (x <= 2e-21)
		tmp = y_m / (x * z);
	else
		tmp = (cosh(x) / z) * (y_m / x);
	end
	tmp_2 = y_s * tmp;
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 2e-21], N[(y$95$m / N[(x * z), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cosh[x], $MachinePrecision] / z), $MachinePrecision] * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{-21}:\\
\;\;\;\;\frac{y_m}{x \cdot z}\\

\mathbf{else}:\\
\;\;\;\;\frac{\cosh x}{z} \cdot \frac{y_m}{x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.99999999999999982e-21

    1. Initial program 87.1%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. associate-*l/87.0%

        \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
    3. Simplified87.0%

      \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 66.4%

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

    if 1.99999999999999982e-21 < x

    1. Initial program 78.9%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. associate-*l/78.9%

        \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
    3. Simplified78.9%

      \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
    4. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification69.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2 \cdot 10^{-21}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cosh x}{z} \cdot \frac{y}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 80.7% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ y_s \cdot \begin{array}{l} \mathbf{if}\;z \leq 2.2 \cdot 10^{-88}:\\ \;\;\;\;\frac{\cosh x}{\frac{x \cdot z}{y_m}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cosh x}{z} \cdot \frac{y_m}{x}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (*
  y_s
  (if (<= z 2.2e-88)
    (/ (cosh x) (/ (* x z) y_m))
    (* (/ (cosh x) z) (/ y_m x)))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (z <= 2.2e-88) {
		tmp = cosh(x) / ((x * z) / y_m);
	} else {
		tmp = (cosh(x) / z) * (y_m / x);
	}
	return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= 2.2d-88) then
        tmp = cosh(x) / ((x * z) / y_m)
    else
        tmp = (cosh(x) / z) * (y_m / x)
    end if
    code = y_s * tmp
end function
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (z <= 2.2e-88) {
		tmp = Math.cosh(x) / ((x * z) / y_m);
	} else {
		tmp = (Math.cosh(x) / z) * (y_m / x);
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if z <= 2.2e-88:
		tmp = math.cosh(x) / ((x * z) / y_m)
	else:
		tmp = (math.cosh(x) / z) * (y_m / x)
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (z <= 2.2e-88)
		tmp = Float64(cosh(x) / Float64(Float64(x * z) / y_m));
	else
		tmp = Float64(Float64(cosh(x) / z) * Float64(y_m / x));
	end
	return Float64(y_s * tmp)
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (z <= 2.2e-88)
		tmp = cosh(x) / ((x * z) / y_m);
	else
		tmp = (cosh(x) / z) * (y_m / x);
	end
	tmp_2 = y_s * tmp;
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[z, 2.2e-88], N[(N[Cosh[x], $MachinePrecision] / N[(N[(x * z), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cosh[x], $MachinePrecision] / z), $MachinePrecision] * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 2.2 \cdot 10^{-88}:\\
\;\;\;\;\frac{\cosh x}{\frac{x \cdot z}{y_m}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\cosh x}{z} \cdot \frac{y_m}{x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 2.20000000000000005e-88

    1. Initial program 84.3%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. associate-/l*78.1%

        \[\leadsto \color{blue}{\frac{\cosh x}{\frac{z}{\frac{y}{x}}}} \]
    3. Simplified78.1%

      \[\leadsto \color{blue}{\frac{\cosh x}{\frac{z}{\frac{y}{x}}}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 82.8%

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

    if 2.20000000000000005e-88 < z

    1. Initial program 87.0%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. associate-*l/86.8%

        \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
    3. Simplified86.8%

      \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
    4. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification84.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 2.2 \cdot 10^{-88}:\\ \;\;\;\;\frac{\cosh x}{\frac{x \cdot z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cosh x}{z} \cdot \frac{y}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 73.0% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ y_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 10^{-26}:\\ \;\;\;\;\frac{y_m}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y_m \cdot \frac{\cosh x}{x}}{z}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (* y_s (if (<= x 1e-26) (/ y_m (* x z)) (/ (* y_m (/ (cosh x) x)) z))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 1e-26) {
		tmp = y_m / (x * z);
	} else {
		tmp = (y_m * (cosh(x) / x)) / z;
	}
	return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 1d-26) then
        tmp = y_m / (x * z)
    else
        tmp = (y_m * (cosh(x) / x)) / z
    end if
    code = y_s * tmp
end function
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 1e-26) {
		tmp = y_m / (x * z);
	} else {
		tmp = (y_m * (Math.cosh(x) / x)) / z;
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if x <= 1e-26:
		tmp = y_m / (x * z)
	else:
		tmp = (y_m * (math.cosh(x) / x)) / z
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (x <= 1e-26)
		tmp = Float64(y_m / Float64(x * z));
	else
		tmp = Float64(Float64(y_m * Float64(cosh(x) / x)) / z);
	end
	return Float64(y_s * tmp)
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (x <= 1e-26)
		tmp = y_m / (x * z);
	else
		tmp = (y_m * (cosh(x) / x)) / z;
	end
	tmp_2 = y_s * tmp;
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 1e-26], N[(y$95$m / N[(x * z), $MachinePrecision]), $MachinePrecision], N[(N[(y$95$m * N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 10^{-26}:\\
\;\;\;\;\frac{y_m}{x \cdot z}\\

\mathbf{else}:\\
\;\;\;\;\frac{y_m \cdot \frac{\cosh x}{x}}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1e-26

    1. Initial program 87.0%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. associate-*l/86.9%

        \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
    3. Simplified86.9%

      \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 66.0%

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

    if 1e-26 < x

    1. Initial program 79.6%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. expm1-log1p-u45.8%

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cosh x \cdot \frac{y}{x}\right)\right)}}{z} \]
      2. expm1-udef41.2%

        \[\leadsto \frac{\color{blue}{e^{\mathsf{log1p}\left(\cosh x \cdot \frac{y}{x}\right)} - 1}}{z} \]
    4. Applied egg-rr41.2%

      \[\leadsto \frac{\color{blue}{e^{\mathsf{log1p}\left(\cosh x \cdot \frac{y}{x}\right)} - 1}}{z} \]
    5. Step-by-step derivation
      1. expm1-def45.8%

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cosh x \cdot \frac{y}{x}\right)\right)}}{z} \]
      2. expm1-log1p79.6%

        \[\leadsto \frac{\color{blue}{\cosh x \cdot \frac{y}{x}}}{z} \]
      3. associate-*r/99.9%

        \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{x}}}{z} \]
      4. associate-*l/100.0%

        \[\leadsto \frac{\color{blue}{\frac{\cosh x}{x} \cdot y}}{z} \]
      5. *-commutative100.0%

        \[\leadsto \frac{\color{blue}{y \cdot \frac{\cosh x}{x}}}{z} \]
    6. Simplified100.0%

      \[\leadsto \frac{\color{blue}{y \cdot \frac{\cosh x}{x}}}{z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification73.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 10^{-26}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \frac{\cosh x}{x}}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 58.0% accurate, 6.7× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ y_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 1.4:\\ \;\;\;\;\frac{y_m}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{y_m \cdot \left(\frac{x}{z} \cdot 0.5\right)}}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (*
  y_s
  (if (<= x 1.4) (/ y_m (* x z)) (/ 1.0 (/ 1.0 (* y_m (* (/ x z) 0.5)))))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 1.4) {
		tmp = y_m / (x * z);
	} else {
		tmp = 1.0 / (1.0 / (y_m * ((x / z) * 0.5)));
	}
	return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 1.4d0) then
        tmp = y_m / (x * z)
    else
        tmp = 1.0d0 / (1.0d0 / (y_m * ((x / z) * 0.5d0)))
    end if
    code = y_s * tmp
end function
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 1.4) {
		tmp = y_m / (x * z);
	} else {
		tmp = 1.0 / (1.0 / (y_m * ((x / z) * 0.5)));
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if x <= 1.4:
		tmp = y_m / (x * z)
	else:
		tmp = 1.0 / (1.0 / (y_m * ((x / z) * 0.5)))
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (x <= 1.4)
		tmp = Float64(y_m / Float64(x * z));
	else
		tmp = Float64(1.0 / Float64(1.0 / Float64(y_m * Float64(Float64(x / z) * 0.5))));
	end
	return Float64(y_s * tmp)
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (x <= 1.4)
		tmp = y_m / (x * z);
	else
		tmp = 1.0 / (1.0 / (y_m * ((x / z) * 0.5)));
	end
	tmp_2 = y_s * tmp;
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 1.4], N[(y$95$m / N[(x * z), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 / N[(y$95$m * N[(N[(x / z), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 1.4:\\
\;\;\;\;\frac{y_m}{x \cdot z}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{y_m \cdot \left(\frac{x}{z} \cdot 0.5\right)}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.3999999999999999

    1. Initial program 87.2%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. associate-*l/87.1%

        \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
    3. Simplified87.1%

      \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 66.6%

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

    if 1.3999999999999999 < x

    1. Initial program 78.2%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 37.2%

      \[\leadsto \frac{\color{blue}{0.5 \cdot \left(x \cdot y\right) + \frac{y}{x}}}{z} \]
    4. Taylor expanded in x around inf 37.2%

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{z}} \]
    5. Step-by-step derivation
      1. associate-*r/37.2%

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left(x \cdot y\right)}{z}} \]
      2. associate-*r*37.2%

        \[\leadsto \frac{\color{blue}{\left(0.5 \cdot x\right) \cdot y}}{z} \]
      3. *-commutative37.2%

        \[\leadsto \frac{\color{blue}{\left(x \cdot 0.5\right)} \cdot y}{z} \]
      4. *-commutative37.2%

        \[\leadsto \frac{\color{blue}{y \cdot \left(x \cdot 0.5\right)}}{z} \]
      5. associate-/l*37.3%

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x \cdot 0.5}}} \]
      6. *-commutative37.3%

        \[\leadsto \frac{y}{\frac{z}{\color{blue}{0.5 \cdot x}}} \]
    6. Simplified37.3%

      \[\leadsto \color{blue}{\frac{y}{\frac{z}{0.5 \cdot x}}} \]
    7. Step-by-step derivation
      1. associate-/r*37.3%

        \[\leadsto \frac{y}{\color{blue}{\frac{\frac{z}{0.5}}{x}}} \]
      2. associate-/r/33.8%

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{0.5}} \cdot x} \]
      3. div-inv33.8%

        \[\leadsto \frac{y}{\color{blue}{z \cdot \frac{1}{0.5}}} \cdot x \]
      4. metadata-eval33.8%

        \[\leadsto \frac{y}{z \cdot \color{blue}{2}} \cdot x \]
    8. Applied egg-rr33.8%

      \[\leadsto \color{blue}{\frac{y}{z \cdot 2} \cdot x} \]
    9. Step-by-step derivation
      1. associate-/r*33.8%

        \[\leadsto \color{blue}{\frac{\frac{y}{z}}{2}} \cdot x \]
      2. associate-/r/33.8%

        \[\leadsto \color{blue}{\frac{\frac{y}{z}}{\frac{2}{x}}} \]
      3. *-un-lft-identity33.8%

        \[\leadsto \frac{\frac{\color{blue}{1 \cdot y}}{z}}{\frac{2}{x}} \]
      4. associate-*l/33.8%

        \[\leadsto \frac{\color{blue}{\frac{1}{z} \cdot y}}{\frac{2}{x}} \]
      5. associate-*r/37.2%

        \[\leadsto \color{blue}{\frac{1}{z} \cdot \frac{y}{\frac{2}{x}}} \]
      6. /-rgt-identity37.2%

        \[\leadsto \color{blue}{\frac{\frac{1}{z} \cdot \frac{y}{\frac{2}{x}}}{1}} \]
      7. clear-num37.2%

        \[\leadsto \color{blue}{\frac{1}{\frac{1}{\frac{1}{z} \cdot \frac{y}{\frac{2}{x}}}}} \]
      8. associate-*l/37.2%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{1 \cdot \frac{y}{\frac{2}{x}}}{z}}}} \]
      9. *-un-lft-identity37.2%

        \[\leadsto \frac{1}{\frac{1}{\frac{\color{blue}{\frac{y}{\frac{2}{x}}}}{z}}} \]
      10. associate-/r/37.2%

        \[\leadsto \frac{1}{\frac{1}{\frac{\color{blue}{\frac{y}{2} \cdot x}}{z}}} \]
      11. div-inv37.2%

        \[\leadsto \frac{1}{\frac{1}{\frac{\color{blue}{\left(y \cdot \frac{1}{2}\right)} \cdot x}{z}}} \]
      12. metadata-eval37.2%

        \[\leadsto \frac{1}{\frac{1}{\frac{\left(y \cdot \color{blue}{0.5}\right) \cdot x}{z}}} \]
      13. associate-*r/39.0%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(y \cdot 0.5\right) \cdot \frac{x}{z}}}} \]
      14. *-commutative39.0%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{x}{z} \cdot \left(y \cdot 0.5\right)}}} \]
      15. *-commutative39.0%

        \[\leadsto \frac{1}{\frac{1}{\frac{x}{z} \cdot \color{blue}{\left(0.5 \cdot y\right)}}} \]
      16. associate-*r*39.0%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\frac{x}{z} \cdot 0.5\right) \cdot y}}} \]
    10. Applied egg-rr39.0%

      \[\leadsto \color{blue}{\frac{1}{\frac{1}{\left(\frac{x}{z} \cdot 0.5\right) \cdot y}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification60.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.4:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{y \cdot \left(\frac{x}{z} \cdot 0.5\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 58.0% accurate, 8.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ y_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 1.4:\\ \;\;\;\;\frac{y_m}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;y_m \cdot \left(x \cdot \frac{0.5}{z}\right)\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (* y_s (if (<= x 1.4) (/ y_m (* x z)) (* y_m (* x (/ 0.5 z))))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 1.4) {
		tmp = y_m / (x * z);
	} else {
		tmp = y_m * (x * (0.5 / z));
	}
	return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 1.4d0) then
        tmp = y_m / (x * z)
    else
        tmp = y_m * (x * (0.5d0 / z))
    end if
    code = y_s * tmp
end function
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 1.4) {
		tmp = y_m / (x * z);
	} else {
		tmp = y_m * (x * (0.5 / z));
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if x <= 1.4:
		tmp = y_m / (x * z)
	else:
		tmp = y_m * (x * (0.5 / z))
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (x <= 1.4)
		tmp = Float64(y_m / Float64(x * z));
	else
		tmp = Float64(y_m * Float64(x * Float64(0.5 / z)));
	end
	return Float64(y_s * tmp)
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (x <= 1.4)
		tmp = y_m / (x * z);
	else
		tmp = y_m * (x * (0.5 / z));
	end
	tmp_2 = y_s * tmp;
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 1.4], N[(y$95$m / N[(x * z), $MachinePrecision]), $MachinePrecision], N[(y$95$m * N[(x * N[(0.5 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 1.4:\\
\;\;\;\;\frac{y_m}{x \cdot z}\\

\mathbf{else}:\\
\;\;\;\;y_m \cdot \left(x \cdot \frac{0.5}{z}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.3999999999999999

    1. Initial program 87.2%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. associate-*l/87.1%

        \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
    3. Simplified87.1%

      \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 66.6%

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

    if 1.3999999999999999 < x

    1. Initial program 78.2%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 37.2%

      \[\leadsto \frac{\color{blue}{0.5 \cdot \left(x \cdot y\right) + \frac{y}{x}}}{z} \]
    4. Taylor expanded in x around inf 37.2%

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{z}} \]
    5. Step-by-step derivation
      1. associate-*r/37.2%

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left(x \cdot y\right)}{z}} \]
      2. associate-*r*37.2%

        \[\leadsto \frac{\color{blue}{\left(0.5 \cdot x\right) \cdot y}}{z} \]
      3. *-commutative37.2%

        \[\leadsto \frac{\color{blue}{\left(x \cdot 0.5\right)} \cdot y}{z} \]
      4. *-commutative37.2%

        \[\leadsto \frac{\color{blue}{y \cdot \left(x \cdot 0.5\right)}}{z} \]
      5. associate-/l*37.3%

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x \cdot 0.5}}} \]
      6. *-commutative37.3%

        \[\leadsto \frac{y}{\frac{z}{\color{blue}{0.5 \cdot x}}} \]
    6. Simplified37.3%

      \[\leadsto \color{blue}{\frac{y}{\frac{z}{0.5 \cdot x}}} \]
    7. Step-by-step derivation
      1. clear-num37.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{z}{0.5 \cdot x}}{y}}} \]
      2. associate-/r/39.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{z}{0.5 \cdot x}} \cdot y} \]
      3. clear-num39.0%

        \[\leadsto \color{blue}{\frac{0.5 \cdot x}{z}} \cdot y \]
      4. *-commutative39.0%

        \[\leadsto \frac{\color{blue}{x \cdot 0.5}}{z} \cdot y \]
      5. *-un-lft-identity39.0%

        \[\leadsto \frac{x \cdot 0.5}{\color{blue}{1 \cdot z}} \cdot y \]
      6. times-frac39.0%

        \[\leadsto \color{blue}{\left(\frac{x}{1} \cdot \frac{0.5}{z}\right)} \cdot y \]
      7. /-rgt-identity39.0%

        \[\leadsto \left(\color{blue}{x} \cdot \frac{0.5}{z}\right) \cdot y \]
    8. Applied egg-rr39.0%

      \[\leadsto \color{blue}{\left(x \cdot \frac{0.5}{z}\right) \cdot y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification60.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.4:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot \frac{0.5}{z}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 57.1% accurate, 10.7× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ y_s \cdot \begin{array}{l} \mathbf{if}\;y_m \leq 7.5 \cdot 10^{+21}:\\ \;\;\;\;\frac{\frac{y_m}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y_m}{z}}{x}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (* y_s (if (<= y_m 7.5e+21) (/ (/ y_m x) z) (/ (/ y_m z) x))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (y_m <= 7.5e+21) {
		tmp = (y_m / x) / z;
	} else {
		tmp = (y_m / z) / x;
	}
	return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y_m <= 7.5d+21) then
        tmp = (y_m / x) / z
    else
        tmp = (y_m / z) / x
    end if
    code = y_s * tmp
end function
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (y_m <= 7.5e+21) {
		tmp = (y_m / x) / z;
	} else {
		tmp = (y_m / z) / x;
	}
	return y_s * tmp;
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if y_m <= 7.5e+21:
		tmp = (y_m / x) / z
	else:
		tmp = (y_m / z) / x
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (y_m <= 7.5e+21)
		tmp = Float64(Float64(y_m / x) / z);
	else
		tmp = Float64(Float64(y_m / z) / x);
	end
	return Float64(y_s * tmp)
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (y_m <= 7.5e+21)
		tmp = (y_m / x) / z;
	else
		tmp = (y_m / z) / x;
	end
	tmp_2 = y_s * tmp;
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 7.5e+21], N[(N[(y$95$m / x), $MachinePrecision] / z), $MachinePrecision], N[(N[(y$95$m / z), $MachinePrecision] / x), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;y_m \leq 7.5 \cdot 10^{+21}:\\
\;\;\;\;\frac{\frac{y_m}{x}}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{y_m}{z}}{x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 7.5e21

    1. Initial program 83.9%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 52.5%

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

    if 7.5e21 < y

    1. Initial program 90.8%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. associate-*l/90.8%

        \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
    3. Simplified90.8%

      \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 44.6%

      \[\leadsto \color{blue}{\frac{1}{z}} \cdot \frac{y}{x} \]
    6. Step-by-step derivation
      1. associate-*r/64.4%

        \[\leadsto \color{blue}{\frac{\frac{1}{z} \cdot y}{x}} \]
      2. associate-*l/64.5%

        \[\leadsto \frac{\color{blue}{\frac{1 \cdot y}{z}}}{x} \]
      3. *-un-lft-identity64.5%

        \[\leadsto \frac{\frac{\color{blue}{y}}{z}}{x} \]
    7. Applied egg-rr64.5%

      \[\leadsto \color{blue}{\frac{\frac{y}{z}}{x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification54.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 7.5 \cdot 10^{+21}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 49.4% accurate, 21.4× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ y_s \cdot \frac{y_m}{x \cdot z} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z) :precision binary64 (* y_s (/ y_m (* x z))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	return y_s * (y_m / (x * z));
}
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    code = y_s * (y_m / (x * z))
end function
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	return y_s * (y_m / (x * z));
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	return y_s * (y_m / (x * z))
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	return Float64(y_s * Float64(y_m / Float64(x * z)))
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp = code(y_s, x, y_m, z)
	tmp = y_s * (y_m / (x * z));
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[(y$95$m / N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
y_s \cdot \frac{y_m}{x \cdot z}
\end{array}
Derivation
  1. Initial program 85.3%

    \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
  2. Step-by-step derivation
    1. associate-*l/85.2%

      \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
  3. Simplified85.2%

    \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 53.3%

    \[\leadsto \color{blue}{\frac{y}{x \cdot z}} \]
  6. Final simplification53.3%

    \[\leadsto \frac{y}{x \cdot z} \]
  7. Add Preprocessing

Developer target: 97.3% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{y}{z}}{x} \cdot \cosh x\\ \mathbf{if}\;y < -4.618902267687042 \cdot 10^{-52}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y < 1.038530535935153 \cdot 10^{-39}:\\ \;\;\;\;\frac{\frac{\cosh x \cdot y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (/ (/ y z) x) (cosh x))))
   (if (< y -4.618902267687042e-52)
     t_0
     (if (< y 1.038530535935153e-39) (/ (/ (* (cosh x) y) x) z) t_0))))
double code(double x, double y, double z) {
	double t_0 = ((y / z) / x) * cosh(x);
	double tmp;
	if (y < -4.618902267687042e-52) {
		tmp = t_0;
	} else if (y < 1.038530535935153e-39) {
		tmp = ((cosh(x) * y) / x) / z;
	} else {
		tmp = t_0;
	}
	return tmp;
}
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 = ((y / z) / x) * cosh(x)
    if (y < (-4.618902267687042d-52)) then
        tmp = t_0
    else if (y < 1.038530535935153d-39) then
        tmp = ((cosh(x) * y) / x) / z
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = ((y / z) / x) * Math.cosh(x);
	double tmp;
	if (y < -4.618902267687042e-52) {
		tmp = t_0;
	} else if (y < 1.038530535935153e-39) {
		tmp = ((Math.cosh(x) * y) / x) / z;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = ((y / z) / x) * math.cosh(x)
	tmp = 0
	if y < -4.618902267687042e-52:
		tmp = t_0
	elif y < 1.038530535935153e-39:
		tmp = ((math.cosh(x) * y) / x) / z
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(Float64(y / z) / x) * cosh(x))
	tmp = 0.0
	if (y < -4.618902267687042e-52)
		tmp = t_0;
	elseif (y < 1.038530535935153e-39)
		tmp = Float64(Float64(Float64(cosh(x) * y) / x) / z);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = ((y / z) / x) * cosh(x);
	tmp = 0.0;
	if (y < -4.618902267687042e-52)
		tmp = t_0;
	elseif (y < 1.038530535935153e-39)
		tmp = ((cosh(x) * y) / x) / z;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision] * N[Cosh[x], $MachinePrecision]), $MachinePrecision]}, If[Less[y, -4.618902267687042e-52], t$95$0, If[Less[y, 1.038530535935153e-39], N[(N[(N[(N[Cosh[x], $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\frac{y}{z}}{x} \cdot \cosh x\\
\mathbf{if}\;y < -4.618902267687042 \cdot 10^{-52}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y < 1.038530535935153 \cdot 10^{-39}:\\
\;\;\;\;\frac{\frac{\cosh x \cdot y}{x}}{z}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024019 
(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))