Linear.Quaternion:$ctan from linear-1.19.1.3

Percentage Accurate: 84.5% → 96.4%
Time: 11.5s
Alternatives: 13
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 13 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: 96.4% accurate, 1.0× speedup?

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

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

    \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
  2. Step-by-step derivation
    1. *-commutative81.5%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 68.1% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;x \leq 3.15 \cdot 10^{+237}:\\
\;\;\;\;y \cdot \frac{\cosh x}{x \cdot z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.25000000000000003e-147

    1. Initial program 80.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.25000000000000003e-147 < x < 3.15000000000000004e237

    1. Initial program 86.7%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. *-commutative86.7%

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

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

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

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

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

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

    if 3.15000000000000004e237 < x

    1. Initial program 61.5%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. *-commutative61.5%

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

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

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

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

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

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

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

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

Alternative 3: 90.9% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

Alternative 4: 66.0% accurate, 5.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.2 \cdot 10^{+187}:\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{z} + \frac{y}{z} \cdot \frac{1}{x}\\

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


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

    1. Initial program 83.4%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. *-commutative83.4%

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{x \cdot y}{z} + \frac{\color{blue}{y \cdot 1}}{x \cdot z} \]
      2. *-commutative67.4%

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

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

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

    if 7.20000000000000072e187 < x

    1. Initial program 64.0%

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

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

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

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

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

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

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

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

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

Alternative 5: 59.2% accurate, 5.9× speedup?

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

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

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


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

    1. Initial program 80.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.50000000000000034e-149 < x

    1. Initial program 83.5%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. *-commutative83.5%

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

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

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

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

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

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

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

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

Alternative 6: 59.0% accurate, 5.9× speedup?

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

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

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


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

    1. Initial program 80.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.99999999999999998e-148 < x

    1. Initial program 83.5%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. *-commutative83.5%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(y \cdot \left(x \cdot \frac{1}{z}\right)\right)} + \frac{y}{x \cdot z} \]
    8. Step-by-step derivation
      1. un-div-inv61.1%

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

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

      \[\leadsto 0.5 \cdot \left(y \cdot \color{blue}{\frac{1}{\frac{z}{x}}}\right) + \frac{y}{x \cdot z} \]
    10. Step-by-step derivation
      1. un-div-inv61.1%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{y}{\frac{z}{x}}} + \frac{y}{x \cdot z} \]
    11. Applied egg-rr61.1%

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

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

Alternative 7: 67.2% accurate, 5.9× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{y}{x \cdot z}\\
\mathbf{if}\;z \leq 2 \cdot 10^{-72}:\\
\;\;\;\;0.5 \cdot \frac{y}{\frac{z}{x}} + t\_0\\

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


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

    1. Initial program 81.4%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. *-commutative81.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(y \cdot \left(x \cdot \frac{1}{z}\right)\right)} + \frac{y}{x \cdot z} \]
    8. Step-by-step derivation
      1. un-div-inv73.3%

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

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

      \[\leadsto 0.5 \cdot \left(y \cdot \color{blue}{\frac{1}{\frac{z}{x}}}\right) + \frac{y}{x \cdot z} \]
    10. Step-by-step derivation
      1. un-div-inv73.3%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{y}{\frac{z}{x}}} + \frac{y}{x \cdot z} \]
    11. Applied egg-rr73.3%

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

    if 1.9999999999999999e-72 < z

    1. Initial program 81.6%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. *-commutative81.6%

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

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

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

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

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

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

      \[\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 simplification69.1%

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

Alternative 8: 63.8% accurate, 6.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 520000:\\
\;\;\;\;\frac{y}{z} \cdot \left(\frac{1}{x} + x \cdot 0.5\right)\\

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


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

    1. Initial program 81.9%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. *-commutative81.9%

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{x \cdot y}{z} + \frac{\color{blue}{y \cdot 1}}{x \cdot z} \]
      2. *-commutative75.7%

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

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

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{z} + \color{blue}{\frac{y}{z} \cdot \frac{1}{x}} \]
    8. Taylor expanded in x around 0 75.7%

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{z} + \frac{y}{x \cdot z}} \]
    9. Step-by-step derivation
      1. *-commutative75.7%

        \[\leadsto 0.5 \cdot \frac{x \cdot y}{z} + \frac{y}{\color{blue}{z \cdot x}} \]
      2. +-commutative75.7%

        \[\leadsto \color{blue}{\frac{y}{z \cdot x} + 0.5 \cdot \frac{x \cdot y}{z}} \]
      3. *-rgt-identity75.7%

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

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

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

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

        \[\leadsto \frac{y}{z} \cdot \color{blue}{\frac{-1}{-1 \cdot x}} + 0.5 \cdot \frac{x \cdot y}{z} \]
      8. neg-mul-178.3%

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

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

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

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

        \[\leadsto \frac{y}{z} \cdot \frac{-1}{-x} + \color{blue}{\frac{y}{z} \cdot \left(x \cdot 0.5\right)} \]
      13. distribute-lft-out76.3%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot \left(\frac{-1}{-x} + x \cdot 0.5\right)} \]
      14. neg-mul-176.3%

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

        \[\leadsto \frac{y}{z} \cdot \left(\color{blue}{\frac{\frac{-1}{-1}}{x}} + x \cdot 0.5\right) \]
      16. metadata-eval76.3%

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

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

    if 5.2e5 < x

    1. Initial program 80.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 59.3% accurate, 8.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.4:\\
\;\;\;\;\frac{\frac{y}{z}}{x}\\

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


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

    1. Initial program 81.7%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. *-commutative81.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.3999999999999999 < x

    1. Initial program 80.9%

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

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

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

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

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

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

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

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

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

Alternative 10: 59.3% accurate, 8.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.4:\\
\;\;\;\;\frac{\frac{y}{z}}{x}\\

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


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

    1. Initial program 81.7%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. *-commutative81.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.3999999999999999 < x

    1. Initial program 80.9%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. *-commutative80.9%

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{x \cdot y}{z} + \frac{\color{blue}{y \cdot 1}}{x \cdot z} \]
      2. *-commutative39.0%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 50.6% accurate, 10.7× speedup?

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

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

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


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

    1. Initial program 82.8%

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

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

    if 4.9999999999999999e-20 < z

    1. Initial program 78.1%

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

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

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

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

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

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

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

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

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

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

    \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
  2. Step-by-step derivation
    1. *-commutative81.5%

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

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

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

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

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

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

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

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

Alternative 13: 53.2% 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 81.5%

    \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
  2. Step-by-step derivation
    1. *-commutative81.5%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{y}{z}}}{x} \]
  8. Final simplification56.0%

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

Developer target: 96.9% 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 2024041 
(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))