Linear.Quaternion:$ctanh from linear-1.19.1.3

Percentage Accurate: 96.0% → 99.6%
Time: 8.2s
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: 96.0% 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, 0.3× speedup?

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

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

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{-76}:\\
\;\;\;\;t_0 \cdot \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 x (/.f64 (sin.f64 y) y)) z) < -9.99999999999999995e-56

    1. Initial program 99.8%

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

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

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

    if -9.99999999999999995e-56 < (/.f64 (*.f64 x (/.f64 (sin.f64 y) y)) z) < 1.99999999999999985e-76

    1. Initial program 93.5%

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

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

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

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

    if 1.99999999999999985e-76 < (/.f64 (*.f64 x (/.f64 (sin.f64 y) y)) z)

    1. Initial program 99.7%

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

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

Alternative 2: 99.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3 \cdot 10^{-31} \lor \neg \left(z \leq 1.6 \cdot 10^{-53}\right):\\
\;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.99999999999999981e-31 or 1.6e-53 < z

    1. Initial program 99.0%

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

        \[\leadsto \color{blue}{\frac{x}{z} \cdot \frac{\sin y}{y}} \]
      2. *-commutative99.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 -2.99999999999999981e-31 < z < 1.6e-53

    1. Initial program 92.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3 \cdot 10^{-31} \lor \neg \left(z \leq 1.6 \cdot 10^{-53}\right):\\ \;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{\sin y}{z}}{y}\\ \end{array} \]

Alternative 3: 99.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sin y}{y}\\ \mathbf{if}\;z \leq -2 \cdot 10^{+83} \lor \neg \left(z \leq 5 \cdot 10^{-35}\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 -2e+83) (not (<= z 5e-35))) (* 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 <= -2e+83) || !(z <= 5e-35)) {
		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 <= (-2d+83)) .or. (.not. (z <= 5d-35))) 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 <= -2e+83) || !(z <= 5e-35)) {
		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 <= -2e+83) or not (z <= 5e-35):
		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 <= -2e+83) || !(z <= 5e-35))
		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 <= -2e+83) || ~((z <= 5e-35)))
		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, -2e+83], N[Not[LessEqual[z, 5e-35]], $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 -2 \cdot 10^{+83} \lor \neg \left(z \leq 5 \cdot 10^{-35}\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 < -2.00000000000000006e83 or 4.99999999999999964e-35 < z

    1. Initial program 99.4%

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

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

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

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

    if -2.00000000000000006e83 < z < 4.99999999999999964e-35

    1. Initial program 93.6%

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

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

      \[\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 -2 \cdot 10^{+83} \lor \neg \left(z \leq 5 \cdot 10^{-35}\right):\\ \;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{\frac{\sin y}{y}}}\\ \end{array} \]

Alternative 4: 95.9% accurate, 1.0× speedup?

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

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

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

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

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

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

Alternative 5: 61.4% accurate, 8.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 3.9 \cdot 10^{-12}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{y} \cdot \frac{y \cdot z}{x}}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y 3.9e-12) (/ x z) (/ 1.0 (* (/ 1.0 y) (/ (* y z) x)))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 3.9e-12) {
		tmp = x / z;
	} else {
		tmp = 1.0 / ((1.0 / y) * ((y * z) / x));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= 3.9d-12) then
        tmp = x / z
    else
        tmp = 1.0d0 / ((1.0d0 / y) * ((y * z) / x))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 3.9e-12) {
		tmp = x / z;
	} else {
		tmp = 1.0 / ((1.0 / y) * ((y * z) / x));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= 3.9e-12:
		tmp = x / z
	else:
		tmp = 1.0 / ((1.0 / y) * ((y * z) / x))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= 3.9e-12)
		tmp = Float64(x / z);
	else
		tmp = Float64(1.0 / Float64(Float64(1.0 / y) * Float64(Float64(y * z) / x)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 3.9e-12)
		tmp = x / z;
	else
		tmp = 1.0 / ((1.0 / y) * ((y * z) / x));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, 3.9e-12], N[(x / z), $MachinePrecision], N[(1.0 / N[(N[(1.0 / y), $MachinePrecision] * N[(N[(y * z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 97.7%

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

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

    if 3.89999999999999994e-12 < y

    1. Initial program 92.2%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot \frac{y}{z}}{y}} \]
      2. clear-num22.7%

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot \left(y \cdot z\right)}}{y \cdot x}} \]
      5. times-frac37.4%

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

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

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

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

Alternative 6: 61.4% accurate, 11.8× speedup?

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

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

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


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

    1. Initial program 97.7%

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

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

    if 2e22 < y

    1. Initial program 91.1%

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

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

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

      \[\leadsto x \cdot \frac{\color{blue}{1}}{z} \]
    5. Step-by-step derivation
      1. *-un-lft-identity19.2%

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

        \[\leadsto \color{blue}{\frac{y}{y}} \cdot \left(x \cdot \frac{1}{z}\right) \]
      3. un-div-inv19.2%

        \[\leadsto \frac{y}{y} \cdot \color{blue}{\frac{x}{z}} \]
      4. times-frac25.2%

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

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

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

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

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

Alternative 7: 57.6% 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 96.4%

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

    \[\leadsto \color{blue}{\frac{x}{z}} \]
  3. Final simplification55.3%

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

Developer target: 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 2023305 
(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))