Linear.Quaternion:$ctanh from linear-1.19.1.3

Percentage Accurate: 96.2% → 99.6%
Time: 9.9s
Alternatives: 12
Speedup: 1.0×

Specification

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

\\
\frac{x \cdot \frac{\sin y}{y}}{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: 96.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.6% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.99999999999999984e78 or 0.012 < z

    1. Initial program 99.8%

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

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

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

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

    if -4.99999999999999984e78 < z < 0.012

    1. Initial program 91.9%

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

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

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

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

Alternative 2: 99.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{+78} \lor \neg \left(z \leq 0.24\right):\\
\;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.99999999999999964e78 or 0.23999999999999999 < z

    1. Initial program 99.8%

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

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

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

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

    if -5.99999999999999964e78 < z < 0.23999999999999999

    1. Initial program 91.9%

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{\frac{\sin y}{y}}}} \]
    4. Step-by-step derivation
      1. clear-num99.6%

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

        \[\leadsto \frac{x}{\color{blue}{\frac{1}{\frac{\sin y}{y}} \cdot z}} \]
      3. clear-num99.7%

        \[\leadsto \frac{x}{\color{blue}{\frac{y}{\sin y}} \cdot z} \]
    5. Applied egg-rr99.7%

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

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

Alternative 3: 77.6% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 96.8%

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x}{y}}{\frac{z}{\sin y}}} \]
      4. associate-/r/81.3%

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

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

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

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

    if 2.39999999999999998e-8 < y

    1. Initial program 90.8%

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x}{y}}{\frac{z}{\sin y}}} \]
      4. associate-/r/91.0%

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

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

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

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

Alternative 4: 97.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
\mathbf{if}\;x \leq -2.9 \cdot 10^{+64}:\\
\;\;\;\;\frac{x \cdot t_0}{z}\\

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


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

    1. Initial program 99.6%

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

    if -2.89999999999999993e64 < x

    1. Initial program 94.0%

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

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

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

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

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

Alternative 5: 96.0% accurate, 1.0× speedup?

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\sin y}{y} \cdot \frac{x}{z}} \]
  4. Final simplification96.1%

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

Alternative 6: 62.8% accurate, 9.7× speedup?

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

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

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


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

    1. Initial program 96.8%

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x}{y}}{\frac{z}{\sin y}}} \]
      4. associate-/r/81.3%

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

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

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

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

    if 2.5 < y

    1. Initial program 90.8%

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

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

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

      \[\leadsto \frac{x}{\color{blue}{z + 0.16666666666666666 \cdot \left({y}^{2} \cdot z\right)}} \]
    5. Step-by-step derivation
      1. *-commutative32.4%

        \[\leadsto \frac{x}{z + 0.16666666666666666 \cdot \color{blue}{\left(z \cdot {y}^{2}\right)}} \]
      2. unpow232.4%

        \[\leadsto \frac{x}{z + 0.16666666666666666 \cdot \left(z \cdot \color{blue}{\left(y \cdot y\right)}\right)} \]
    6. Simplified32.4%

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

      \[\leadsto \color{blue}{6 \cdot \frac{x}{{y}^{2} \cdot z}} \]
    8. Step-by-step derivation
      1. unpow232.4%

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

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

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

        \[\leadsto 6 \cdot \frac{\frac{x}{y}}{\color{blue}{z \cdot y}} \]
    9. Simplified32.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2.5:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \frac{\frac{x}{y}}{y \cdot z}\\ \end{array} \]

Alternative 7: 62.8% accurate, 9.7× speedup?

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

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

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


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

    1. Initial program 96.8%

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x}{y}}{\frac{z}{\sin y}}} \]
      4. associate-/r/81.3%

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

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

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

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

    if 2.5 < y

    1. Initial program 90.8%

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

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

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

      \[\leadsto \frac{x}{\color{blue}{z + 0.16666666666666666 \cdot \left({y}^{2} \cdot z\right)}} \]
    5. Step-by-step derivation
      1. *-commutative32.4%

        \[\leadsto \frac{x}{z + 0.16666666666666666 \cdot \color{blue}{\left(z \cdot {y}^{2}\right)}} \]
      2. unpow232.4%

        \[\leadsto \frac{x}{z + 0.16666666666666666 \cdot \left(z \cdot \color{blue}{\left(y \cdot y\right)}\right)} \]
    6. Simplified32.4%

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

      \[\leadsto \color{blue}{6 \cdot \frac{x}{{y}^{2} \cdot z}} \]
    8. Step-by-step derivation
      1. unpow232.4%

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

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

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

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

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

        \[\leadsto \frac{6 \cdot x}{\color{blue}{z \cdot \left(y \cdot y\right)}} \]
    9. Simplified32.4%

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

        \[\leadsto \frac{6 \cdot x}{\color{blue}{\left(z \cdot y\right) \cdot y}} \]
      2. times-frac32.4%

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

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

      \[\leadsto \color{blue}{\frac{6}{y \cdot z} \cdot \frac{x}{y}} \]
    12. Taylor expanded in y around 0 32.4%

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

        \[\leadsto 6 \cdot \color{blue}{\frac{\frac{x}{{y}^{2}}}{z}} \]
      2. unpow232.5%

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

        \[\leadsto 6 \cdot \frac{\color{blue}{\frac{\frac{x}{y}}{y}}}{z} \]
    14. Simplified32.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2.5:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \frac{\frac{\frac{x}{y}}{y}}{z}\\ \end{array} \]

Alternative 8: 62.9% accurate, 9.7× speedup?

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

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

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


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

    1. Initial program 96.8%

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x}{y}}{\frac{z}{\sin y}}} \]
      4. associate-/r/81.3%

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

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

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

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

    if 2.5 < y

    1. Initial program 90.8%

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

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

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

      \[\leadsto \frac{x}{\color{blue}{z + 0.16666666666666666 \cdot \left({y}^{2} \cdot z\right)}} \]
    5. Step-by-step derivation
      1. *-commutative32.4%

        \[\leadsto \frac{x}{z + 0.16666666666666666 \cdot \color{blue}{\left(z \cdot {y}^{2}\right)}} \]
      2. unpow232.4%

        \[\leadsto \frac{x}{z + 0.16666666666666666 \cdot \left(z \cdot \color{blue}{\left(y \cdot y\right)}\right)} \]
    6. Simplified32.4%

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

      \[\leadsto \color{blue}{6 \cdot \frac{x}{{y}^{2} \cdot z}} \]
    8. Step-by-step derivation
      1. unpow232.4%

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

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

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

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

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

        \[\leadsto \frac{6 \cdot x}{\color{blue}{z \cdot \left(y \cdot y\right)}} \]
    9. Simplified32.4%

      \[\leadsto \color{blue}{\frac{6 \cdot x}{z \cdot \left(y \cdot y\right)}} \]
    10. Step-by-step derivation
      1. *-commutative32.4%

        \[\leadsto \frac{\color{blue}{x \cdot 6}}{z \cdot \left(y \cdot y\right)} \]
      2. times-frac33.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2.5:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{6}{y \cdot y}\\ \end{array} \]

Alternative 9: 63.0% accurate, 9.7× speedup?

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

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

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


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

    1. Initial program 96.8%

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x}{y}}{\frac{z}{\sin y}}} \]
      4. associate-/r/81.3%

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

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

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

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

    if 2.5 < y

    1. Initial program 90.8%

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

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

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

      \[\leadsto \frac{x}{\color{blue}{z + 0.16666666666666666 \cdot \left({y}^{2} \cdot z\right)}} \]
    5. Step-by-step derivation
      1. *-commutative32.4%

        \[\leadsto \frac{x}{z + 0.16666666666666666 \cdot \color{blue}{\left(z \cdot {y}^{2}\right)}} \]
      2. unpow232.4%

        \[\leadsto \frac{x}{z + 0.16666666666666666 \cdot \left(z \cdot \color{blue}{\left(y \cdot y\right)}\right)} \]
    6. Simplified32.4%

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

      \[\leadsto \color{blue}{6 \cdot \frac{x}{{y}^{2} \cdot z}} \]
    8. Step-by-step derivation
      1. unpow232.4%

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

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

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

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

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

        \[\leadsto \frac{6 \cdot x}{\color{blue}{z \cdot \left(y \cdot y\right)}} \]
    9. Simplified32.4%

      \[\leadsto \color{blue}{\frac{6 \cdot x}{z \cdot \left(y \cdot y\right)}} \]
    10. Step-by-step derivation
      1. *-commutative32.4%

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

        \[\leadsto \frac{x \cdot 6}{\color{blue}{\left(z \cdot y\right) \cdot y}} \]
      3. times-frac33.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2.5:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot z} \cdot \frac{6}{y}\\ \end{array} \]

Alternative 10: 63.0% accurate, 9.7× speedup?

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

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

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


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

    1. Initial program 96.8%

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x}{y}}{\frac{z}{\sin y}}} \]
      4. associate-/r/81.3%

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

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

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

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

    if 2.5 < y

    1. Initial program 90.8%

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

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

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

      \[\leadsto \frac{x}{\color{blue}{z + 0.16666666666666666 \cdot \left({y}^{2} \cdot z\right)}} \]
    5. Step-by-step derivation
      1. *-commutative32.4%

        \[\leadsto \frac{x}{z + 0.16666666666666666 \cdot \color{blue}{\left(z \cdot {y}^{2}\right)}} \]
      2. unpow232.4%

        \[\leadsto \frac{x}{z + 0.16666666666666666 \cdot \left(z \cdot \color{blue}{\left(y \cdot y\right)}\right)} \]
    6. Simplified32.4%

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

      \[\leadsto \color{blue}{6 \cdot \frac{x}{{y}^{2} \cdot z}} \]
    8. Step-by-step derivation
      1. unpow232.4%

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

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

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

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

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

        \[\leadsto \frac{6 \cdot x}{\color{blue}{z \cdot \left(y \cdot y\right)}} \]
    9. Simplified32.4%

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

        \[\leadsto \frac{6 \cdot x}{\color{blue}{\left(z \cdot y\right) \cdot y}} \]
      2. times-frac32.4%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{6}{y \cdot z}} \]
      2. clear-num32.4%

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

        \[\leadsto \frac{1}{\frac{y}{x}} \cdot \color{blue}{\frac{\frac{6}{y}}{z}} \]
      4. frac-times33.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2.5:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{6}{y}}{z \cdot \frac{y}{x}}\\ \end{array} \]

Alternative 11: 66.9% accurate, 9.7× speedup?

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{\frac{\sin y}{y}}}} \]
  3. Simplified94.9%

    \[\leadsto \color{blue}{\frac{x}{\frac{z}{\frac{\sin y}{y}}}} \]
  4. Step-by-step derivation
    1. clear-num94.8%

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

      \[\leadsto \frac{x}{\color{blue}{\frac{1}{\frac{\sin y}{y}} \cdot z}} \]
    3. clear-num94.9%

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

    \[\leadsto \frac{x}{\color{blue}{\frac{y}{\sin y} \cdot z}} \]
  6. Taylor expanded in y around 0 66.0%

    \[\leadsto \frac{x}{\color{blue}{\left(1 + 0.16666666666666666 \cdot {y}^{2}\right)} \cdot z} \]
  7. Step-by-step derivation
    1. *-commutative66.0%

      \[\leadsto \frac{x}{\left(1 + \color{blue}{{y}^{2} \cdot 0.16666666666666666}\right) \cdot z} \]
    2. unpow266.0%

      \[\leadsto \frac{x}{\left(1 + \color{blue}{\left(y \cdot y\right)} \cdot 0.16666666666666666\right) \cdot z} \]
  8. Simplified66.0%

    \[\leadsto \frac{x}{\color{blue}{\left(1 + \left(y \cdot y\right) \cdot 0.16666666666666666\right)} \cdot z} \]
  9. Final simplification66.0%

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

Alternative 12: 59.0% accurate, 35.7× speedup?

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{x}{y}}{\frac{z}{\sin y}}} \]
    4. associate-/r/83.7%

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

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

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

    \[\leadsto \color{blue}{\frac{x}{z}} \]
  5. Final simplification60.5%

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

Developer target: 99.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{\sin y}\\ t_1 := \frac{x \cdot \frac{1}{t_0}}{z}\\ \mathbf{if}\;z < -4.2173720203427147 \cdot 10^{-29}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z < 4.446702369113811 \cdot 10^{+64}:\\ \;\;\;\;\frac{x}{z \cdot t_0}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ y (sin y))) (t_1 (/ (* x (/ 1.0 t_0)) z)))
   (if (< z -4.2173720203427147e-29)
     t_1
     (if (< z 4.446702369113811e+64) (/ x (* z t_0)) t_1))))
double code(double x, double y, double z) {
	double t_0 = y / sin(y);
	double t_1 = (x * (1.0 / t_0)) / z;
	double tmp;
	if (z < -4.2173720203427147e-29) {
		tmp = t_1;
	} else if (z < 4.446702369113811e+64) {
		tmp = x / (z * t_0);
	} else {
		tmp = t_1;
	}
	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) :: t_1
    real(8) :: tmp
    t_0 = y / sin(y)
    t_1 = (x * (1.0d0 / t_0)) / z
    if (z < (-4.2173720203427147d-29)) then
        tmp = t_1
    else if (z < 4.446702369113811d+64) then
        tmp = x / (z * t_0)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y / Math.sin(y);
	double t_1 = (x * (1.0 / t_0)) / z;
	double tmp;
	if (z < -4.2173720203427147e-29) {
		tmp = t_1;
	} else if (z < 4.446702369113811e+64) {
		tmp = x / (z * t_0);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y / math.sin(y)
	t_1 = (x * (1.0 / t_0)) / z
	tmp = 0
	if z < -4.2173720203427147e-29:
		tmp = t_1
	elif z < 4.446702369113811e+64:
		tmp = x / (z * t_0)
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(y / sin(y))
	t_1 = Float64(Float64(x * Float64(1.0 / t_0)) / z)
	tmp = 0.0
	if (z < -4.2173720203427147e-29)
		tmp = t_1;
	elseif (z < 4.446702369113811e+64)
		tmp = Float64(x / Float64(z * t_0));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y / sin(y);
	t_1 = (x * (1.0 / t_0)) / z;
	tmp = 0.0;
	if (z < -4.2173720203427147e-29)
		tmp = t_1;
	elseif (z < 4.446702369113811e+64)
		tmp = x / (z * t_0);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[Less[z, -4.2173720203427147e-29], t$95$1, If[Less[z, 4.446702369113811e+64], N[(x / N[(z * t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{y}{\sin y}\\
t_1 := \frac{x \cdot \frac{1}{t_0}}{z}\\
\mathbf{if}\;z < -4.2173720203427147 \cdot 10^{-29}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z < 4.446702369113811 \cdot 10^{+64}:\\
\;\;\;\;\frac{x}{z \cdot t_0}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023271 
(FPCore (x y z)
  :name "Linear.Quaternion:$ctanh from linear-1.19.1.3"
  :precision binary64

  :herbie-target
  (if (< z -4.2173720203427147e-29) (/ (* x (/ 1.0 (/ y (sin y)))) z) (if (< z 4.446702369113811e+64) (/ x (* z (/ y (sin y)))) (/ (* x (/ 1.0 (/ y (sin y)))) z)))

  (/ (* x (/ (sin y) y)) z))