Linear.Quaternion:$ctanh from linear-1.19.1.3

Percentage Accurate: 95.9% → 96.2%
Time: 10.0s
Alternatives: 7
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 7 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: 95.9% 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: 96.2% accurate, 1.0× speedup?

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

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

    \[\frac{x \cdot \frac{\sin y}{y}}{z} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \frac{x \cdot \frac{1}{\frac{y}{\sin y}}}{z} \]
    2. un-div-invN/A

      \[\leadsto \frac{\frac{x}{\frac{y}{\sin y}}}{z} \]
    3. associate-/l/N/A

      \[\leadsto \frac{x}{\color{blue}{z \cdot \frac{y}{\sin y}}} \]
    4. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(x, \color{blue}{\left(z \cdot \frac{y}{\sin y}\right)}\right) \]
    5. clear-numN/A

      \[\leadsto \mathsf{/.f64}\left(x, \left(z \cdot \frac{1}{\color{blue}{\frac{\sin y}{y}}}\right)\right) \]
    6. div-invN/A

      \[\leadsto \mathsf{/.f64}\left(x, \left(\frac{z}{\color{blue}{\frac{\sin y}{y}}}\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(x, \mathsf{/.f64}\left(z, \color{blue}{\left(\frac{\sin y}{y}\right)}\right)\right) \]
    8. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(x, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(\sin y, \color{blue}{y}\right)\right)\right) \]
    9. sin-lowering-sin.f6498.4%

      \[\leadsto \mathsf{/.f64}\left(x, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(\mathsf{sin.f64}\left(y\right), y\right)\right)\right) \]
  4. Applied egg-rr98.4%

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

Alternative 2: 75.7% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 96.7%

      \[\frac{x \cdot \frac{\sin y}{y}}{z} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{\sin y}{y}\right), \color{blue}{z}\right) \]
      2. associate-*r/N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{x \cdot \sin y}{y}\right), z\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \sin y\right), y\right), z\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \sin y\right), y\right), z\right) \]
      5. sin-lowering-sin.f6486.5%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{sin.f64}\left(y\right)\right), y\right), z\right) \]
    3. Simplified86.5%

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \color{blue}{\left(y \cdot \left(1 + \frac{-1}{6} \cdot {y}^{2}\right)\right)}\right), y\right), z\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \left(1 + \frac{-1}{6} \cdot {y}^{2}\right)\right)\right), y\right), z\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \left(\frac{-1}{6} \cdot {y}^{2}\right)\right)\right)\right), y\right), z\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \left(\frac{-1}{6} \cdot \left(y \cdot y\right)\right)\right)\right)\right), y\right), z\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \left(\left(\frac{-1}{6} \cdot y\right) \cdot y\right)\right)\right)\right), y\right), z\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \left(y \cdot \left(\frac{-1}{6} \cdot y\right)\right)\right)\right)\right), y\right), z\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \left(\frac{-1}{6} \cdot y\right)\right)\right)\right)\right), y\right), z\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \left(y \cdot \frac{-1}{6}\right)\right)\right)\right)\right), y\right), z\right) \]
      8. *-lowering-*.f6460.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \frac{-1}{6}\right)\right)\right)\right)\right), y\right), z\right) \]
    7. Simplified60.8%

      \[\leadsto \frac{\frac{x \cdot \color{blue}{\left(y \cdot \left(1 + y \cdot \left(y \cdot -0.16666666666666666\right)\right)\right)}}{y}}{z} \]
    8. Step-by-step derivation
      1. associate-/l/N/A

        \[\leadsto \frac{x \cdot \left(y \cdot \left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right)\right)}{\color{blue}{z \cdot y}} \]
      2. times-fracN/A

        \[\leadsto \frac{x}{z} \cdot \color{blue}{\frac{y \cdot \left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right)}{y}} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x}{z}\right), \color{blue}{\left(\frac{y \cdot \left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right)}{y}\right)}\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \left(\frac{\color{blue}{y \cdot \left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right)}}{y}\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \left(\frac{\left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right) \cdot y}{y}\right)\right) \]
      6. associate-/l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \left(\left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right) \cdot \color{blue}{\frac{y}{y}}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{*.f64}\left(\left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right), \color{blue}{\left(\frac{y}{y}\right)}\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(y \cdot \left(y \cdot \frac{-1}{6}\right)\right)\right), \left(\frac{\color{blue}{y}}{y}\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \left(y \cdot \frac{-1}{6}\right)\right)\right), \left(\frac{y}{y}\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \frac{-1}{6}\right)\right)\right), \left(\frac{y}{y}\right)\right)\right) \]
      11. /-lowering-/.f6472.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \frac{-1}{6}\right)\right)\right), \mathsf{/.f64}\left(y, \color{blue}{y}\right)\right)\right) \]
    9. Applied egg-rr72.0%

      \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(\left(1 + y \cdot \left(y \cdot -0.16666666666666666\right)\right) \cdot \frac{y}{y}\right)} \]
    10. Step-by-step derivation
      1. *-inversesN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \left(\left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right) \cdot 1\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \left(1 \cdot \color{blue}{\left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right)}\right)\right) \]
      3. *-lft-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \left(1 + \color{blue}{y \cdot \left(y \cdot \frac{-1}{6}\right)}\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \left(y \cdot \left(y \cdot \frac{-1}{6}\right) + \color{blue}{1}\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{+.f64}\left(\left(y \cdot \left(y \cdot \frac{-1}{6}\right)\right), \color{blue}{1}\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(y, \left(y \cdot \frac{-1}{6}\right)\right), 1\right)\right) \]
      7. *-lowering-*.f6472.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \frac{-1}{6}\right)\right), 1\right)\right) \]
    11. Applied egg-rr72.0%

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

    if 1.9000000000000001e-4 < y

    1. Initial program 92.1%

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

        \[\leadsto \frac{\frac{x \cdot \sin y}{y}}{z} \]
      2. associate-/l/N/A

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

        \[\leadsto \frac{x}{z \cdot y} \cdot \color{blue}{\sin y} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x}{z \cdot y}\right), \color{blue}{\sin y}\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, \left(z \cdot y\right)\right), \sin \color{blue}{y}\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, \left(y \cdot z\right)\right), \sin y\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, \mathsf{*.f64}\left(y, z\right)\right), \sin y\right) \]
      8. sin-lowering-sin.f6497.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, \mathsf{*.f64}\left(y, z\right)\right), \mathsf{sin.f64}\left(y\right)\right) \]
    4. Applied egg-rr97.0%

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

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

Alternative 3: 60.8% accurate, 6.7× speedup?

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

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

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


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

    1. Initial program 96.9%

      \[\frac{x \cdot \frac{\sin y}{y}}{z} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{\sin y}{y}\right), \color{blue}{z}\right) \]
      2. associate-*r/N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{x \cdot \sin y}{y}\right), z\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \sin y\right), y\right), z\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \sin y\right), y\right), z\right) \]
      5. sin-lowering-sin.f6487.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{sin.f64}\left(y\right)\right), y\right), z\right) \]
    3. Simplified87.4%

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \color{blue}{\left(y \cdot \left(1 + \frac{-1}{6} \cdot {y}^{2}\right)\right)}\right), y\right), z\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \left(1 + \frac{-1}{6} \cdot {y}^{2}\right)\right)\right), y\right), z\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \left(\frac{-1}{6} \cdot {y}^{2}\right)\right)\right)\right), y\right), z\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \left(\frac{-1}{6} \cdot \left(y \cdot y\right)\right)\right)\right)\right), y\right), z\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \left(\left(\frac{-1}{6} \cdot y\right) \cdot y\right)\right)\right)\right), y\right), z\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \left(y \cdot \left(\frac{-1}{6} \cdot y\right)\right)\right)\right)\right), y\right), z\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \left(\frac{-1}{6} \cdot y\right)\right)\right)\right)\right), y\right), z\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \left(y \cdot \frac{-1}{6}\right)\right)\right)\right)\right), y\right), z\right) \]
      8. *-lowering-*.f6457.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \frac{-1}{6}\right)\right)\right)\right)\right), y\right), z\right) \]
    7. Simplified57.8%

      \[\leadsto \frac{\frac{x \cdot \color{blue}{\left(y \cdot \left(1 + y \cdot \left(y \cdot -0.16666666666666666\right)\right)\right)}}{y}}{z} \]
    8. Step-by-step derivation
      1. associate-/l/N/A

        \[\leadsto \frac{x \cdot \left(y \cdot \left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right)\right)}{\color{blue}{z \cdot y}} \]
      2. times-fracN/A

        \[\leadsto \frac{x}{z} \cdot \color{blue}{\frac{y \cdot \left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right)}{y}} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x}{z}\right), \color{blue}{\left(\frac{y \cdot \left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right)}{y}\right)}\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \left(\frac{\color{blue}{y \cdot \left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right)}}{y}\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \left(\frac{\left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right) \cdot y}{y}\right)\right) \]
      6. associate-/l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \left(\left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right) \cdot \color{blue}{\frac{y}{y}}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{*.f64}\left(\left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right), \color{blue}{\left(\frac{y}{y}\right)}\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(y \cdot \left(y \cdot \frac{-1}{6}\right)\right)\right), \left(\frac{\color{blue}{y}}{y}\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \left(y \cdot \frac{-1}{6}\right)\right)\right), \left(\frac{y}{y}\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \frac{-1}{6}\right)\right)\right), \left(\frac{y}{y}\right)\right)\right) \]
      11. /-lowering-/.f6468.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \frac{-1}{6}\right)\right)\right), \mathsf{/.f64}\left(y, \color{blue}{y}\right)\right)\right) \]
    9. Applied egg-rr68.2%

      \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(\left(1 + y \cdot \left(y \cdot -0.16666666666666666\right)\right) \cdot \frac{y}{y}\right)} \]
    10. Step-by-step derivation
      1. *-inversesN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \left(\left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right) \cdot 1\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \left(1 \cdot \color{blue}{\left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right)}\right)\right) \]
      3. *-lft-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \left(1 + \color{blue}{y \cdot \left(y \cdot \frac{-1}{6}\right)}\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \left(y \cdot \left(y \cdot \frac{-1}{6}\right) + \color{blue}{1}\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{+.f64}\left(\left(y \cdot \left(y \cdot \frac{-1}{6}\right)\right), \color{blue}{1}\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(y, \left(y \cdot \frac{-1}{6}\right)\right), 1\right)\right) \]
      7. *-lowering-*.f6468.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \frac{-1}{6}\right)\right), 1\right)\right) \]
    11. Applied egg-rr68.2%

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

    if 1.15e30 < y

    1. Initial program 90.2%

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

        \[\leadsto \frac{\frac{x \cdot \sin y}{y}}{z} \]
      2. associate-/l/N/A

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

        \[\leadsto \frac{x}{z \cdot y} \cdot \color{blue}{\sin y} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x}{z \cdot y}\right), \color{blue}{\sin y}\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, \left(z \cdot y\right)\right), \sin \color{blue}{y}\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, \left(y \cdot z\right)\right), \sin y\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, \mathsf{*.f64}\left(y, z\right)\right), \sin y\right) \]
      8. sin-lowering-sin.f6496.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, \mathsf{*.f64}\left(y, z\right)\right), \mathsf{sin.f64}\left(y\right)\right) \]
    4. Applied egg-rr96.5%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, \mathsf{*.f64}\left(y, z\right)\right), \color{blue}{y}\right) \]
    6. Step-by-step derivation
      1. Simplified26.8%

        \[\leadsto \frac{x}{y \cdot z} \cdot \color{blue}{y} \]
    7. Recombined 2 regimes into one program.
    8. Final simplification58.8%

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

    Alternative 4: 66.4% accurate, 8.2× speedup?

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

      \[\frac{x \cdot \frac{\sin y}{y}}{z} \]
    2. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{\sin y}{y}\right), \color{blue}{z}\right) \]
      2. associate-*r/N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{x \cdot \sin y}{y}\right), z\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \sin y\right), y\right), z\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \sin y\right), y\right), z\right) \]
      5. sin-lowering-sin.f6488.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{sin.f64}\left(y\right)\right), y\right), z\right) \]
    3. Simplified88.0%

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \color{blue}{\left(y \cdot \left(1 + \frac{-1}{6} \cdot {y}^{2}\right)\right)}\right), y\right), z\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \left(1 + \frac{-1}{6} \cdot {y}^{2}\right)\right)\right), y\right), z\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \left(\frac{-1}{6} \cdot {y}^{2}\right)\right)\right)\right), y\right), z\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \left(\frac{-1}{6} \cdot \left(y \cdot y\right)\right)\right)\right)\right), y\right), z\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \left(\left(\frac{-1}{6} \cdot y\right) \cdot y\right)\right)\right)\right), y\right), z\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \left(y \cdot \left(\frac{-1}{6} \cdot y\right)\right)\right)\right)\right), y\right), z\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \left(\frac{-1}{6} \cdot y\right)\right)\right)\right)\right), y\right), z\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \left(y \cdot \frac{-1}{6}\right)\right)\right)\right)\right), y\right), z\right) \]
      8. *-lowering-*.f6445.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \frac{-1}{6}\right)\right)\right)\right)\right), y\right), z\right) \]
    7. Simplified45.2%

      \[\leadsto \frac{\frac{x \cdot \color{blue}{\left(y \cdot \left(1 + y \cdot \left(y \cdot -0.16666666666666666\right)\right)\right)}}{y}}{z} \]
    8. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{z}{\frac{x \cdot \left(y \cdot \left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right)\right)}{y}}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{z}{\frac{x \cdot \left(y \cdot \left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right)\right)}{y}}\right)}\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\frac{1}{\color{blue}{\frac{\frac{x \cdot \left(y \cdot \left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right)\right)}{y}}{z}}}\right)\right) \]
      4. associate-/l/N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\frac{1}{\frac{x \cdot \left(y \cdot \left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right)\right)}{\color{blue}{z \cdot y}}}\right)\right) \]
      5. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\frac{z \cdot y}{\color{blue}{x \cdot \left(y \cdot \left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right)\right)}}\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\left(z \cdot y\right), \color{blue}{\left(x \cdot \left(y \cdot \left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right)\right)\right)}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(z, y\right), \left(\color{blue}{x} \cdot \left(y \cdot \left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right)\right)\right)\right)\right) \]
      8. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(z, y\right), \left(\left(x \cdot y\right) \cdot \color{blue}{\left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right)}\right)\right)\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(z, y\right), \left(\left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right) \cdot \color{blue}{\left(x \cdot y\right)}\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(z, y\right), \mathsf{*.f64}\left(\left(1 + y \cdot \left(y \cdot \frac{-1}{6}\right)\right), \color{blue}{\left(x \cdot y\right)}\right)\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(z, y\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(y \cdot \left(y \cdot \frac{-1}{6}\right)\right)\right), \left(\color{blue}{x} \cdot y\right)\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(z, y\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \left(y \cdot \frac{-1}{6}\right)\right)\right), \left(x \cdot y\right)\right)\right)\right) \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(z, y\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \frac{-1}{6}\right)\right)\right), \left(x \cdot y\right)\right)\right)\right) \]
      14. *-lowering-*.f6439.7%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(z, y\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \frac{-1}{6}\right)\right)\right), \mathsf{*.f64}\left(x, \color{blue}{y}\right)\right)\right)\right) \]
    9. Applied egg-rr39.7%

      \[\leadsto \color{blue}{\frac{1}{\frac{z \cdot y}{\left(1 + y \cdot \left(y \cdot -0.16666666666666666\right)\right) \cdot \left(x \cdot y\right)}}} \]
    10. Taylor expanded in y around 0

      \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{1}{6} \cdot \frac{{y}^{2} \cdot z}{x} + \frac{z}{x}\right)}\right) \]
    11. Step-by-step derivation
      1. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\frac{1}{6} \cdot \left({y}^{2} \cdot \frac{z}{x}\right) + \frac{z}{x}\right)\right) \]
      2. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\frac{1}{6} \cdot {y}^{2}\right) \cdot \frac{z}{x} + \frac{\color{blue}{z}}{x}\right)\right) \]
      3. distribute-lft1-inN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\frac{1}{6} \cdot {y}^{2} + 1\right) \cdot \color{blue}{\frac{z}{x}}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\left(\frac{1}{6} \cdot {y}^{2} + 1\right), \color{blue}{\left(\frac{z}{x}\right)}\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{6} \cdot {y}^{2}\right), 1\right), \left(\frac{\color{blue}{z}}{x}\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left({y}^{2} \cdot \frac{1}{6}\right), 1\right), \left(\frac{z}{x}\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\left({y}^{2}\right), \frac{1}{6}\right), 1\right), \left(\frac{z}{x}\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(y \cdot y\right), \frac{1}{6}\right), 1\right), \left(\frac{z}{x}\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \frac{1}{6}\right), 1\right), \left(\frac{z}{x}\right)\right)\right) \]
      10. /-lowering-/.f6467.6%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \frac{1}{6}\right), 1\right), \mathsf{/.f64}\left(z, \color{blue}{x}\right)\right)\right) \]
    12. Simplified67.6%

      \[\leadsto \frac{1}{\color{blue}{\left(\left(y \cdot y\right) \cdot 0.16666666666666666 + 1\right) \cdot \frac{z}{x}}} \]
    13. Final simplification67.6%

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

    Alternative 5: 62.4% accurate, 8.9× speedup?

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

      1. Initial program 96.7%

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

        \[\leadsto \color{blue}{\frac{x}{z}} \]
      4. Step-by-step derivation
        1. /-lowering-/.f6476.7%

          \[\leadsto \mathsf{/.f64}\left(x, \color{blue}{z}\right) \]
      5. Simplified76.7%

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

      if 9.49999999999999998e-4 < y

      1. Initial program 92.1%

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

          \[\leadsto \frac{\frac{x \cdot \sin y}{y}}{z} \]
        2. associate-/l/N/A

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

          \[\leadsto \frac{x}{z \cdot y} \cdot \color{blue}{\sin y} \]
        4. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\frac{x}{z \cdot y}\right), \color{blue}{\sin y}\right) \]
        5. /-lowering-/.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, \left(z \cdot y\right)\right), \sin \color{blue}{y}\right) \]
        6. *-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, \left(y \cdot z\right)\right), \sin y\right) \]
        7. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, \mathsf{*.f64}\left(y, z\right)\right), \sin y\right) \]
        8. sin-lowering-sin.f6497.0%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, \mathsf{*.f64}\left(y, z\right)\right), \mathsf{sin.f64}\left(y\right)\right) \]
      4. Applied egg-rr97.0%

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, \mathsf{*.f64}\left(y, z\right)\right), \color{blue}{y}\right) \]
      6. Step-by-step derivation
        1. Simplified24.0%

          \[\leadsto \frac{x}{y \cdot z} \cdot \color{blue}{y} \]
      7. Recombined 2 regimes into one program.
      8. Final simplification61.9%

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

      Alternative 6: 66.7% 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.4%

        \[\frac{x \cdot \frac{\sin y}{y}}{z} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. clear-numN/A

          \[\leadsto \frac{x \cdot \frac{1}{\frac{y}{\sin y}}}{z} \]
        2. un-div-invN/A

          \[\leadsto \frac{\frac{x}{\frac{y}{\sin y}}}{z} \]
        3. associate-/l/N/A

          \[\leadsto \frac{x}{\color{blue}{z \cdot \frac{y}{\sin y}}} \]
        4. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(x, \color{blue}{\left(z \cdot \frac{y}{\sin y}\right)}\right) \]
        5. clear-numN/A

          \[\leadsto \mathsf{/.f64}\left(x, \left(z \cdot \frac{1}{\color{blue}{\frac{\sin y}{y}}}\right)\right) \]
        6. div-invN/A

          \[\leadsto \mathsf{/.f64}\left(x, \left(\frac{z}{\color{blue}{\frac{\sin y}{y}}}\right)\right) \]
        7. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(x, \mathsf{/.f64}\left(z, \color{blue}{\left(\frac{\sin y}{y}\right)}\right)\right) \]
        8. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(x, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(\sin y, \color{blue}{y}\right)\right)\right) \]
        9. sin-lowering-sin.f6498.4%

          \[\leadsto \mathsf{/.f64}\left(x, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(\mathsf{sin.f64}\left(y\right), y\right)\right)\right) \]
      4. Applied egg-rr98.4%

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

        \[\leadsto \mathsf{/.f64}\left(x, \color{blue}{\left(z + \frac{1}{6} \cdot \left({y}^{2} \cdot z\right)\right)}\right) \]
      6. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto \mathsf{/.f64}\left(x, \left(z + \left(\frac{1}{6} \cdot {y}^{2}\right) \cdot \color{blue}{z}\right)\right) \]
        2. distribute-rgt1-inN/A

          \[\leadsto \mathsf{/.f64}\left(x, \left(\left(\frac{1}{6} \cdot {y}^{2} + 1\right) \cdot \color{blue}{z}\right)\right) \]
        3. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(x, \mathsf{*.f64}\left(\left(\frac{1}{6} \cdot {y}^{2} + 1\right), \color{blue}{z}\right)\right) \]
        4. +-commutativeN/A

          \[\leadsto \mathsf{/.f64}\left(x, \mathsf{*.f64}\left(\left(1 + \frac{1}{6} \cdot {y}^{2}\right), z\right)\right) \]
        5. +-lowering-+.f64N/A

          \[\leadsto \mathsf{/.f64}\left(x, \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{1}{6} \cdot {y}^{2}\right)\right), z\right)\right) \]
        6. *-commutativeN/A

          \[\leadsto \mathsf{/.f64}\left(x, \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left({y}^{2} \cdot \frac{1}{6}\right)\right), z\right)\right) \]
        7. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(x, \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({y}^{2}\right), \frac{1}{6}\right)\right), z\right)\right) \]
        8. unpow2N/A

          \[\leadsto \mathsf{/.f64}\left(x, \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(y \cdot y\right), \frac{1}{6}\right)\right), z\right)\right) \]
        9. *-lowering-*.f6467.4%

          \[\leadsto \mathsf{/.f64}\left(x, \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \frac{1}{6}\right)\right), z\right)\right) \]
      7. Simplified67.4%

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

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

      Alternative 7: 58.5% 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.4%

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

        \[\leadsto \color{blue}{\frac{x}{z}} \]
      4. Step-by-step derivation
        1. /-lowering-/.f6459.6%

          \[\leadsto \mathsf{/.f64}\left(x, \color{blue}{z}\right) \]
      5. Simplified59.6%

        \[\leadsto \color{blue}{\frac{x}{z}} \]
      6. Add Preprocessing

      Developer Target 1: 99.6% 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 2024158 
      (FPCore (x y z)
        :name "Linear.Quaternion:$ctanh from linear-1.19.1.3"
        :precision binary64
      
        :alt
        (! :herbie-platform default (if (< z -42173720203427147/1000000000000000000000000000000000000000000000) (/ (* x (/ 1 (/ y (sin y)))) z) (if (< z 44467023691138110000000000000000000000000000000000000000000000000) (/ x (* z (/ y (sin y)))) (/ (* x (/ 1 (/ y (sin y)))) z))))
      
        (/ (* x (/ (sin y) y)) z))