Linear.Quaternion:$ctan from linear-1.19.1.3

Percentage Accurate: 84.7% → 99.7%
Time: 10.3s
Alternatives: 16
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 16 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.7% 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 1.85 \cdot 10^{-40}:\\ \;\;\;\;\frac{\frac{\cosh x}{\frac{z\_m}{y}}}{x}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{\frac{\cosh x}{z\_m}}{x}\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
(FPCore (z_s x y z_m)
 :precision binary64
 (*
  z_s
  (if (<= z_m 1.85e-40)
    (/ (/ (cosh x) (/ z_m y)) x)
    (* 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 <= 1.85e-40) {
		tmp = (cosh(x) / (z_m / y)) / x;
	} 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 <= 1.85d-40) then
        tmp = (cosh(x) / (z_m / y)) / x
    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 <= 1.85e-40) {
		tmp = (Math.cosh(x) / (z_m / y)) / x;
	} 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 <= 1.85e-40:
		tmp = (math.cosh(x) / (z_m / y)) / x
	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 <= 1.85e-40)
		tmp = Float64(Float64(cosh(x) / Float64(z_m / y)) / x);
	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 <= 1.85e-40)
		tmp = (cosh(x) / (z_m / y)) / x;
	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, 1.85e-40], N[(N[(N[Cosh[x], $MachinePrecision] / N[(z$95$m / y), $MachinePrecision]), $MachinePrecision] / x), $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 1.85 \cdot 10^{-40}:\\
\;\;\;\;\frac{\frac{\cosh x}{\frac{z\_m}{y}}}{x}\\

\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 < 1.84999999999999999e-40

    1. Initial program 91.5%

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

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

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

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

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

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

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

    if 1.84999999999999999e-40 < z

    1. Initial program 85.0%

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\cosh x}{z} \cdot \frac{y}{x}\right)} - 1} \]
      3. associate-*l/41.3%

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(\cosh x \cdot \frac{y}{x}\right) \cdot \frac{1}{z}}\right)} - 1 \]
      5. associate-*l*37.4%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.7% 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 5 \cdot 10^{+213}:\\ \;\;\;\;\frac{t\_0}{z\_m}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{\frac{\cosh x}{z\_m}}{x}\\ \end{array} \end{array} \end{array} \]
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
(FPCore (z_s x y z_m)
 :precision binary64
 (let* ((t_0 (* (cosh x) (/ y x))))
   (* z_s (if (<= t_0 5e+213) (/ t_0 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 t_0 = cosh(x) * (y / x);
	double tmp;
	if (t_0 <= 5e+213) {
		tmp = t_0 / 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) :: t_0
    real(8) :: tmp
    t_0 = cosh(x) * (y / x)
    if (t_0 <= 5d+213) then
        tmp = t_0 / 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 t_0 = Math.cosh(x) * (y / x);
	double tmp;
	if (t_0 <= 5e+213) {
		tmp = t_0 / 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):
	t_0 = math.cosh(x) * (y / x)
	tmp = 0
	if t_0 <= 5e+213:
		tmp = t_0 / 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)
	t_0 = Float64(cosh(x) * Float64(y / x))
	tmp = 0.0
	if (t_0 <= 5e+213)
		tmp = Float64(t_0 / 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)
	t_0 = cosh(x) * (y / x);
	tmp = 0.0;
	if (t_0 <= 5e+213)
		tmp = t_0 / 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_] := Block[{t$95$0 = N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]}, N[(z$95$s * If[LessEqual[t$95$0, 5e+213], N[(t$95$0 / z$95$m), $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)

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

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


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

    1. Initial program 95.9%

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

    if 4.9999999999999998e213 < (*.f64 (cosh.f64 x) (/.f64 y x))

    1. Initial program 76.8%

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\cosh x}{z} \cdot \frac{y}{x}\right)} - 1} \]
      3. associate-*l/42.5%

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(\cosh x \cdot \frac{y}{x}\right) \cdot \frac{1}{z}}\right)} - 1 \]
      5. associate-*l*39.0%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\cosh x \cdot \left(\frac{y}{x} \cdot \frac{1}{z}\right)}\right)} - 1 \]
      6. div-inv39.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 74.9% 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}\;x \leq 2.65 \cdot 10^{-109}:\\ \;\;\;\;\frac{\frac{y}{z\_m}}{x}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{\frac{\cosh x}{z\_m}}{x}\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
(FPCore (z_s x y z_m)
 :precision binary64
 (* z_s (if (<= x 2.65e-109) (/ (/ y z_m) x) (* 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 (x <= 2.65e-109) {
		tmp = (y / z_m) / x;
	} 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 (x <= 2.65d-109) then
        tmp = (y / z_m) / x
    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 (x <= 2.65e-109) {
		tmp = (y / z_m) / x;
	} 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 x <= 2.65e-109:
		tmp = (y / z_m) / x
	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 (x <= 2.65e-109)
		tmp = Float64(Float64(y / z_m) / x);
	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 (x <= 2.65e-109)
		tmp = (y / z_m) / x;
	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[x, 2.65e-109], N[(N[(y / z$95$m), $MachinePrecision] / x), $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}\;x \leq 2.65 \cdot 10^{-109}:\\
\;\;\;\;\frac{\frac{y}{z\_m}}{x}\\

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


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

    1. Initial program 91.5%

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

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

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

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

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

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

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

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

    if 2.6499999999999999e-109 < x

    1. Initial program 85.4%

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\cosh x}{z} \cdot \frac{y}{x}\right)} - 1} \]
      3. associate-*l/43.2%

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(\cosh x \cdot \frac{y}{x}\right) \cdot \frac{1}{z}}\right)} - 1 \]
      5. associate-*l*40.8%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\cosh x \cdot \left(\frac{y}{x} \cdot \frac{1}{z}\right)}\right)} - 1 \]
      6. div-inv40.8%

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 95.4% accurate, 1.0× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ z_s = \mathsf{copysign}\left(1, z\right) \\ \begin{array}{l} t_0 := \frac{\cosh x}{z\_m}\\ z\_s \cdot \begin{array}{l} \mathbf{if}\;z\_m \leq 1.45 \cdot 10^{-96}:\\ \;\;\;\;t\_0 \cdot \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{t\_0}{x}\\ \end{array} \end{array} \end{array} \]
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
(FPCore (z_s x y z_m)
 :precision binary64
 (let* ((t_0 (/ (cosh x) z_m)))
   (* z_s (if (<= z_m 1.45e-96) (* t_0 (/ y x)) (* y (/ t_0 x))))))
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) / z_m;
	double tmp;
	if (z_m <= 1.45e-96) {
		tmp = t_0 * (y / x);
	} else {
		tmp = y * (t_0 / 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) :: t_0
    real(8) :: tmp
    t_0 = cosh(x) / z_m
    if (z_m <= 1.45d-96) then
        tmp = t_0 * (y / x)
    else
        tmp = y * (t_0 / 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 t_0 = Math.cosh(x) / z_m;
	double tmp;
	if (z_m <= 1.45e-96) {
		tmp = t_0 * (y / x);
	} else {
		tmp = y * (t_0 / 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):
	t_0 = math.cosh(x) / z_m
	tmp = 0
	if z_m <= 1.45e-96:
		tmp = t_0 * (y / x)
	else:
		tmp = y * (t_0 / x)
	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) / z_m)
	tmp = 0.0
	if (z_m <= 1.45e-96)
		tmp = Float64(t_0 * Float64(y / x));
	else
		tmp = Float64(y * Float64(t_0 / 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)
	t_0 = cosh(x) / z_m;
	tmp = 0.0;
	if (z_m <= 1.45e-96)
		tmp = t_0 * (y / x);
	else
		tmp = y * (t_0 / 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_] := Block[{t$95$0 = N[(N[Cosh[x], $MachinePrecision] / z$95$m), $MachinePrecision]}, N[(z$95$s * If[LessEqual[z$95$m, 1.45e-96], N[(t$95$0 * N[(y / x), $MachinePrecision]), $MachinePrecision], N[(y * N[(t$95$0 / x), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)

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

\mathbf{else}:\\
\;\;\;\;y \cdot \frac{t\_0}{x}\\


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

    1. Initial program 90.9%

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

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

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

    if 1.44999999999999997e-96 < z

    1. Initial program 87.0%

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\cosh x}{z} \cdot \frac{y}{x}\right)} - 1} \]
      3. associate-*l/43.4%

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(\cosh x \cdot \frac{y}{x}\right) \cdot \frac{1}{z}}\right)} - 1 \]
      5. associate-*l*40.0%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\cosh x \cdot \left(\frac{y}{x} \cdot \frac{1}{z}\right)}\right)} - 1 \]
      6. div-inv40.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 70.8% accurate, 3.7× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(x \cdot y\right)\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 3.7 \cdot 10^{-56}:\\
\;\;\;\;\frac{\frac{y}{x} + t\_0}{z\_m}\\

\mathbf{elif}\;z\_m \leq 1.45 \cdot 10^{+78}:\\
\;\;\;\;\frac{t\_0 \cdot \left(z\_m \cdot x\right) + z\_m \cdot y}{z\_m \cdot \left(z\_m \cdot x\right)}\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 3.7000000000000002e-56

    1. Initial program 91.2%

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

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

    if 3.7000000000000002e-56 < z < 1.45000000000000008e78

    1. Initial program 94.1%

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

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

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

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left(x \cdot y\right)}{z}} + \frac{y}{x \cdot z} \]
      2. frac-add82.6%

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

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

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

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

    if 1.45000000000000008e78 < z

    1. Initial program 80.2%

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

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

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

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

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

Alternative 6: 71.3% accurate, 4.6× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(x \cdot y\right)\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 5 \cdot 10^{-96}:\\
\;\;\;\;\frac{\frac{y}{x} + t\_0}{z\_m}\\

\mathbf{elif}\;z\_m \leq 1.35 \cdot 10^{+135}:\\
\;\;\;\;\frac{y + x \cdot t\_0}{z\_m \cdot x}\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 4.99999999999999995e-96

    1. Initial program 90.9%

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

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

    if 4.99999999999999995e-96 < z < 1.34999999999999992e135

    1. Initial program 93.3%

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{z} + \frac{y}{x \cdot z}} \]
    6. Step-by-step derivation
      1. +-commutative70.1%

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{z} \cdot y}{x}} + 0.5 \cdot \frac{x \cdot y}{z} \]
      6. associate-*r/70.1%

        \[\leadsto \frac{\frac{1}{z} \cdot y}{x} + \color{blue}{\frac{0.5 \cdot \left(x \cdot y\right)}{z}} \]
      7. frac-add76.5%

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

        \[\leadsto \frac{\color{blue}{\frac{1 \cdot y}{z}} \cdot z + x \cdot \left(0.5 \cdot \left(x \cdot y\right)\right)}{x \cdot z} \]
      9. *-un-lft-identity76.5%

        \[\leadsto \frac{\frac{\color{blue}{y}}{z} \cdot z + x \cdot \left(0.5 \cdot \left(x \cdot y\right)\right)}{x \cdot z} \]
      10. *-commutative76.5%

        \[\leadsto \frac{\frac{y}{z} \cdot z + x \cdot \color{blue}{\left(\left(x \cdot y\right) \cdot 0.5\right)}}{x \cdot z} \]
      11. *-commutative76.5%

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

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

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

    if 1.34999999999999992e135 < z

    1. Initial program 75.3%

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

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

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

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

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

Alternative 7: 66.1% accurate, 5.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}\;y \leq 4.2 \cdot 10^{+181}:\\ \;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z\_m \cdot x} + 0.5 \cdot \left(x \cdot \frac{y}{z\_m}\right)\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
(FPCore (z_s x y z_m)
 :precision binary64
 (*
  z_s
  (if (<= y 4.2e+181)
    (/ (+ (/ y x) (* 0.5 (* x y))) z_m)
    (+ (/ y (* z_m x)) (* 0.5 (* x (/ y 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 (y <= 4.2e+181) {
		tmp = ((y / x) + (0.5 * (x * y))) / z_m;
	} else {
		tmp = (y / (z_m * x)) + (0.5 * (x * (y / 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 (y <= 4.2d+181) then
        tmp = ((y / x) + (0.5d0 * (x * y))) / z_m
    else
        tmp = (y / (z_m * x)) + (0.5d0 * (x * (y / 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 (y <= 4.2e+181) {
		tmp = ((y / x) + (0.5 * (x * y))) / z_m;
	} else {
		tmp = (y / (z_m * x)) + (0.5 * (x * (y / 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 y <= 4.2e+181:
		tmp = ((y / x) + (0.5 * (x * y))) / z_m
	else:
		tmp = (y / (z_m * x)) + (0.5 * (x * (y / 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 (y <= 4.2e+181)
		tmp = Float64(Float64(Float64(y / x) + Float64(0.5 * Float64(x * y))) / z_m);
	else
		tmp = Float64(Float64(y / Float64(z_m * x)) + Float64(0.5 * Float64(x * Float64(y / 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 (y <= 4.2e+181)
		tmp = ((y / x) + (0.5 * (x * y))) / z_m;
	else
		tmp = (y / (z_m * x)) + (0.5 * (x * (y / 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[y, 4.2e+181], N[(N[(N[(y / x), $MachinePrecision] + N[(0.5 * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision], N[(N[(y / N[(z$95$m * x), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(x * N[(y / z$95$m), $MachinePrecision]), $MachinePrecision]), $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 4.2 \cdot 10^{+181}:\\
\;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z\_m}\\

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


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

    1. Initial program 90.0%

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

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

    if 4.19999999999999995e181 < y

    1. Initial program 85.5%

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{z} + \frac{y}{x \cdot z}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u57.7%

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

        \[\leadsto 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{x \cdot y}{z}\right)} - 1\right)} + \frac{y}{x \cdot z} \]
      3. div-inv57.7%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\left(x \cdot y\right) \cdot \frac{1}{z}}\right)} - 1\right) + \frac{y}{x \cdot z} \]
      4. associate-*l*57.7%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{x \cdot \left(y \cdot \frac{1}{z}\right)}\right)} - 1\right) + \frac{y}{x \cdot z} \]
      5. *-commutative57.7%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(x \cdot \color{blue}{\left(\frac{1}{z} \cdot y\right)}\right)} - 1\right) + \frac{y}{x \cdot z} \]
      6. associate-*l/57.7%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(x \cdot \color{blue}{\frac{1 \cdot y}{z}}\right)} - 1\right) + \frac{y}{x \cdot z} \]
      7. *-un-lft-identity57.7%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(x \cdot \frac{\color{blue}{y}}{z}\right)} - 1\right) + \frac{y}{x \cdot z} \]
    7. Applied egg-rr57.7%

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

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

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

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

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

Alternative 8: 68.0% accurate, 5.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}\;y \leq 6 \cdot 10^{+32}:\\ \;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z\_m}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{z\_m} + \frac{y}{z\_m \cdot x}\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
(FPCore (z_s x y z_m)
 :precision binary64
 (*
  z_s
  (if (<= y 6e+32)
    (/ (+ (/ y x) (* 0.5 (* x y))) z_m)
    (+ (* 0.5 (/ (* x y) 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 <= 6e+32) {
		tmp = ((y / x) + (0.5 * (x * y))) / z_m;
	} else {
		tmp = (0.5 * ((x * y) / z_m)) + (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 <= 6d+32) then
        tmp = ((y / x) + (0.5d0 * (x * y))) / z_m
    else
        tmp = (0.5d0 * ((x * y) / z_m)) + (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 <= 6e+32) {
		tmp = ((y / x) + (0.5 * (x * y))) / z_m;
	} else {
		tmp = (0.5 * ((x * y) / z_m)) + (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 <= 6e+32:
		tmp = ((y / x) + (0.5 * (x * y))) / z_m
	else:
		tmp = (0.5 * ((x * y) / z_m)) + (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 <= 6e+32)
		tmp = Float64(Float64(Float64(y / x) + Float64(0.5 * Float64(x * y))) / z_m);
	else
		tmp = Float64(Float64(0.5 * Float64(Float64(x * y) / z_m)) + 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 <= 6e+32)
		tmp = ((y / x) + (0.5 * (x * y))) / z_m;
	else
		tmp = (0.5 * ((x * y) / z_m)) + (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, 6e+32], N[(N[(N[(y / x), $MachinePrecision] + N[(0.5 * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision], N[(N[(0.5 * N[(N[(x * y), $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision] + N[(y / N[(z$95$m * x), $MachinePrecision]), $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 6 \cdot 10^{+32}:\\
\;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z\_m}\\

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


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

    1. Initial program 88.7%

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

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

    if 6e32 < y

    1. Initial program 92.2%

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

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

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

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

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

Alternative 9: 57.6% 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}\;x \leq 1.4:\\ \;\;\;\;\frac{\frac{y}{z\_m}}{x}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{z\_m}\right)\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
(FPCore (z_s x y z_m)
 :precision binary64
 (* z_s (if (<= x 1.4) (/ (/ y z_m) x) (* 0.5 (* x (/ y 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 (x <= 1.4) {
		tmp = (y / z_m) / x;
	} else {
		tmp = 0.5 * (x * (y / 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 (x <= 1.4d0) then
        tmp = (y / z_m) / x
    else
        tmp = 0.5d0 * (x * (y / 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 (x <= 1.4) {
		tmp = (y / z_m) / x;
	} else {
		tmp = 0.5 * (x * (y / 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 x <= 1.4:
		tmp = (y / z_m) / x
	else:
		tmp = 0.5 * (x * (y / 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 (x <= 1.4)
		tmp = Float64(Float64(y / z_m) / x);
	else
		tmp = Float64(0.5 * Float64(x * Float64(y / 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 (x <= 1.4)
		tmp = (y / z_m) / x;
	else
		tmp = 0.5 * (x * (y / 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[x, 1.4], N[(N[(y / z$95$m), $MachinePrecision] / x), $MachinePrecision], N[(0.5 * N[(x * N[(y / z$95$m), $MachinePrecision]), $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}\;x \leq 1.4:\\
\;\;\;\;\frac{\frac{y}{z\_m}}{x}\\

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


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

    1. Initial program 92.6%

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

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

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

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

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

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

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

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

    if 1.3999999999999999 < x

    1. Initial program 79.3%

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{z} + \frac{y}{x \cdot z}} \]
    6. Taylor expanded in x around inf 32.1%

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

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

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

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

Alternative 10: 59.6% 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}\;x \leq 190:\\ \;\;\;\;\frac{\frac{y}{z\_m}}{x}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y \cdot \frac{x}{z\_m}\right)\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
(FPCore (z_s x y z_m)
 :precision binary64
 (* z_s (if (<= x 190.0) (/ (/ y z_m) x) (* 0.5 (* y (/ 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 (x <= 190.0) {
		tmp = (y / z_m) / x;
	} else {
		tmp = 0.5 * (y * (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 (x <= 190.0d0) then
        tmp = (y / z_m) / x
    else
        tmp = 0.5d0 * (y * (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 (x <= 190.0) {
		tmp = (y / z_m) / x;
	} else {
		tmp = 0.5 * (y * (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 x <= 190.0:
		tmp = (y / z_m) / x
	else:
		tmp = 0.5 * (y * (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 (x <= 190.0)
		tmp = Float64(Float64(y / z_m) / x);
	else
		tmp = Float64(0.5 * Float64(y * Float64(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 (x <= 190.0)
		tmp = (y / z_m) / x;
	else
		tmp = 0.5 * (y * (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[x, 190.0], N[(N[(y / z$95$m), $MachinePrecision] / x), $MachinePrecision], N[(0.5 * N[(y * N[(x / z$95$m), $MachinePrecision]), $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}\;x \leq 190:\\
\;\;\;\;\frac{\frac{y}{z\_m}}{x}\\

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


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

    1. Initial program 92.6%

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

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

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

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

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

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

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

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

    if 190 < x

    1. Initial program 78.9%

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{z} + \frac{y}{x \cdot z}} \]
    6. Taylor expanded in x around inf 32.5%

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

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

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

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

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

Alternative 11: 59.6% 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}\;x \leq 190:\\ \;\;\;\;\frac{\frac{y}{z\_m}}{x}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{z\_m}\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
(FPCore (z_s x y z_m)
 :precision binary64
 (* z_s (if (<= x 190.0) (/ (/ y z_m) x) (* 0.5 (/ (* x y) 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 (x <= 190.0) {
		tmp = (y / z_m) / x;
	} else {
		tmp = 0.5 * ((x * y) / 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 (x <= 190.0d0) then
        tmp = (y / z_m) / x
    else
        tmp = 0.5d0 * ((x * y) / 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 (x <= 190.0) {
		tmp = (y / z_m) / x;
	} else {
		tmp = 0.5 * ((x * y) / 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 x <= 190.0:
		tmp = (y / z_m) / x
	else:
		tmp = 0.5 * ((x * y) / 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 (x <= 190.0)
		tmp = Float64(Float64(y / z_m) / x);
	else
		tmp = Float64(0.5 * Float64(Float64(x * y) / 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 (x <= 190.0)
		tmp = (y / z_m) / x;
	else
		tmp = 0.5 * ((x * y) / 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[x, 190.0], N[(N[(y / z$95$m), $MachinePrecision] / x), $MachinePrecision], N[(0.5 * N[(N[(x * y), $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}\;x \leq 190:\\
\;\;\;\;\frac{\frac{y}{z\_m}}{x}\\

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


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

    1. Initial program 92.6%

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

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

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

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

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

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

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

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

    if 190 < x

    1. Initial program 78.9%

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{z} + \frac{y}{x \cdot z}} \]
    6. Taylor expanded in x around inf 32.5%

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

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

Alternative 12: 66.1% accurate, 9.7× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ z_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \frac{y \cdot \left(x \cdot 0.5 + \frac{1}{x}\right)}{z\_m} \end{array} \]
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
(FPCore (z_s x y z_m)
 :precision binary64
 (* z_s (/ (* y (+ (* x 0.5) (/ 1.0 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 * ((x * 0.5) + (1.0 / 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 * ((x * 0.5d0) + (1.0d0 / 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 * ((x * 0.5) + (1.0 / 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 * ((x * 0.5) + (1.0 / 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(Float64(y * Float64(Float64(x * 0.5) + Float64(1.0 / 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 * ((x * 0.5) + (1.0 / 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[(N[(y * N[(N[(x * 0.5), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)

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

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

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

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

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

Alternative 13: 66.2% accurate, 9.7× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ z_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z\_m} \end{array} \]
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
(FPCore (z_s x y z_m)
 :precision binary64
 (* z_s (/ (+ (/ y x) (* 0.5 (* x y))) 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 / x) + (0.5 * (x * y))) / 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 / x) + (0.5d0 * (x * y))) / 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 / x) + (0.5 * (x * y))) / 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 / x) + (0.5 * (x * y))) / 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(Float64(Float64(y / x) + Float64(0.5 * Float64(x * y))) / 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 / x) + (0.5 * (x * y))) / 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[(N[(N[(y / x), $MachinePrecision] + N[(0.5 * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)

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

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

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

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

Alternative 14: 51.0% 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 4.5 \cdot 10^{+32}:\\ \;\;\;\;\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 1 z)
(FPCore (z_s x y z_m)
 :precision binary64
 (* z_s (if (<= y 4.5e+32) (/ (/ 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 <= 4.5e+32) {
		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 <= 4.5d+32) 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 <= 4.5e+32) {
		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 <= 4.5e+32:
		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 <= 4.5e+32)
		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 <= 4.5e+32)
		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, 4.5e+32], 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 4.5 \cdot 10^{+32}:\\
\;\;\;\;\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 < 4.5000000000000003e32

    1. Initial program 88.7%

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

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

    if 4.5000000000000003e32 < y

    1. Initial program 92.2%

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

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

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

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

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

Alternative 15: 52.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}\;y \leq 7 \cdot 10^{+15}:\\ \;\;\;\;\frac{\frac{y}{x}}{z\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z\_m}}{x}\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
(FPCore (z_s x y z_m)
 :precision binary64
 (* z_s (if (<= y 7e+15) (/ (/ 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 <= 7e+15) {
		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 <= 7d+15) 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 <= 7e+15) {
		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 <= 7e+15:
		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 <= 7e+15)
		tmp = Float64(Float64(y / x) / z_m);
	else
		tmp = Float64(Float64(y / 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 <= 7e+15)
		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, 7e+15], N[(N[(y / x), $MachinePrecision] / z$95$m), $MachinePrecision], N[(N[(y / z$95$m), $MachinePrecision] / x), $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 7 \cdot 10^{+15}:\\
\;\;\;\;\frac{\frac{y}{x}}{z\_m}\\

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


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

    1. Initial program 88.4%

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

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

    if 7e15 < y

    1. Initial program 92.8%

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

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

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

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

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

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

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

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

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

Alternative 16: 49.6% 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 1 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 89.6%

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

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

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

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

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

Developer target: 97.3% accurate, 0.9× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}

Reproduce

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