Linear.Quaternion:$ctan from linear-1.19.1.3

Percentage Accurate: 84.9% → 99.8%
Time: 8.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.9% 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.8% 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 950:\\ \;\;\;\;\frac{\cosh x}{x} \cdot \frac{y}{z\_m}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{\frac{\cosh x}{z\_m}}{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 950.0)
    (* (/ (cosh x) x) (/ y z_m))
    (* y (/ (/ (cosh x) 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 <= 950.0) {
		tmp = (cosh(x) / x) * (y / z_m);
	} else {
		tmp = y * ((cosh(x) / 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 <= 950.0d0) then
        tmp = (cosh(x) / x) * (y / z_m)
    else
        tmp = y * ((cosh(x) / 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 <= 950.0) {
		tmp = (Math.cosh(x) / x) * (y / z_m);
	} else {
		tmp = y * ((Math.cosh(x) / 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 <= 950.0:
		tmp = (math.cosh(x) / x) * (y / z_m)
	else:
		tmp = y * ((math.cosh(x) / 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 <= 950.0)
		tmp = Float64(Float64(cosh(x) / x) * Float64(y / z_m));
	else
		tmp = Float64(y * Float64(Float64(cosh(x) / 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 <= 950.0)
		tmp = (cosh(x) / x) * (y / z_m);
	else
		tmp = y * ((cosh(x) / 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, 950.0], N[(N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision] * N[(y / z$95$m), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(N[Cosh[x], $MachinePrecision] / z$95$m), $MachinePrecision] / 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 950:\\
\;\;\;\;\frac{\cosh x}{x} \cdot \frac{y}{z\_m}\\

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


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

    1. Initial program 87.9%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*r/98.4%

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

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

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

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

    if 950 < z

    1. Initial program 84.3%

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

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

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

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

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

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

Alternative 2: 95.8% 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}{z\_m}}{x}\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) 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 * ((cosh(x) / 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 * ((cosh(x) / 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 * ((Math.cosh(x) / 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 * ((math.cosh(x) / 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(Float64(cosh(x) / 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 * ((cosh(x) / 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[(N[(N[Cosh[x], $MachinePrecision] / z$95$m), $MachinePrecision] / x), $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}{z\_m}}{x}\right)
\end{array}
Derivation
  1. Initial program 87.1%

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

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

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

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

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

    \[\leadsto \color{blue}{y \cdot \frac{\frac{\cosh x}{z}}{x}} \]
  5. Add Preprocessing

Alternative 3: 57.9% accurate, 8.9× 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 10^{-18}:\\ \;\;\;\;\frac{y}{z\_m} \cdot \frac{1}{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 1e-18) (* (/ y z_m) (/ 1.0 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 <= 1e-18) {
		tmp = (y / z_m) * (1.0 / 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 <= 1d-18) then
        tmp = (y / z_m) * (1.0d0 / 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 <= 1e-18) {
		tmp = (y / z_m) * (1.0 / 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 <= 1e-18:
		tmp = (y / z_m) * (1.0 / 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 <= 1e-18)
		tmp = Float64(Float64(y / z_m) * Float64(1.0 / 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 <= 1e-18)
		tmp = (y / z_m) * (1.0 / 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, 1e-18], N[(N[(y / z$95$m), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $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 10^{-18}:\\
\;\;\;\;\frac{y}{z\_m} \cdot \frac{1}{x}\\

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


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

    1. Initial program 87.7%

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

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

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

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

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

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

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

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

    if 1.0000000000000001e-18 < z

    1. Initial program 85.1%

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

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

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

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

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

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

Alternative 4: 57.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 4.5 \cdot 10^{-6}:\\ \;\;\;\;\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 4.5e-6) (/ (/ 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 <= 4.5e-6) {
		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 <= 4.5d-6) 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 <= 4.5e-6) {
		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 <= 4.5e-6:
		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 <= 4.5e-6)
		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 <= 4.5e-6)
		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, 4.5e-6], 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 4.5 \cdot 10^{-6}:\\
\;\;\;\;\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.50000000000000011e-6

    1. Initial program 87.8%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{y}{z}}{x}} \]
    7. Simplified54.1%

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

    if 4.50000000000000011e-6 < z

    1. Initial program 84.5%

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

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

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

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

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

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

Alternative 5: 53.8% 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^{+48}:\\ \;\;\;\;\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 (<= z_m 5e+48) (/ (/ 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 (z_m <= 5e+48) {
		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 (z_m <= 5d+48) 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 (z_m <= 5e+48) {
		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 z_m <= 5e+48:
		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 (z_m <= 5e+48)
		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 (z_m <= 5e+48)
		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[z$95$m, 5e+48], 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}\;z\_m \leq 5 \cdot 10^{+48}:\\
\;\;\;\;\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 z < 4.99999999999999973e48

    1. Initial program 88.4%

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

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

    if 4.99999999999999973e48 < z

    1. Initial program 81.0%

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

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

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

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

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

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

Alternative 6: 50.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 87.1%

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

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

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

    \[\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}} \]
  6. Final simplification48.2%

    \[\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 2024089 
(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))