Linear.Quaternion:$ctan from linear-1.19.1.3

Percentage Accurate: 84.5% → 98.5%
Time: 7.5s
Alternatives: 12
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \frac{\cosh x \cdot \frac{y}{x}}{z} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
double code(double x, double y, double z) {
	return (cosh(x) * (y / x)) / z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (cosh(x) * (y / x)) / z
end function
public static double code(double x, double y, double z) {
	return (Math.cosh(x) * (y / x)) / z;
}
def code(x, y, z):
	return (math.cosh(x) * (y / x)) / z
function code(x, y, z)
	return Float64(Float64(cosh(x) * Float64(y / x)) / z)
end
function tmp = code(x, y, z)
	tmp = (cosh(x) * (y / x)) / z;
end
code[x_, y_, z_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 84.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\cosh x \cdot \frac{y}{x}}{z} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
double code(double x, double y, double z) {
	return (cosh(x) * (y / x)) / z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (cosh(x) * (y / x)) / z
end function
public static double code(double x, double y, double z) {
	return (Math.cosh(x) * (y / x)) / z;
}
def code(x, y, z):
	return (math.cosh(x) * (y / x)) / z
function code(x, y, z)
	return Float64(Float64(cosh(x) * Float64(y / x)) / z)
end
function tmp = code(x, y, z)
	tmp = (cosh(x) * (y / x)) / z;
end
code[x_, y_, z_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 98.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\cosh x \cdot \frac{y}{x}}{z}\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 10^{+226}\right):\\ \;\;\;\;y \cdot \frac{\frac{\cosh x}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (* (cosh x) (/ y x)) z)))
   (if (or (<= t_0 (- INFINITY)) (not (<= t_0 1e+226)))
     (* y (/ (/ (cosh x) x) z))
     (/ (/ y x) z))))
double code(double x, double y, double z) {
	double t_0 = (cosh(x) * (y / x)) / z;
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 1e+226)) {
		tmp = y * ((cosh(x) / x) / z);
	} else {
		tmp = (y / x) / z;
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	double t_0 = (Math.cosh(x) * (y / x)) / z;
	double tmp;
	if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 1e+226)) {
		tmp = y * ((Math.cosh(x) / x) / z);
	} else {
		tmp = (y / x) / z;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (math.cosh(x) * (y / x)) / z
	tmp = 0
	if (t_0 <= -math.inf) or not (t_0 <= 1e+226):
		tmp = y * ((math.cosh(x) / x) / z)
	else:
		tmp = (y / x) / z
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(cosh(x) * Float64(y / x)) / z)
	tmp = 0.0
	if ((t_0 <= Float64(-Inf)) || !(t_0 <= 1e+226))
		tmp = Float64(y * Float64(Float64(cosh(x) / x) / z));
	else
		tmp = Float64(Float64(y / x) / z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (cosh(x) * (y / x)) / z;
	tmp = 0.0;
	if ((t_0 <= -Inf) || ~((t_0 <= 1e+226)))
		tmp = y * ((cosh(x) / x) / z);
	else
		tmp = (y / x) / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 1e+226]], $MachinePrecision]], N[(y * N[(N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(y / x), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\cosh x \cdot \frac{y}{x}}{z}\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 10^{+226}\right):\\
\;\;\;\;y \cdot \frac{\frac{\cosh x}{x}}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < -inf.0 or 9.99999999999999961e225 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z)

    1. Initial program 78.2%

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

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

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

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

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

        \[\leadsto \frac{\cosh x}{\frac{\color{blue}{x \cdot z}}{y}} \]
      4. expm1-log1p-u36.1%

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

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

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

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

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

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

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

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

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

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

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

    if -inf.0 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 9.99999999999999961e225

    1. Initial program 99.6%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Taylor expanded in x around 0 99.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\cosh x \cdot \frac{y}{x}}{z} \leq -\infty \lor \neg \left(\frac{\cosh x \cdot \frac{y}{x}}{z} \leq 10^{+226}\right):\\ \;\;\;\;y \cdot \frac{\frac{\cosh x}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \]

Alternative 2: 96.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\frac{y \cdot \cosh x}{z}}{x} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (/ (* y (cosh x)) z) x))
double code(double x, double y, double z) {
	return ((y * cosh(x)) / z) / x;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((y * cosh(x)) / z) / x
end function
public static double code(double x, double y, double z) {
	return ((y * Math.cosh(x)) / z) / x;
}
def code(x, y, z):
	return ((y * math.cosh(x)) / z) / x
function code(x, y, z)
	return Float64(Float64(Float64(y * cosh(x)) / z) / x)
end
function tmp = code(x, y, z)
	tmp = ((y * cosh(x)) / z) / x;
end
code[x_, y_, z_] := N[(N[(N[(y * N[Cosh[x], $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{y \cdot \cosh x}{z}}{x}
\end{array}
Derivation
  1. Initial program 83.8%

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

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

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

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

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

      \[\leadsto \frac{\cosh x}{\frac{\color{blue}{x \cdot z}}{y}} \]
    4. expm1-log1p-u43.4%

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

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

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\cosh x \cdot y}{x \cdot z}}\right)} - 1 \]
    7. times-frac46.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{y \cdot \cosh x}{z}}{x}} \]
  10. Final simplification99.1%

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

Alternative 3: 68.2% accurate, 5.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{1 + x \cdot \left(x \cdot 0.5\right)}{x \cdot z}\\ \mathbf{if}\;x \leq -2.2 \cdot 10^{-12}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-102}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{+121}:\\ \;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(y \cdot x\right)}{z}\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{+237}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{0.5}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (/ (+ 1.0 (* x (* x 0.5))) (* x z)))))
   (if (<= x -2.2e-12)
     t_0
     (if (<= x 1.2e-102)
       (/ (/ y z) x)
       (if (<= x 2.1e+121)
         (/ (+ (/ y x) (* 0.5 (* y x))) z)
         (if (<= x 9.5e+237) t_0 (* (* y x) (/ 0.5 z))))))))
double code(double x, double y, double z) {
	double t_0 = y * ((1.0 + (x * (x * 0.5))) / (x * z));
	double tmp;
	if (x <= -2.2e-12) {
		tmp = t_0;
	} else if (x <= 1.2e-102) {
		tmp = (y / z) / x;
	} else if (x <= 2.1e+121) {
		tmp = ((y / x) + (0.5 * (y * x))) / z;
	} else if (x <= 9.5e+237) {
		tmp = t_0;
	} else {
		tmp = (y * x) * (0.5 / z);
	}
	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 * ((1.0d0 + (x * (x * 0.5d0))) / (x * z))
    if (x <= (-2.2d-12)) then
        tmp = t_0
    else if (x <= 1.2d-102) then
        tmp = (y / z) / x
    else if (x <= 2.1d+121) then
        tmp = ((y / x) + (0.5d0 * (y * x))) / z
    else if (x <= 9.5d+237) then
        tmp = t_0
    else
        tmp = (y * x) * (0.5d0 / z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y * ((1.0 + (x * (x * 0.5))) / (x * z));
	double tmp;
	if (x <= -2.2e-12) {
		tmp = t_0;
	} else if (x <= 1.2e-102) {
		tmp = (y / z) / x;
	} else if (x <= 2.1e+121) {
		tmp = ((y / x) + (0.5 * (y * x))) / z;
	} else if (x <= 9.5e+237) {
		tmp = t_0;
	} else {
		tmp = (y * x) * (0.5 / z);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * ((1.0 + (x * (x * 0.5))) / (x * z))
	tmp = 0
	if x <= -2.2e-12:
		tmp = t_0
	elif x <= 1.2e-102:
		tmp = (y / z) / x
	elif x <= 2.1e+121:
		tmp = ((y / x) + (0.5 * (y * x))) / z
	elif x <= 9.5e+237:
		tmp = t_0
	else:
		tmp = (y * x) * (0.5 / z)
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(Float64(1.0 + Float64(x * Float64(x * 0.5))) / Float64(x * z)))
	tmp = 0.0
	if (x <= -2.2e-12)
		tmp = t_0;
	elseif (x <= 1.2e-102)
		tmp = Float64(Float64(y / z) / x);
	elseif (x <= 2.1e+121)
		tmp = Float64(Float64(Float64(y / x) + Float64(0.5 * Float64(y * x))) / z);
	elseif (x <= 9.5e+237)
		tmp = t_0;
	else
		tmp = Float64(Float64(y * x) * Float64(0.5 / z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * ((1.0 + (x * (x * 0.5))) / (x * z));
	tmp = 0.0;
	if (x <= -2.2e-12)
		tmp = t_0;
	elseif (x <= 1.2e-102)
		tmp = (y / z) / x;
	elseif (x <= 2.1e+121)
		tmp = ((y / x) + (0.5 * (y * x))) / z;
	elseif (x <= 9.5e+237)
		tmp = t_0;
	else
		tmp = (y * x) * (0.5 / z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(N[(1.0 + N[(x * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.2e-12], t$95$0, If[LessEqual[x, 1.2e-102], N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 2.1e+121], N[(N[(N[(y / x), $MachinePrecision] + N[(0.5 * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[x, 9.5e+237], t$95$0, N[(N[(y * x), $MachinePrecision] * N[(0.5 / z), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y \cdot \frac{1 + x \cdot \left(x \cdot 0.5\right)}{x \cdot z}\\
\mathbf{if}\;x \leq -2.2 \cdot 10^{-12}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1.2 \cdot 10^{-102}:\\
\;\;\;\;\frac{\frac{y}{z}}{x}\\

\mathbf{elif}\;x \leq 2.1 \cdot 10^{+121}:\\
\;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(y \cdot x\right)}{z}\\

\mathbf{elif}\;x \leq 9.5 \cdot 10^{+237}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -2.19999999999999992e-12 or 2.1000000000000002e121 < x < 9.50000000000000061e237

    1. Initial program 73.2%

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

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

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

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

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

        \[\leadsto \frac{\cosh x}{\frac{\color{blue}{x \cdot z}}{y}} \]
      4. expm1-log1p-u31.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.19999999999999992e-12 < x < 1.2e-102

    1. Initial program 87.0%

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

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

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

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

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

        \[\leadsto \frac{\cosh x}{\frac{\color{blue}{x \cdot z}}{y}} \]
      4. expm1-log1p-u57.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{y}{z}}{x}} \]
    12. Simplified98.5%

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

    if 1.2e-102 < x < 2.1000000000000002e121

    1. Initial program 98.2%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Taylor expanded in x around 0 56.8%

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

    if 9.50000000000000061e237 < x

    1. Initial program 72.7%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Taylor expanded in x around 0 74.3%

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.5 \cdot \left(y \cdot x\right)}{z}} \]
    6. Step-by-step derivation
      1. associate-/l*74.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.2 \cdot 10^{-12}:\\ \;\;\;\;y \cdot \frac{1 + x \cdot \left(x \cdot 0.5\right)}{x \cdot z}\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-102}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{+121}:\\ \;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(y \cdot x\right)}{z}\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{+237}:\\ \;\;\;\;y \cdot \frac{1 + x \cdot \left(x \cdot 0.5\right)}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{0.5}{z}\\ \end{array} \]

Alternative 4: 65.4% accurate, 7.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(y \cdot x\right) \cdot \frac{0.5}{z}\\ \mathbf{if}\;x \leq -65:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.4:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{+100} \lor \neg \left(x \leq 5.4 \cdot 10^{+237}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{z}{x}}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (* y x) (/ 0.5 z))))
   (if (<= x -65.0)
     t_0
     (if (<= x 1.4)
       (/ (/ y z) x)
       (if (or (<= x 1.95e+100) (not (<= x 5.4e+237)))
         t_0
         (* 0.5 (/ y (/ z x))))))))
double code(double x, double y, double z) {
	double t_0 = (y * x) * (0.5 / z);
	double tmp;
	if (x <= -65.0) {
		tmp = t_0;
	} else if (x <= 1.4) {
		tmp = (y / z) / x;
	} else if ((x <= 1.95e+100) || !(x <= 5.4e+237)) {
		tmp = t_0;
	} else {
		tmp = 0.5 * (y / (z / x));
	}
	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 * x) * (0.5d0 / z)
    if (x <= (-65.0d0)) then
        tmp = t_0
    else if (x <= 1.4d0) then
        tmp = (y / z) / x
    else if ((x <= 1.95d+100) .or. (.not. (x <= 5.4d+237))) then
        tmp = t_0
    else
        tmp = 0.5d0 * (y / (z / x))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (y * x) * (0.5 / z);
	double tmp;
	if (x <= -65.0) {
		tmp = t_0;
	} else if (x <= 1.4) {
		tmp = (y / z) / x;
	} else if ((x <= 1.95e+100) || !(x <= 5.4e+237)) {
		tmp = t_0;
	} else {
		tmp = 0.5 * (y / (z / x));
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (y * x) * (0.5 / z)
	tmp = 0
	if x <= -65.0:
		tmp = t_0
	elif x <= 1.4:
		tmp = (y / z) / x
	elif (x <= 1.95e+100) or not (x <= 5.4e+237):
		tmp = t_0
	else:
		tmp = 0.5 * (y / (z / x))
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(y * x) * Float64(0.5 / z))
	tmp = 0.0
	if (x <= -65.0)
		tmp = t_0;
	elseif (x <= 1.4)
		tmp = Float64(Float64(y / z) / x);
	elseif ((x <= 1.95e+100) || !(x <= 5.4e+237))
		tmp = t_0;
	else
		tmp = Float64(0.5 * Float64(y / Float64(z / x)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (y * x) * (0.5 / z);
	tmp = 0.0;
	if (x <= -65.0)
		tmp = t_0;
	elseif (x <= 1.4)
		tmp = (y / z) / x;
	elseif ((x <= 1.95e+100) || ~((x <= 5.4e+237)))
		tmp = t_0;
	else
		tmp = 0.5 * (y / (z / x));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y * x), $MachinePrecision] * N[(0.5 / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -65.0], t$95$0, If[LessEqual[x, 1.4], N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision], If[Or[LessEqual[x, 1.95e+100], N[Not[LessEqual[x, 5.4e+237]], $MachinePrecision]], t$95$0, N[(0.5 * N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(y \cdot x\right) \cdot \frac{0.5}{z}\\
\mathbf{if}\;x \leq -65:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1.4:\\
\;\;\;\;\frac{\frac{y}{z}}{x}\\

\mathbf{elif}\;x \leq 1.95 \cdot 10^{+100} \lor \neg \left(x \leq 5.4 \cdot 10^{+237}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -65 or 1.3999999999999999 < x < 1.95e100 or 5.3999999999999999e237 < x

    1. Initial program 81.5%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Taylor expanded in x around 0 40.0%

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.5 \cdot \left(y \cdot x\right)}{z}} \]
    6. Step-by-step derivation
      1. associate-/l*40.0%

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

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

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

    if -65 < x < 1.3999999999999999

    1. Initial program 89.8%

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

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

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

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

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

        \[\leadsto \frac{\cosh x}{\frac{\color{blue}{x \cdot z}}{y}} \]
      4. expm1-log1p-u62.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{y}{z}}{x}} \]
    12. Simplified97.8%

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

    if 1.95e100 < x < 5.3999999999999999e237

    1. Initial program 68.0%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Taylor expanded in x around 0 35.2%

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

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

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

        \[\leadsto \frac{0.5 \cdot \color{blue}{\left(y \cdot x\right)}}{z} \]
    5. Simplified35.2%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -65:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{0.5}{z}\\ \mathbf{elif}\;x \leq 1.4:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{+100} \lor \neg \left(x \leq 5.4 \cdot 10^{+237}\right):\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{0.5}{z}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{z}{x}}\\ \end{array} \]

Alternative 5: 65.6% accurate, 7.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-123}:\\ \;\;\;\;y \cdot \left(0.5 \cdot \frac{x}{z} + \frac{1}{x \cdot z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(y \cdot x\right)}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -2e-123)
   (* y (+ (* 0.5 (/ x z)) (/ 1.0 (* x z))))
   (/ (+ (/ y x) (* 0.5 (* y x))) z)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -2e-123) {
		tmp = y * ((0.5 * (x / z)) + (1.0 / (x * z)));
	} else {
		tmp = ((y / x) + (0.5 * (y * x))) / z;
	}
	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) :: tmp
    if (y <= (-2d-123)) then
        tmp = y * ((0.5d0 * (x / z)) + (1.0d0 / (x * z)))
    else
        tmp = ((y / x) + (0.5d0 * (y * x))) / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -2e-123) {
		tmp = y * ((0.5 * (x / z)) + (1.0 / (x * z)));
	} else {
		tmp = ((y / x) + (0.5 * (y * x))) / z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -2e-123:
		tmp = y * ((0.5 * (x / z)) + (1.0 / (x * z)))
	else:
		tmp = ((y / x) + (0.5 * (y * x))) / z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -2e-123)
		tmp = Float64(y * Float64(Float64(0.5 * Float64(x / z)) + Float64(1.0 / Float64(x * z))));
	else
		tmp = Float64(Float64(Float64(y / x) + Float64(0.5 * Float64(y * x))) / z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -2e-123)
		tmp = y * ((0.5 * (x / z)) + (1.0 / (x * z)));
	else
		tmp = ((y / x) + (0.5 * (y * x))) / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -2e-123], N[(y * N[(N[(0.5 * N[(x / z), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y / x), $MachinePrecision] + N[(0.5 * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-123}:\\
\;\;\;\;y \cdot \left(0.5 \cdot \frac{x}{z} + \frac{1}{x \cdot z}\right)\\

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


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

    1. Initial program 88.0%

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

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

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

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

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

        \[\leadsto \frac{\cosh x}{\frac{\color{blue}{x \cdot z}}{y}} \]
      4. expm1-log1p-u51.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-123 < y

    1. Initial program 81.4%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Taylor expanded in x around 0 59.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-123}:\\ \;\;\;\;y \cdot \left(0.5 \cdot \frac{x}{z} + \frac{1}{x \cdot z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(y \cdot x\right)}{z}\\ \end{array} \]

Alternative 6: 61.3% accurate, 9.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -65 \lor \neg \left(x \leq 6200\right):\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -65.0) (not (<= x 6200.0)))
   (* 0.5 (* x (/ y z)))
   (/ (/ y z) x)))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -65.0) || !(x <= 6200.0)) {
		tmp = 0.5 * (x * (y / z));
	} else {
		tmp = (y / z) / x;
	}
	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) :: tmp
    if ((x <= (-65.0d0)) .or. (.not. (x <= 6200.0d0))) then
        tmp = 0.5d0 * (x * (y / z))
    else
        tmp = (y / z) / x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -65.0) || !(x <= 6200.0)) {
		tmp = 0.5 * (x * (y / z));
	} else {
		tmp = (y / z) / x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -65.0) or not (x <= 6200.0):
		tmp = 0.5 * (x * (y / z))
	else:
		tmp = (y / z) / x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -65.0) || !(x <= 6200.0))
		tmp = Float64(0.5 * Float64(x * Float64(y / z)));
	else
		tmp = Float64(Float64(y / z) / x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -65.0) || ~((x <= 6200.0)))
		tmp = 0.5 * (x * (y / z));
	else
		tmp = (y / z) / x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -65.0], N[Not[LessEqual[x, 6200.0]], $MachinePrecision]], N[(0.5 * N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -65 \lor \neg \left(x \leq 6200\right):\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{z}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -65 or 6200 < x

    1. Initial program 79.0%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Taylor expanded in x around 0 39.4%

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.5 \cdot \left(y \cdot x\right)}{z}} \]
    6. Step-by-step derivation
      1. associate-/l*39.4%

        \[\leadsto \color{blue}{\frac{0.5}{\frac{z}{y \cdot x}}} \]
      2. div-inv39.4%

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

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{1}{\frac{z}{y}} \cdot x\right)} \]
      3. clear-num29.5%

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

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

    if -65 < x < 6200

    1. Initial program 89.9%

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

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

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

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

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

        \[\leadsto \frac{\cosh x}{\frac{\color{blue}{x \cdot z}}{y}} \]
      4. expm1-log1p-u62.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{y}{z}}{x}} \]
    12. Simplified97.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -65 \lor \neg \left(x \leq 6200\right):\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \end{array} \]

Alternative 7: 64.9% accurate, 9.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -65 \lor \neg \left(x \leq 6200\right):\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -65.0) (not (<= x 6200.0)))
   (* 0.5 (/ y (/ z x)))
   (/ (/ y z) x)))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -65.0) || !(x <= 6200.0)) {
		tmp = 0.5 * (y / (z / x));
	} else {
		tmp = (y / z) / x;
	}
	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) :: tmp
    if ((x <= (-65.0d0)) .or. (.not. (x <= 6200.0d0))) then
        tmp = 0.5d0 * (y / (z / x))
    else
        tmp = (y / z) / x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -65.0) || !(x <= 6200.0)) {
		tmp = 0.5 * (y / (z / x));
	} else {
		tmp = (y / z) / x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -65.0) or not (x <= 6200.0):
		tmp = 0.5 * (y / (z / x))
	else:
		tmp = (y / z) / x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -65.0) || !(x <= 6200.0))
		tmp = Float64(0.5 * Float64(y / Float64(z / x)));
	else
		tmp = Float64(Float64(y / z) / x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -65.0) || ~((x <= 6200.0)))
		tmp = 0.5 * (y / (z / x));
	else
		tmp = (y / z) / x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -65.0], N[Not[LessEqual[x, 6200.0]], $MachinePrecision]], N[(0.5 * N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -65 \lor \neg \left(x \leq 6200\right):\\
\;\;\;\;0.5 \cdot \frac{y}{\frac{z}{x}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -65 or 6200 < x

    1. Initial program 79.0%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Taylor expanded in x around 0 39.4%

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

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

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

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

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

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

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

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

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

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

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

    if -65 < x < 6200

    1. Initial program 89.9%

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

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

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

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

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

        \[\leadsto \frac{\cosh x}{\frac{\color{blue}{x \cdot z}}{y}} \]
      4. expm1-log1p-u62.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{y}{z}}{x}} \]
    12. Simplified97.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -65 \lor \neg \left(x \leq 6200\right):\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \end{array} \]

Alternative 8: 65.7% accurate, 9.7× speedup?

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

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

    \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
  2. Taylor expanded in x around 0 61.3%

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

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

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

Alternative 9: 65.8% accurate, 9.7× speedup?

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

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

    \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
  2. Taylor expanded in x around 0 61.3%

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

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

Alternative 10: 50.6% accurate, 15.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-66}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -2e-66) (/ y (* x z)) (/ (/ y x) z)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -2e-66) {
		tmp = y / (x * z);
	} else {
		tmp = (y / x) / z;
	}
	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) :: tmp
    if (y <= (-2d-66)) then
        tmp = y / (x * z)
    else
        tmp = (y / x) / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -2e-66) {
		tmp = y / (x * z);
	} else {
		tmp = (y / x) / z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -2e-66:
		tmp = y / (x * z)
	else:
		tmp = (y / x) / z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -2e-66)
		tmp = Float64(y / Float64(x * z));
	else
		tmp = Float64(Float64(y / x) / z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -2e-66)
		tmp = y / (x * z);
	else
		tmp = (y / x) / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -2e-66], N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision], N[(N[(y / x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-66}:\\
\;\;\;\;\frac{y}{x \cdot z}\\

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


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

    1. Initial program 87.8%

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

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

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

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

    if -2e-66 < y

    1. Initial program 81.9%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Taylor expanded in x around 0 46.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-66}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \]

Alternative 11: 49.2% accurate, 21.4× speedup?

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

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

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

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

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

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

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

Alternative 12: 52.7% accurate, 21.4× speedup?

\[\begin{array}{l} \\ \frac{\frac{y}{z}}{x} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (/ y z) x))
double code(double x, double y, double z) {
	return (y / z) / x;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (y / z) / x
end function
public static double code(double x, double y, double z) {
	return (y / z) / x;
}
def code(x, y, z):
	return (y / z) / x
function code(x, y, z)
	return Float64(Float64(y / z) / x)
end
function tmp = code(x, y, z)
	tmp = (y / z) / x;
end
code[x_, y_, z_] := N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{y}{z}}{x}
\end{array}
Derivation
  1. Initial program 83.8%

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

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

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

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

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

      \[\leadsto \frac{\cosh x}{\frac{\color{blue}{x \cdot z}}{y}} \]
    4. expm1-log1p-u43.4%

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

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

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\cosh x \cdot y}{x \cdot z}}\right)} - 1 \]
    7. times-frac46.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{y}{z}}{x}} \]
  12. Simplified51.4%

    \[\leadsto \color{blue}{\frac{\frac{y}{z}}{x}} \]
  13. Final simplification51.4%

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

Developer target: 97.0% accurate, 1.0× 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 2023305 
(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))