Linear.Quaternion:$ccosh from linear-1.19.1.3

Percentage Accurate: 88.7% → 99.9%
Time: 7.5s
Alternatives: 9
Speedup: 1.0×

Specification

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

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

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

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

Alternative 1: 99.9% accurate, 1.0× speedup?

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

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

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

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

    \[\leadsto \color{blue}{\frac{\sin x}{x} \cdot \sinh y} \]
  4. Final simplification99.9%

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

Alternative 2: 86.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sinh y \leq -0.2:\\ \;\;\;\;\sinh y\\ \mathbf{elif}\;\sinh y \leq 10^{-6}:\\ \;\;\;\;\sin x \cdot \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;\sinh y\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (sinh y) -0.2)
   (sinh y)
   (if (<= (sinh y) 1e-6) (* (sin x) (/ y x)) (sinh y))))
double code(double x, double y) {
	double tmp;
	if (sinh(y) <= -0.2) {
		tmp = sinh(y);
	} else if (sinh(y) <= 1e-6) {
		tmp = sin(x) * (y / x);
	} else {
		tmp = sinh(y);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (sinh(y) <= (-0.2d0)) then
        tmp = sinh(y)
    else if (sinh(y) <= 1d-6) then
        tmp = sin(x) * (y / x)
    else
        tmp = sinh(y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (Math.sinh(y) <= -0.2) {
		tmp = Math.sinh(y);
	} else if (Math.sinh(y) <= 1e-6) {
		tmp = Math.sin(x) * (y / x);
	} else {
		tmp = Math.sinh(y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if math.sinh(y) <= -0.2:
		tmp = math.sinh(y)
	elif math.sinh(y) <= 1e-6:
		tmp = math.sin(x) * (y / x)
	else:
		tmp = math.sinh(y)
	return tmp
function code(x, y)
	tmp = 0.0
	if (sinh(y) <= -0.2)
		tmp = sinh(y);
	elseif (sinh(y) <= 1e-6)
		tmp = Float64(sin(x) * Float64(y / x));
	else
		tmp = sinh(y);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (sinh(y) <= -0.2)
		tmp = sinh(y);
	elseif (sinh(y) <= 1e-6)
		tmp = sin(x) * (y / x);
	else
		tmp = sinh(y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], -0.2], N[Sinh[y], $MachinePrecision], If[LessEqual[N[Sinh[y], $MachinePrecision], 1e-6], N[(N[Sin[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -0.2:\\
\;\;\;\;\sinh y\\

\mathbf{elif}\;\sinh y \leq 10^{-6}:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\

\mathbf{else}:\\
\;\;\;\;\sinh y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sinh.f64 y) < -0.20000000000000001 or 9.99999999999999955e-7 < (sinh.f64 y)

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\frac{\sin x}{x} \cdot \sinh y} \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{1} \cdot \sinh y \]

    if -0.20000000000000001 < (sinh.f64 y) < 9.99999999999999955e-7

    1. Initial program 78.7%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{y}{x} \cdot \sin x} \]
    6. Simplified98.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sinh y \leq -0.2:\\ \;\;\;\;\sinh y\\ \mathbf{elif}\;\sinh y \leq 10^{-6}:\\ \;\;\;\;\sin x \cdot \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;\sinh y\\ \end{array} \]

Alternative 3: 72.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sinh y \leq -2 \cdot 10^{-124}:\\ \;\;\;\;\sinh y\\ \mathbf{elif}\;\sinh y \leq 4 \cdot 10^{-30}:\\ \;\;\;\;x \cdot \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;\sinh y\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (sinh y) -2e-124)
   (sinh y)
   (if (<= (sinh y) 4e-30) (* x (/ y x)) (sinh y))))
double code(double x, double y) {
	double tmp;
	if (sinh(y) <= -2e-124) {
		tmp = sinh(y);
	} else if (sinh(y) <= 4e-30) {
		tmp = x * (y / x);
	} else {
		tmp = sinh(y);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (sinh(y) <= (-2d-124)) then
        tmp = sinh(y)
    else if (sinh(y) <= 4d-30) then
        tmp = x * (y / x)
    else
        tmp = sinh(y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (Math.sinh(y) <= -2e-124) {
		tmp = Math.sinh(y);
	} else if (Math.sinh(y) <= 4e-30) {
		tmp = x * (y / x);
	} else {
		tmp = Math.sinh(y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if math.sinh(y) <= -2e-124:
		tmp = math.sinh(y)
	elif math.sinh(y) <= 4e-30:
		tmp = x * (y / x)
	else:
		tmp = math.sinh(y)
	return tmp
function code(x, y)
	tmp = 0.0
	if (sinh(y) <= -2e-124)
		tmp = sinh(y);
	elseif (sinh(y) <= 4e-30)
		tmp = Float64(x * Float64(y / x));
	else
		tmp = sinh(y);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (sinh(y) <= -2e-124)
		tmp = sinh(y);
	elseif (sinh(y) <= 4e-30)
		tmp = x * (y / x);
	else
		tmp = sinh(y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], -2e-124], N[Sinh[y], $MachinePrecision], If[LessEqual[N[Sinh[y], $MachinePrecision], 4e-30], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -2 \cdot 10^{-124}:\\
\;\;\;\;\sinh y\\

\mathbf{elif}\;\sinh y \leq 4 \cdot 10^{-30}:\\
\;\;\;\;x \cdot \frac{y}{x}\\

\mathbf{else}:\\
\;\;\;\;\sinh y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sinh.f64 y) < -1.99999999999999987e-124 or 4e-30 < (sinh.f64 y)

    1. Initial program 98.7%

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

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

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

      \[\leadsto \color{blue}{1} \cdot \sinh y \]

    if -1.99999999999999987e-124 < (sinh.f64 y) < 4e-30

    1. Initial program 74.0%

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

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

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

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

      \[\leadsto \frac{\color{blue}{y \cdot x}}{x} \]
    6. Step-by-step derivation
      1. associate-/l*49.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sinh y \leq -2 \cdot 10^{-124}:\\ \;\;\;\;\sinh y\\ \mathbf{elif}\;\sinh y \leq 4 \cdot 10^{-30}:\\ \;\;\;\;x \cdot \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;\sinh y\\ \end{array} \]

Alternative 4: 99.9% accurate, 1.0× speedup?

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

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

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

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

    \[\leadsto \color{blue}{\sin x \cdot \frac{\sinh y}{x}} \]
  4. Final simplification99.9%

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

Alternative 5: 86.8% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -0.06:\\ \;\;\;\;\sinh y\\ \mathbf{elif}\;y \leq 0.00082:\\ \;\;\;\;\frac{y}{\frac{x}{\sin x}}\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{+89}:\\ \;\;\;\;\sinh y \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;\sinh y\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -0.06)
   (sinh y)
   (if (<= y 0.00082)
     (/ y (/ x (sin x)))
     (if (<= y 8.6e+89)
       (* (sinh y) (+ 1.0 (* (* x x) -0.16666666666666666)))
       (sinh y)))))
double code(double x, double y) {
	double tmp;
	if (y <= -0.06) {
		tmp = sinh(y);
	} else if (y <= 0.00082) {
		tmp = y / (x / sin(x));
	} else if (y <= 8.6e+89) {
		tmp = sinh(y) * (1.0 + ((x * x) * -0.16666666666666666));
	} else {
		tmp = sinh(y);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-0.06d0)) then
        tmp = sinh(y)
    else if (y <= 0.00082d0) then
        tmp = y / (x / sin(x))
    else if (y <= 8.6d+89) then
        tmp = sinh(y) * (1.0d0 + ((x * x) * (-0.16666666666666666d0)))
    else
        tmp = sinh(y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -0.06) {
		tmp = Math.sinh(y);
	} else if (y <= 0.00082) {
		tmp = y / (x / Math.sin(x));
	} else if (y <= 8.6e+89) {
		tmp = Math.sinh(y) * (1.0 + ((x * x) * -0.16666666666666666));
	} else {
		tmp = Math.sinh(y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -0.06:
		tmp = math.sinh(y)
	elif y <= 0.00082:
		tmp = y / (x / math.sin(x))
	elif y <= 8.6e+89:
		tmp = math.sinh(y) * (1.0 + ((x * x) * -0.16666666666666666))
	else:
		tmp = math.sinh(y)
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -0.06)
		tmp = sinh(y);
	elseif (y <= 0.00082)
		tmp = Float64(y / Float64(x / sin(x)));
	elseif (y <= 8.6e+89)
		tmp = Float64(sinh(y) * Float64(1.0 + Float64(Float64(x * x) * -0.16666666666666666)));
	else
		tmp = sinh(y);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -0.06)
		tmp = sinh(y);
	elseif (y <= 0.00082)
		tmp = y / (x / sin(x));
	elseif (y <= 8.6e+89)
		tmp = sinh(y) * (1.0 + ((x * x) * -0.16666666666666666));
	else
		tmp = sinh(y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -0.06], N[Sinh[y], $MachinePrecision], If[LessEqual[y, 0.00082], N[(y / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.6e+89], N[(N[Sinh[y], $MachinePrecision] * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.06:\\
\;\;\;\;\sinh y\\

\mathbf{elif}\;y \leq 0.00082:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\

\mathbf{elif}\;y \leq 8.6 \cdot 10^{+89}:\\
\;\;\;\;\sinh y \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right)\\

\mathbf{else}:\\
\;\;\;\;\sinh y\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -0.059999999999999998 or 8.6000000000000003e89 < y

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\frac{\sin x}{x} \cdot \sinh y} \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{1} \cdot \sinh y \]

    if -0.059999999999999998 < y < 8.1999999999999998e-4

    1. Initial program 78.7%

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

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

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

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

        \[\leadsto \color{blue}{\frac{y}{\frac{x}{\sin x}}} \]
    6. Simplified98.9%

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

    if 8.1999999999999998e-4 < y < 8.6000000000000003e89

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\frac{\sin x}{x} \cdot \sinh y} \]
    3. Simplified100.0%

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

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

        \[\leadsto \left(1 + \color{blue}{{x}^{2} \cdot -0.16666666666666666}\right) \cdot \sinh y \]
      2. unpow289.5%

        \[\leadsto \left(1 + \color{blue}{\left(x \cdot x\right)} \cdot -0.16666666666666666\right) \cdot \sinh y \]
    6. Simplified89.5%

      \[\leadsto \color{blue}{\left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right)} \cdot \sinh y \]
  3. Recombined 3 regimes into one program.
  4. Final simplification93.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -0.06:\\ \;\;\;\;\sinh y\\ \mathbf{elif}\;y \leq 0.00082:\\ \;\;\;\;\frac{y}{\frac{x}{\sin x}}\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{+89}:\\ \;\;\;\;\sinh y \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;\sinh y\\ \end{array} \]

Alternative 6: 86.8% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -0.06:\\ \;\;\;\;\sinh y\\ \mathbf{elif}\;y \leq 9.6 \cdot 10^{-5}:\\ \;\;\;\;\frac{y}{\frac{x}{\sin x}}\\ \mathbf{else}:\\ \;\;\;\;\sinh y\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -0.06) (sinh y) (if (<= y 9.6e-5) (/ y (/ x (sin x))) (sinh y))))
double code(double x, double y) {
	double tmp;
	if (y <= -0.06) {
		tmp = sinh(y);
	} else if (y <= 9.6e-5) {
		tmp = y / (x / sin(x));
	} else {
		tmp = sinh(y);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-0.06d0)) then
        tmp = sinh(y)
    else if (y <= 9.6d-5) then
        tmp = y / (x / sin(x))
    else
        tmp = sinh(y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -0.06) {
		tmp = Math.sinh(y);
	} else if (y <= 9.6e-5) {
		tmp = y / (x / Math.sin(x));
	} else {
		tmp = Math.sinh(y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -0.06:
		tmp = math.sinh(y)
	elif y <= 9.6e-5:
		tmp = y / (x / math.sin(x))
	else:
		tmp = math.sinh(y)
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -0.06)
		tmp = sinh(y);
	elseif (y <= 9.6e-5)
		tmp = Float64(y / Float64(x / sin(x)));
	else
		tmp = sinh(y);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -0.06)
		tmp = sinh(y);
	elseif (y <= 9.6e-5)
		tmp = y / (x / sin(x));
	else
		tmp = sinh(y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -0.06], N[Sinh[y], $MachinePrecision], If[LessEqual[y, 9.6e-5], N[(y / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.06:\\
\;\;\;\;\sinh y\\

\mathbf{elif}\;y \leq 9.6 \cdot 10^{-5}:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\

\mathbf{else}:\\
\;\;\;\;\sinh y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -0.059999999999999998 or 9.6000000000000002e-5 < y

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\frac{\sin x}{x} \cdot \sinh y} \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{1} \cdot \sinh y \]

    if -0.059999999999999998 < y < 9.6000000000000002e-5

    1. Initial program 78.7%

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

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

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

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

        \[\leadsto \color{blue}{\frac{y}{\frac{x}{\sin x}}} \]
    6. Simplified98.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -0.06:\\ \;\;\;\;\sinh y\\ \mathbf{elif}\;y \leq 9.6 \cdot 10^{-5}:\\ \;\;\;\;\frac{y}{\frac{x}{\sin x}}\\ \mathbf{else}:\\ \;\;\;\;\sinh y\\ \end{array} \]

Alternative 7: 54.2% accurate, 2.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{+147}:\\
\;\;\;\;x \cdot \frac{y}{x}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{y \cdot y}\\


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

    1. Initial program 87.4%

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

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

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

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

      \[\leadsto \frac{\color{blue}{y \cdot x}}{x} \]
    6. Step-by-step derivation
      1. associate-/l*31.3%

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

        \[\leadsto \color{blue}{\frac{y}{x} \cdot x} \]
    7. Applied egg-rr50.9%

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

    if 1.34999999999999999e147 < y

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\sin x \cdot \frac{\sinh y}{x}} \]
    3. Simplified100.0%

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

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

      \[\leadsto \frac{\color{blue}{y \cdot x}}{x} \]
    6. Step-by-step derivation
      1. associate-/l*6.0%

        \[\leadsto \color{blue}{\frac{y}{\frac{x}{x}}} \]
      2. *-inverses6.0%

        \[\leadsto \frac{y}{\color{blue}{1}} \]
      3. /-rgt-identity6.0%

        \[\leadsto \color{blue}{y} \]
      4. add-sqr-sqrt6.0%

        \[\leadsto \color{blue}{\sqrt{y} \cdot \sqrt{y}} \]
      5. sqrt-unprod81.5%

        \[\leadsto \color{blue}{\sqrt{y \cdot y}} \]
    7. Applied egg-rr81.5%

      \[\leadsto \color{blue}{\sqrt{y \cdot y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification54.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.35 \cdot 10^{+147}:\\ \;\;\;\;x \cdot \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{y \cdot y}\\ \end{array} \]

Alternative 8: 50.2% accurate, 41.0× speedup?

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{y \cdot x}}{x} \]
  6. Step-by-step derivation
    1. associate-/l*28.2%

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

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

    \[\leadsto \color{blue}{\frac{y}{x} \cdot x} \]
  8. Final simplification51.1%

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

Alternative 9: 27.7% accurate, 205.0× speedup?

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

\\
y
\end{array}
Derivation
  1. Initial program 88.9%

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

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

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

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

      \[\leadsto \color{blue}{\frac{y}{\frac{x}{\sin x}}} \]
  6. Simplified54.0%

    \[\leadsto \color{blue}{\frac{y}{\frac{x}{\sin x}}} \]
  7. Taylor expanded in x around 0 28.2%

    \[\leadsto \color{blue}{y} \]
  8. Final simplification28.2%

    \[\leadsto y \]

Developer target: 99.9% accurate, 1.0× speedup?

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

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

Reproduce

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

  :herbie-target
  (* (sin x) (/ (sinh y) x))

  (/ (* (sin x) (sinh y)) x))