Linear.Quaternion:$ctan from linear-1.19.1.3

Percentage Accurate: 84.8% → 99.5%
Time: 9.1s
Alternatives: 12
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 12 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.8% 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.5% 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.4 \cdot 10^{-45}:\\ \;\;\;\;\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 4.4e-45)
    (/ (* 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 <= 4.4e-45) {
		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 <= 4.4d-45) 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 <= 4.4e-45) {
		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 <= 4.4e-45:
		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 <= 4.4e-45)
		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 <= 4.4e-45)
		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, 4.4e-45], 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.4 \cdot 10^{-45}:\\
\;\;\;\;\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.39999999999999987e-45

    1. Initial program 78.8%

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

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

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

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

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

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

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

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

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

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

    if 4.39999999999999987e-45 < y

    1. Initial program 94.4%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 4.4 \cdot 10^{-45}:\\ \;\;\;\;\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: 69.1% 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.45 \cdot 10^{-213}:\\ \;\;\;\;\frac{\frac{y_m}{z}}{x}\\ \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 2.45e-213) (/ (/ y_m z) x) (* (/ (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 <= 2.45e-213) {
		tmp = (y_m / z) / x;
	} 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 <= 2.45d-213) then
        tmp = (y_m / z) / x
    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 <= 2.45e-213) {
		tmp = (y_m / z) / x;
	} 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 <= 2.45e-213:
		tmp = (y_m / z) / x
	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 <= 2.45e-213)
		tmp = Float64(Float64(y_m / z) / x);
	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 <= 2.45e-213)
		tmp = (y_m / z) / x;
	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, 2.45e-213], N[(N[(y$95$m / z), $MachinePrecision] / x), $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.45 \cdot 10^{-213}:\\
\;\;\;\;\frac{\frac{y_m}{z}}{x}\\

\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 < 2.4499999999999999e-213

    1. Initial program 79.5%

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

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

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

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

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

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

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

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

    if 2.4499999999999999e-213 < x

    1. Initial program 88.2%

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

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

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

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

Alternative 3: 84.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 8.2 \cdot 10^{+34}:\\ \;\;\;\;\frac{\cosh x}{x \cdot \frac{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 8.2e+34)
    (/ (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 <= 8.2e+34) {
		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 <= 8.2d+34) 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 <= 8.2e+34) {
		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 <= 8.2e+34:
		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 <= 8.2e+34)
		tmp = Float64(cosh(x) / Float64(x * Float64(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 <= 8.2e+34)
		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, 8.2e+34], N[(N[Cosh[x], $MachinePrecision] / N[(x * N[(z / y$95$m), $MachinePrecision]), $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 8.2 \cdot 10^{+34}:\\
\;\;\;\;\frac{\cosh x}{x \cdot \frac{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 < 8.1999999999999997e34

    1. Initial program 83.4%

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

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

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

        \[\leadsto \frac{\cosh x}{\color{blue}{\frac{z}{y} \cdot x}} \]
    6. Applied egg-rr84.9%

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

    if 8.1999999999999997e34 < z

    1. Initial program 81.2%

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

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

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

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

Alternative 4: 98.4% 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 9.5 \cdot 10^{+91}:\\ \;\;\;\;\frac{y_m \cdot \frac{\cosh x}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cosh x}{x \cdot \frac{z}{y_m}}\\ \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 9.5e+91)
    (/ (* y_m (/ (cosh x) x)) z)
    (/ (cosh x) (* x (/ z y_m))))))
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 <= 9.5e+91) {
		tmp = (y_m * (cosh(x) / x)) / z;
	} else {
		tmp = cosh(x) / (x * (z / y_m));
	}
	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 <= 9.5d+91) then
        tmp = (y_m * (cosh(x) / x)) / z
    else
        tmp = cosh(x) / (x * (z / y_m))
    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 <= 9.5e+91) {
		tmp = (y_m * (Math.cosh(x) / x)) / z;
	} else {
		tmp = Math.cosh(x) / (x * (z / y_m));
	}
	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 <= 9.5e+91:
		tmp = (y_m * (math.cosh(x) / x)) / z
	else:
		tmp = math.cosh(x) / (x * (z / y_m))
	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 <= 9.5e+91)
		tmp = Float64(Float64(y_m * Float64(cosh(x) / x)) / z);
	else
		tmp = Float64(cosh(x) / Float64(x * Float64(z / y_m)));
	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 <= 9.5e+91)
		tmp = (y_m * (cosh(x) / x)) / z;
	else
		tmp = cosh(x) / (x * (z / y_m));
	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, 9.5e+91], N[(N[(y$95$m * N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[Cosh[x], $MachinePrecision] / N[(x * N[(z / y$95$m), $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}\;y_m \leq 9.5 \cdot 10^{+91}:\\
\;\;\;\;\frac{y_m \cdot \frac{\cosh x}{x}}{z}\\

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


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

    1. Initial program 81.4%

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

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

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

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

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

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

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

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

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

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

    if 9.5000000000000001e91 < y

    1. Initial program 91.1%

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

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

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

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

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

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

Alternative 5: 59.1% accurate, 4.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \frac{\frac{y_m}{z}}{x}\\ y_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 7 \cdot 10^{-213}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{-126}:\\ \;\;\;\;\frac{\frac{y_m}{x}}{z}\\ \mathbf{elif}\;x \leq 0.0005:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{+147}:\\ \;\;\;\;y_m \cdot \left(0.5 \cdot \frac{x}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y_m \cdot x\right) \cdot \frac{0.5}{z}\\ \end{array} \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (let* ((t_0 (/ (/ y_m z) x)))
   (*
    y_s
    (if (<= x 7e-213)
      t_0
      (if (<= x 1.02e-126)
        (/ (/ y_m x) z)
        (if (<= x 0.0005)
          t_0
          (if (<= x 1.45e+147)
            (* y_m (* 0.5 (/ 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 t_0 = (y_m / z) / x;
	double tmp;
	if (x <= 7e-213) {
		tmp = t_0;
	} else if (x <= 1.02e-126) {
		tmp = (y_m / x) / z;
	} else if (x <= 0.0005) {
		tmp = t_0;
	} else if (x <= 1.45e+147) {
		tmp = y_m * (0.5 * (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) :: t_0
    real(8) :: tmp
    t_0 = (y_m / z) / x
    if (x <= 7d-213) then
        tmp = t_0
    else if (x <= 1.02d-126) then
        tmp = (y_m / x) / z
    else if (x <= 0.0005d0) then
        tmp = t_0
    else if (x <= 1.45d+147) then
        tmp = y_m * (0.5d0 * (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 t_0 = (y_m / z) / x;
	double tmp;
	if (x <= 7e-213) {
		tmp = t_0;
	} else if (x <= 1.02e-126) {
		tmp = (y_m / x) / z;
	} else if (x <= 0.0005) {
		tmp = t_0;
	} else if (x <= 1.45e+147) {
		tmp = y_m * (0.5 * (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):
	t_0 = (y_m / z) / x
	tmp = 0
	if x <= 7e-213:
		tmp = t_0
	elif x <= 1.02e-126:
		tmp = (y_m / x) / z
	elif x <= 0.0005:
		tmp = t_0
	elif x <= 1.45e+147:
		tmp = y_m * (0.5 * (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)
	t_0 = Float64(Float64(y_m / z) / x)
	tmp = 0.0
	if (x <= 7e-213)
		tmp = t_0;
	elseif (x <= 1.02e-126)
		tmp = Float64(Float64(y_m / x) / z);
	elseif (x <= 0.0005)
		tmp = t_0;
	elseif (x <= 1.45e+147)
		tmp = Float64(y_m * Float64(0.5 * Float64(x / z)));
	else
		tmp = Float64(Float64(y_m * 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)
	t_0 = (y_m / z) / x;
	tmp = 0.0;
	if (x <= 7e-213)
		tmp = t_0;
	elseif (x <= 1.02e-126)
		tmp = (y_m / x) / z;
	elseif (x <= 0.0005)
		tmp = t_0;
	elseif (x <= 1.45e+147)
		tmp = y_m * (0.5 * (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_] := Block[{t$95$0 = N[(N[(y$95$m / z), $MachinePrecision] / x), $MachinePrecision]}, N[(y$95$s * If[LessEqual[x, 7e-213], t$95$0, If[LessEqual[x, 1.02e-126], N[(N[(y$95$m / x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[x, 0.0005], t$95$0, If[LessEqual[x, 1.45e+147], N[(y$95$m * N[(0.5 * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y$95$m * x), $MachinePrecision] * N[(0.5 / z), $MachinePrecision]), $MachinePrecision]]]]]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

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

\mathbf{elif}\;x \leq 1.02 \cdot 10^{-126}:\\
\;\;\;\;\frac{\frac{y_m}{x}}{z}\\

\mathbf{elif}\;x \leq 0.0005:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1.45 \cdot 10^{+147}:\\
\;\;\;\;y_m \cdot \left(0.5 \cdot \frac{x}{z}\right)\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 7.00000000000000034e-213 or 1.02000000000000004e-126 < x < 5.0000000000000001e-4

    1. Initial program 80.9%

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

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

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

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

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

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

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

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

    if 7.00000000000000034e-213 < x < 1.02000000000000004e-126

    1. Initial program 99.8%

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

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

    if 5.0000000000000001e-4 < x < 1.4499999999999999e147

    1. Initial program 94.1%

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

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

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

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

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

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

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

        \[\leadsto \frac{0.5 \cdot x}{\color{blue}{1 \cdot z}} \cdot y \]
      3. times-frac37.4%

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

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

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

    if 1.4499999999999999e147 < x

    1. Initial program 70.4%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 7 \cdot 10^{-213}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{-126}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \mathbf{elif}\;x \leq 0.0005:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{+147}:\\ \;\;\;\;y \cdot \left(0.5 \cdot \frac{x}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{0.5}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 59.1% accurate, 4.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \frac{\frac{y_m}{z}}{x}\\ y_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 7 \cdot 10^{-213}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-125}:\\ \;\;\;\;\frac{\frac{y_m}{x}}{z}\\ \mathbf{elif}\;x \leq 0.0005:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 6.3 \cdot 10^{+146}:\\ \;\;\;\;y_m \cdot \frac{0.5}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5 \cdot \left(y_m \cdot x\right)}{z}\\ \end{array} \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (let* ((t_0 (/ (/ y_m z) x)))
   (*
    y_s
    (if (<= x 7e-213)
      t_0
      (if (<= x 1.05e-125)
        (/ (/ y_m x) z)
        (if (<= x 0.0005)
          t_0
          (if (<= x 6.3e+146)
            (* y_m (/ 0.5 (/ z x)))
            (/ (* 0.5 (* 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) {
	double t_0 = (y_m / z) / x;
	double tmp;
	if (x <= 7e-213) {
		tmp = t_0;
	} else if (x <= 1.05e-125) {
		tmp = (y_m / x) / z;
	} else if (x <= 0.0005) {
		tmp = t_0;
	} else if (x <= 6.3e+146) {
		tmp = y_m * (0.5 / (z / x));
	} else {
		tmp = (0.5 * (y_m * 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) :: t_0
    real(8) :: tmp
    t_0 = (y_m / z) / x
    if (x <= 7d-213) then
        tmp = t_0
    else if (x <= 1.05d-125) then
        tmp = (y_m / x) / z
    else if (x <= 0.0005d0) then
        tmp = t_0
    else if (x <= 6.3d+146) then
        tmp = y_m * (0.5d0 / (z / x))
    else
        tmp = (0.5d0 * (y_m * 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 t_0 = (y_m / z) / x;
	double tmp;
	if (x <= 7e-213) {
		tmp = t_0;
	} else if (x <= 1.05e-125) {
		tmp = (y_m / x) / z;
	} else if (x <= 0.0005) {
		tmp = t_0;
	} else if (x <= 6.3e+146) {
		tmp = y_m * (0.5 / (z / x));
	} else {
		tmp = (0.5 * (y_m * 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):
	t_0 = (y_m / z) / x
	tmp = 0
	if x <= 7e-213:
		tmp = t_0
	elif x <= 1.05e-125:
		tmp = (y_m / x) / z
	elif x <= 0.0005:
		tmp = t_0
	elif x <= 6.3e+146:
		tmp = y_m * (0.5 / (z / x))
	else:
		tmp = (0.5 * (y_m * x)) / z
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	t_0 = Float64(Float64(y_m / z) / x)
	tmp = 0.0
	if (x <= 7e-213)
		tmp = t_0;
	elseif (x <= 1.05e-125)
		tmp = Float64(Float64(y_m / x) / z);
	elseif (x <= 0.0005)
		tmp = t_0;
	elseif (x <= 6.3e+146)
		tmp = Float64(y_m * Float64(0.5 / Float64(z / x)));
	else
		tmp = Float64(Float64(0.5 * Float64(y_m * 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)
	t_0 = (y_m / z) / x;
	tmp = 0.0;
	if (x <= 7e-213)
		tmp = t_0;
	elseif (x <= 1.05e-125)
		tmp = (y_m / x) / z;
	elseif (x <= 0.0005)
		tmp = t_0;
	elseif (x <= 6.3e+146)
		tmp = y_m * (0.5 / (z / x));
	else
		tmp = (0.5 * (y_m * 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_] := Block[{t$95$0 = N[(N[(y$95$m / z), $MachinePrecision] / x), $MachinePrecision]}, N[(y$95$s * If[LessEqual[x, 7e-213], t$95$0, If[LessEqual[x, 1.05e-125], N[(N[(y$95$m / x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[x, 0.0005], t$95$0, If[LessEqual[x, 6.3e+146], N[(y$95$m * N[(0.5 / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(y$95$m * x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]]]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

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

\mathbf{elif}\;x \leq 1.05 \cdot 10^{-125}:\\
\;\;\;\;\frac{\frac{y_m}{x}}{z}\\

\mathbf{elif}\;x \leq 0.0005:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 6.3 \cdot 10^{+146}:\\
\;\;\;\;y_m \cdot \frac{0.5}{\frac{z}{x}}\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 7.00000000000000034e-213 or 1.05e-125 < x < 5.0000000000000001e-4

    1. Initial program 80.9%

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

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

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

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

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

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

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

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

    if 7.00000000000000034e-213 < x < 1.05e-125

    1. Initial program 99.8%

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

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

    if 5.0000000000000001e-4 < x < 6.3000000000000002e146

    1. Initial program 94.1%

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

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

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

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

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

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

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

        \[\leadsto \frac{0.5 \cdot x}{\color{blue}{1 \cdot z}} \cdot y \]
      3. times-frac37.4%

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

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \frac{x}{z}\right) \cdot y} \]
    9. Step-by-step derivation
      1. clear-num37.4%

        \[\leadsto \left(0.5 \cdot \color{blue}{\frac{1}{\frac{z}{x}}}\right) \cdot y \]
      2. un-div-inv37.4%

        \[\leadsto \color{blue}{\frac{0.5}{\frac{z}{x}}} \cdot y \]
    10. Applied egg-rr37.4%

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

    if 6.3000000000000002e146 < x

    1. Initial program 70.4%

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

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

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

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

        \[\leadsto \frac{0.5 \cdot \color{blue}{\left(y \cdot x\right)}}{z} \]
    6. Simplified60.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 7 \cdot 10^{-213}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-125}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \mathbf{elif}\;x \leq 0.0005:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{elif}\;x \leq 6.3 \cdot 10^{+146}:\\ \;\;\;\;y \cdot \frac{0.5}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5 \cdot \left(y \cdot x\right)}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 59.1% accurate, 4.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \frac{\frac{y_m}{z}}{x}\\ y_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 6.8 \cdot 10^{-213}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-133}:\\ \;\;\;\;\frac{\frac{y_m}{x}}{z}\\ \mathbf{elif}\;x \leq 0.0005:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y_m \cdot \left(0.5 \cdot \frac{x}{z}\right)\\ \end{array} \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (let* ((t_0 (/ (/ y_m z) x)))
   (*
    y_s
    (if (<= x 6.8e-213)
      t_0
      (if (<= x 1.5e-133)
        (/ (/ y_m x) z)
        (if (<= x 0.0005) t_0 (* y_m (* 0.5 (/ 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 t_0 = (y_m / z) / x;
	double tmp;
	if (x <= 6.8e-213) {
		tmp = t_0;
	} else if (x <= 1.5e-133) {
		tmp = (y_m / x) / z;
	} else if (x <= 0.0005) {
		tmp = t_0;
	} else {
		tmp = y_m * (0.5 * (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) :: t_0
    real(8) :: tmp
    t_0 = (y_m / z) / x
    if (x <= 6.8d-213) then
        tmp = t_0
    else if (x <= 1.5d-133) then
        tmp = (y_m / x) / z
    else if (x <= 0.0005d0) then
        tmp = t_0
    else
        tmp = y_m * (0.5d0 * (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 t_0 = (y_m / z) / x;
	double tmp;
	if (x <= 6.8e-213) {
		tmp = t_0;
	} else if (x <= 1.5e-133) {
		tmp = (y_m / x) / z;
	} else if (x <= 0.0005) {
		tmp = t_0;
	} else {
		tmp = y_m * (0.5 * (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):
	t_0 = (y_m / z) / x
	tmp = 0
	if x <= 6.8e-213:
		tmp = t_0
	elif x <= 1.5e-133:
		tmp = (y_m / x) / z
	elif x <= 0.0005:
		tmp = t_0
	else:
		tmp = y_m * (0.5 * (x / z))
	return y_s * tmp
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	t_0 = Float64(Float64(y_m / z) / x)
	tmp = 0.0
	if (x <= 6.8e-213)
		tmp = t_0;
	elseif (x <= 1.5e-133)
		tmp = Float64(Float64(y_m / x) / z);
	elseif (x <= 0.0005)
		tmp = t_0;
	else
		tmp = Float64(y_m * Float64(0.5 * Float64(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)
	t_0 = (y_m / z) / x;
	tmp = 0.0;
	if (x <= 6.8e-213)
		tmp = t_0;
	elseif (x <= 1.5e-133)
		tmp = (y_m / x) / z;
	elseif (x <= 0.0005)
		tmp = t_0;
	else
		tmp = y_m * (0.5 * (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_] := Block[{t$95$0 = N[(N[(y$95$m / z), $MachinePrecision] / x), $MachinePrecision]}, N[(y$95$s * If[LessEqual[x, 6.8e-213], t$95$0, If[LessEqual[x, 1.5e-133], N[(N[(y$95$m / x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[x, 0.0005], t$95$0, N[(y$95$m * N[(0.5 * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

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

\mathbf{elif}\;x \leq 1.5 \cdot 10^{-133}:\\
\;\;\;\;\frac{\frac{y_m}{x}}{z}\\

\mathbf{elif}\;x \leq 0.0005:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 6.8000000000000005e-213 or 1.5000000000000001e-133 < x < 5.0000000000000001e-4

    1. Initial program 80.9%

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

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

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

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

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

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

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

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

    if 6.8000000000000005e-213 < x < 1.5000000000000001e-133

    1. Initial program 99.8%

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

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

    if 5.0000000000000001e-4 < x

    1. Initial program 83.6%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot x}{z} \cdot y} \]
      2. *-un-lft-identity41.6%

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

        \[\leadsto \color{blue}{\left(\frac{0.5}{1} \cdot \frac{x}{z}\right)} \cdot y \]
      4. metadata-eval41.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6.8 \cdot 10^{-213}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-133}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \mathbf{elif}\;x \leq 0.0005:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(0.5 \cdot \frac{x}{z}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 65.4% accurate, 6.3× 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.8 \cdot 10^{-250}:\\ \;\;\;\;\frac{-y_m}{\frac{z}{x \cdot -0.5 + \frac{-1}{x}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y_m}{x} + 0.5 \cdot \left(y_m \cdot x\right)}{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 (<= y_m 4.8e-250)
    (/ (- y_m) (/ z (+ (* x -0.5) (/ -1.0 x))))
    (/ (+ (/ y_m x) (* 0.5 (* 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) {
	double tmp;
	if (y_m <= 4.8e-250) {
		tmp = -y_m / (z / ((x * -0.5) + (-1.0 / x)));
	} else {
		tmp = ((y_m / x) + (0.5 * (y_m * 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 (y_m <= 4.8d-250) then
        tmp = -y_m / (z / ((x * (-0.5d0)) + ((-1.0d0) / x)))
    else
        tmp = ((y_m / x) + (0.5d0 * (y_m * 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 (y_m <= 4.8e-250) {
		tmp = -y_m / (z / ((x * -0.5) + (-1.0 / x)));
	} else {
		tmp = ((y_m / x) + (0.5 * (y_m * 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 y_m <= 4.8e-250:
		tmp = -y_m / (z / ((x * -0.5) + (-1.0 / x)))
	else:
		tmp = ((y_m / x) + (0.5 * (y_m * 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 (y_m <= 4.8e-250)
		tmp = Float64(Float64(-y_m) / Float64(z / Float64(Float64(x * -0.5) + Float64(-1.0 / x))));
	else
		tmp = Float64(Float64(Float64(y_m / x) + Float64(0.5 * Float64(y_m * 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 (y_m <= 4.8e-250)
		tmp = -y_m / (z / ((x * -0.5) + (-1.0 / x)));
	else
		tmp = ((y_m / x) + (0.5 * (y_m * 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[y$95$m, 4.8e-250], N[((-y$95$m) / N[(z / N[(N[(x * -0.5), $MachinePrecision] + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y$95$m / x), $MachinePrecision] + N[(0.5 * N[(y$95$m * x), $MachinePrecision]), $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}\;y_m \leq 4.8 \cdot 10^{-250}:\\
\;\;\;\;\frac{-y_m}{\frac{z}{x \cdot -0.5 + \frac{-1}{x}}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 4.7999999999999998e-250

    1. Initial program 75.8%

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{y \cdot \left(-0.5 \cdot x - \frac{1}{x}\right)}{z}} \]
    5. Step-by-step derivation
      1. mul-1-neg63.5%

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

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

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

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

    if 4.7999999999999998e-250 < y

    1. Initial program 92.7%

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

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

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

Alternative 9: 65.6% accurate, 9.7× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ y_s \cdot \frac{\frac{y_m}{x} + 0.5 \cdot \left(y_m \cdot x\right)}{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) (* 0.5 (* 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) + (0.5 * (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) + (0.5d0 * (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) + (0.5 * (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) + (0.5 * (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(Float64(Float64(y_m / x) + Float64(0.5 * Float64(y_m * 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) + (0.5 * (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[(N[(N[(y$95$m / x), $MachinePrecision] + N[(0.5 * N[(y$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
y_s \cdot \frac{\frac{y_m}{x} + 0.5 \cdot \left(y_m \cdot x\right)}{z}
\end{array}
Derivation
  1. Initial program 82.9%

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

    \[\leadsto \frac{\color{blue}{0.5 \cdot \left(x \cdot y\right) + \frac{y}{x}}}{z} \]
  4. Final simplification66.5%

    \[\leadsto \frac{\frac{y}{x} + 0.5 \cdot \left(y \cdot x\right)}{z} \]
  5. Add Preprocessing

Alternative 10: 52.9% 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 5 \cdot 10^{-20}:\\ \;\;\;\;\frac{\frac{y_m}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y_m}{x \cdot 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 (<= y_m 5e-20) (/ (/ y_m x) z) (/ 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) {
	double tmp;
	if (y_m <= 5e-20) {
		tmp = (y_m / x) / z;
	} else {
		tmp = y_m / (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 (y_m <= 5d-20) then
        tmp = (y_m / x) / z
    else
        tmp = y_m / (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 (y_m <= 5e-20) {
		tmp = (y_m / x) / z;
	} else {
		tmp = y_m / (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 y_m <= 5e-20:
		tmp = (y_m / x) / z
	else:
		tmp = y_m / (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 (y_m <= 5e-20)
		tmp = Float64(Float64(y_m / x) / z);
	else
		tmp = Float64(y_m / Float64(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 (y_m <= 5e-20)
		tmp = (y_m / x) / z;
	else
		tmp = y_m / (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[y$95$m, 5e-20], N[(N[(y$95$m / x), $MachinePrecision] / z), $MachinePrecision], 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 \begin{array}{l}
\mathbf{if}\;y_m \leq 5 \cdot 10^{-20}:\\
\;\;\;\;\frac{\frac{y_m}{x}}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 4.9999999999999999e-20

    1. Initial program 79.5%

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

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

    if 4.9999999999999999e-20 < y

    1. Initial program 93.9%

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

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

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

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

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

Alternative 11: 56.9% 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 10^{-40}:\\ \;\;\;\;\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 1e-40) (/ (/ 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 <= 1e-40) {
		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 <= 1d-40) 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 <= 1e-40) {
		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 <= 1e-40:
		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 <= 1e-40)
		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 <= 1e-40)
		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, 1e-40], 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 10^{-40}:\\
\;\;\;\;\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 < 9.9999999999999993e-41

    1. Initial program 78.9%

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

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

    if 9.9999999999999993e-41 < y

    1. Initial program 94.3%

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

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

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

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

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

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

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

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

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

Alternative 12: 49.1% 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 82.9%

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

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

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

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

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

Developer target: 97.5% 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 2024014 
(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))