Linear.Quaternion:$ctan from linear-1.19.1.3

Percentage Accurate: 84.5% → 99.7%
Time: 14.4s
Alternatives: 6
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 6 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.5% 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.7% accurate, 1.0× speedup?

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

\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 3.1 \cdot 10^{+40}:\\
\;\;\;\;\frac{\frac{y}{z\_m} \cdot \cosh x}{x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 3.0999999999999998e40

    1. Initial program 85.2%

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

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

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

      \[\leadsto \color{blue}{\cosh x \cdot \frac{y}{z \cdot x}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. *-commutative78.2%

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

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

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

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

    if 3.0999999999999998e40 < z

    1. Initial program 77.2%

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

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

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

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

        \[\leadsto \cosh x \cdot \color{blue}{\frac{1}{\frac{z \cdot x}{y}}} \]
      2. un-div-inv55.1%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{\cosh x}{z}}{x}} \cdot y \]
      4. *-commutative99.9%

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

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

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

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

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

Alternative 2: 97.4% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \cosh x \cdot \frac{y}{x}\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 10^{+115}:\\
\;\;\;\;\frac{t\_0}{z\_m}\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (cosh.f64 x) (/.f64 y x)) < 1e115

    1. Initial program 96.5%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Add Preprocessing

    if 1e115 < (*.f64 (cosh.f64 x) (/.f64 y x))

    1. Initial program 68.9%

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

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

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

      \[\leadsto \color{blue}{\cosh x \cdot \frac{y}{z \cdot x}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num67.7%

        \[\leadsto \cosh x \cdot \color{blue}{\frac{1}{\frac{z \cdot x}{y}}} \]
      2. un-div-inv67.7%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{\cosh x}{z}}{x}} \cdot y \]
      4. *-commutative99.9%

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

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

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

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

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

Alternative 3: 95.9% accurate, 1.0× speedup?

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

\\
z\_s \cdot \left(y \cdot \frac{\frac{\cosh x}{x}}{z\_m}\right)
\end{array}
Derivation
  1. Initial program 83.7%

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

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

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

    \[\leadsto \color{blue}{\cosh x \cdot \frac{y}{z \cdot x}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. clear-num73.9%

      \[\leadsto \cosh x \cdot \color{blue}{\frac{1}{\frac{z \cdot x}{y}}} \]
    2. un-div-inv73.9%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{y \cdot \frac{\frac{\cosh x}{x}}{z}} \]
  9. Final simplification96.5%

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

Alternative 4: 50.4% accurate, 10.7× speedup?

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

\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq 9.6 \cdot 10^{-166}:\\
\;\;\;\;\frac{\frac{y}{x}}{z\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{y}{z\_m \cdot x}\\


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

    1. Initial program 80.5%

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

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

    if 9.5999999999999994e-166 < y

    1. Initial program 89.5%

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

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

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

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

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

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

Alternative 5: 56.9% accurate, 10.7× speedup?

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

\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 5 \cdot 10^{-30}:\\
\;\;\;\;\frac{\frac{y}{z\_m}}{x}\\

\mathbf{else}:\\
\;\;\;\;\frac{y}{z\_m \cdot x}\\


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

    1. Initial program 85.0%

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

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

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

      \[\leadsto \color{blue}{\cosh x \cdot \frac{y}{z \cdot x}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. *-commutative77.6%

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

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

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

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

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

    if 4.99999999999999972e-30 < z

    1. Initial program 79.4%

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

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

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

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

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

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

Alternative 6: 49.4% accurate, 21.4× speedup?

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

\\
z\_s \cdot \frac{y}{z\_m \cdot x}
\end{array}
Derivation
  1. Initial program 83.7%

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

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

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

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

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

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

Developer target: 97.0% 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 2024076 
(FPCore (x y z)
  :name "Linear.Quaternion:$ctan from linear-1.19.1.3"
  :precision binary64

  :alt
  (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))