Linear.Quaternion:$ccosh from linear-1.19.1.3

Percentage Accurate: 88.7% → 99.8%
Time: 9.5s
Alternatives: 7
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 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: 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.8% 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 86.1%

    \[\frac{\sin x \cdot \sinh y}{x} \]
  2. Step-by-step derivation
    1. associate-/l*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. Add Preprocessing
  5. Final simplification99.9%

    \[\leadsto \sin x \cdot \frac{\sinh y}{x} \]
  6. Add Preprocessing

Alternative 2: 70.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 0.005:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sinh.f64 y) < 0.0050000000000000001

    1. Initial program 81.8%

      \[\frac{\sin x \cdot \sinh y}{x} \]
    2. Step-by-step derivation
      1. associate-/l*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. Add Preprocessing
    5. Taylor expanded in y around 0 46.1%

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

        \[\leadsto \color{blue}{y \cdot \frac{\sin x}{x}} \]
    7. Simplified64.2%

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

    if 0.0050000000000000001 < (sinh.f64 y)

    1. Initial program 100.0%

      \[\frac{\sin x \cdot \sinh y}{x} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \frac{\color{blue}{\sinh y \cdot \sin x}}{x} \]
      2. add-sqr-sqrt52.5%

        \[\leadsto \frac{\sinh y \cdot \sin x}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}} \]
      3. times-frac52.5%

        \[\leadsto \color{blue}{\frac{\sinh y}{\sqrt{x}} \cdot \frac{\sin x}{\sqrt{x}}} \]
    4. Applied egg-rr52.5%

      \[\leadsto \color{blue}{\frac{\sinh y}{\sqrt{x}} \cdot \frac{\sin x}{\sqrt{x}}} \]
    5. Step-by-step derivation
      1. frac-times52.5%

        \[\leadsto \color{blue}{\frac{\sinh y \cdot \sin x}{\sqrt{x} \cdot \sqrt{x}}} \]
      2. *-commutative52.5%

        \[\leadsto \frac{\color{blue}{\sin x \cdot \sinh y}}{\sqrt{x} \cdot \sqrt{x}} \]
      3. add-sqr-sqrt100.0%

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

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

        \[\leadsto \color{blue}{\frac{\sin x}{\frac{x}{\sinh y}}} \]
      6. div-inv100.0%

        \[\leadsto \frac{\sin x}{\color{blue}{x \cdot \frac{1}{\sinh y}}} \]
      7. associate-/r*100.0%

        \[\leadsto \color{blue}{\frac{\frac{\sin x}{x}}{\frac{1}{\sinh y}}} \]
    6. Applied egg-rr100.0%

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

      \[\leadsto \frac{\color{blue}{1}}{\frac{1}{\sinh y}} \]
    8. Step-by-step derivation
      1. remove-double-div75.4%

        \[\leadsto \color{blue}{\sinh y} \]
      2. expm1-log1p-u75.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sinh y\right)\right)} \]
      3. expm1-undefine75.4%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sinh y\right)} - 1} \]
    9. Applied egg-rr75.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sinh y\right)} - 1} \]
    10. Step-by-step derivation
      1. sub-neg75.4%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sinh y\right)} + \left(-1\right)} \]
      2. metadata-eval75.4%

        \[\leadsto e^{\mathsf{log1p}\left(\sinh y\right)} + \color{blue}{-1} \]
      3. +-commutative75.4%

        \[\leadsto \color{blue}{-1 + e^{\mathsf{log1p}\left(\sinh y\right)}} \]
      4. log1p-undefine75.4%

        \[\leadsto -1 + e^{\color{blue}{\log \left(1 + \sinh y\right)}} \]
      5. rem-exp-log75.4%

        \[\leadsto -1 + \color{blue}{\left(1 + \sinh y\right)} \]
      6. associate-+r+75.4%

        \[\leadsto \color{blue}{\left(-1 + 1\right) + \sinh y} \]
      7. metadata-eval75.4%

        \[\leadsto \color{blue}{0} + \sinh y \]
      8. +-lft-identity75.4%

        \[\leadsto \color{blue}{\sinh y} \]
    11. Simplified75.4%

      \[\leadsto \color{blue}{\sinh y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification66.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sinh y \leq 0.005:\\ \;\;\;\;y \cdot \frac{\sin x}{x}\\ \mathbf{else}:\\ \;\;\;\;\sinh y\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 63.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 10^{-88}:\\
\;\;\;\;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) < 9.99999999999999934e-89

    1. Initial program 81.2%

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{y}{x}} \]
      2. *-commutative58.4%

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

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

    if 9.99999999999999934e-89 < (sinh.f64 y)

    1. Initial program 98.6%

      \[\frac{\sin x \cdot \sinh y}{x} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative98.6%

        \[\leadsto \frac{\color{blue}{\sinh y \cdot \sin x}}{x} \]
      2. add-sqr-sqrt53.3%

        \[\leadsto \frac{\sinh y \cdot \sin x}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}} \]
      3. times-frac53.3%

        \[\leadsto \color{blue}{\frac{\sinh y}{\sqrt{x}} \cdot \frac{\sin x}{\sqrt{x}}} \]
    4. Applied egg-rr53.3%

      \[\leadsto \color{blue}{\frac{\sinh y}{\sqrt{x}} \cdot \frac{\sin x}{\sqrt{x}}} \]
    5. Step-by-step derivation
      1. frac-times53.3%

        \[\leadsto \color{blue}{\frac{\sinh y \cdot \sin x}{\sqrt{x} \cdot \sqrt{x}}} \]
      2. *-commutative53.3%

        \[\leadsto \frac{\color{blue}{\sin x \cdot \sinh y}}{\sqrt{x} \cdot \sqrt{x}} \]
      3. add-sqr-sqrt98.6%

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

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

        \[\leadsto \color{blue}{\frac{\sin x}{\frac{x}{\sinh y}}} \]
      6. div-inv99.9%

        \[\leadsto \frac{\sin x}{\color{blue}{x \cdot \frac{1}{\sinh y}}} \]
      7. associate-/r*99.9%

        \[\leadsto \color{blue}{\frac{\frac{\sin x}{x}}{\frac{1}{\sinh y}}} \]
    6. Applied egg-rr99.9%

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

      \[\leadsto \frac{\color{blue}{1}}{\frac{1}{\sinh y}} \]
    8. Step-by-step derivation
      1. remove-double-div74.0%

        \[\leadsto \color{blue}{\sinh y} \]
      2. expm1-log1p-u74.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sinh y\right)\right)} \]
      3. expm1-undefine64.9%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sinh y\right)} - 1} \]
    9. Applied egg-rr64.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sinh y\right)} - 1} \]
    10. Step-by-step derivation
      1. sub-neg64.9%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sinh y\right)} + \left(-1\right)} \]
      2. metadata-eval64.9%

        \[\leadsto e^{\mathsf{log1p}\left(\sinh y\right)} + \color{blue}{-1} \]
      3. +-commutative64.9%

        \[\leadsto \color{blue}{-1 + e^{\mathsf{log1p}\left(\sinh y\right)}} \]
      4. log1p-undefine64.9%

        \[\leadsto -1 + e^{\color{blue}{\log \left(1 + \sinh y\right)}} \]
      5. rem-exp-log64.9%

        \[\leadsto -1 + \color{blue}{\left(1 + \sinh y\right)} \]
      6. associate-+r+74.0%

        \[\leadsto \color{blue}{\left(-1 + 1\right) + \sinh y} \]
      7. metadata-eval74.0%

        \[\leadsto \color{blue}{0} + \sinh y \]
      8. +-lft-identity74.0%

        \[\leadsto \color{blue}{\sinh y} \]
    11. Simplified74.0%

      \[\leadsto \color{blue}{\sinh y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification62.8%

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

Alternative 4: 50.9% accurate, 7.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{y}{x}\\ t_1 := -0.16666666666666666 \cdot \left(x \cdot x\right)\\ \mathbf{if}\;x \leq 2.3 \cdot 10^{+102}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{+158}:\\ \;\;\;\;y \cdot \left(1 + t\_1\right)\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{+226} \lor \neg \left(x \leq 1.5 \cdot 10^{+246}\right):\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot t\_1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* x (/ y x))) (t_1 (* -0.16666666666666666 (* x x))))
   (if (<= x 2.3e+102)
     t_0
     (if (<= x 1.8e+158)
       (* y (+ 1.0 t_1))
       (if (or (<= x 1.75e+226) (not (<= x 1.5e+246))) t_0 (* y t_1))))))
double code(double x, double y) {
	double t_0 = x * (y / x);
	double t_1 = -0.16666666666666666 * (x * x);
	double tmp;
	if (x <= 2.3e+102) {
		tmp = t_0;
	} else if (x <= 1.8e+158) {
		tmp = y * (1.0 + t_1);
	} else if ((x <= 1.75e+226) || !(x <= 1.5e+246)) {
		tmp = t_0;
	} else {
		tmp = y * t_1;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x * (y / x)
    t_1 = (-0.16666666666666666d0) * (x * x)
    if (x <= 2.3d+102) then
        tmp = t_0
    else if (x <= 1.8d+158) then
        tmp = y * (1.0d0 + t_1)
    else if ((x <= 1.75d+226) .or. (.not. (x <= 1.5d+246))) then
        tmp = t_0
    else
        tmp = y * t_1
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = x * (y / x);
	double t_1 = -0.16666666666666666 * (x * x);
	double tmp;
	if (x <= 2.3e+102) {
		tmp = t_0;
	} else if (x <= 1.8e+158) {
		tmp = y * (1.0 + t_1);
	} else if ((x <= 1.75e+226) || !(x <= 1.5e+246)) {
		tmp = t_0;
	} else {
		tmp = y * t_1;
	}
	return tmp;
}
def code(x, y):
	t_0 = x * (y / x)
	t_1 = -0.16666666666666666 * (x * x)
	tmp = 0
	if x <= 2.3e+102:
		tmp = t_0
	elif x <= 1.8e+158:
		tmp = y * (1.0 + t_1)
	elif (x <= 1.75e+226) or not (x <= 1.5e+246):
		tmp = t_0
	else:
		tmp = y * t_1
	return tmp
function code(x, y)
	t_0 = Float64(x * Float64(y / x))
	t_1 = Float64(-0.16666666666666666 * Float64(x * x))
	tmp = 0.0
	if (x <= 2.3e+102)
		tmp = t_0;
	elseif (x <= 1.8e+158)
		tmp = Float64(y * Float64(1.0 + t_1));
	elseif ((x <= 1.75e+226) || !(x <= 1.5e+246))
		tmp = t_0;
	else
		tmp = Float64(y * t_1);
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x * (y / x);
	t_1 = -0.16666666666666666 * (x * x);
	tmp = 0.0;
	if (x <= 2.3e+102)
		tmp = t_0;
	elseif (x <= 1.8e+158)
		tmp = y * (1.0 + t_1);
	elseif ((x <= 1.75e+226) || ~((x <= 1.5e+246)))
		tmp = t_0;
	else
		tmp = y * t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2.3e+102], t$95$0, If[LessEqual[x, 1.8e+158], N[(y * N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 1.75e+226], N[Not[LessEqual[x, 1.5e+246]], $MachinePrecision]], t$95$0, N[(y * t$95$1), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \frac{y}{x}\\
t_1 := -0.16666666666666666 \cdot \left(x \cdot x\right)\\
\mathbf{if}\;x \leq 2.3 \cdot 10^{+102}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.8 \cdot 10^{+158}:\\
\;\;\;\;y \cdot \left(1 + t\_1\right)\\

\mathbf{elif}\;x \leq 1.75 \cdot 10^{+226} \lor \neg \left(x \leq 1.5 \cdot 10^{+246}\right):\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;y \cdot t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 2.2999999999999999e102 or 1.79999999999999994e158 < x < 1.7499999999999999e226 or 1.5e246 < x

    1. Initial program 85.5%

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

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

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

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

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

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

    if 2.2999999999999999e102 < x < 1.79999999999999994e158

    1. Initial program 99.8%

      \[\frac{\sin x \cdot \sinh y}{x} \]
    2. Step-by-step derivation
      1. associate-/l*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. Add Preprocessing
    5. Taylor expanded in y around 0 17.2%

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

        \[\leadsto \color{blue}{y \cdot \frac{\sin x}{x}} \]
    7. Simplified17.4%

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

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

        \[\leadsto y \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot -0.16666666666666666\right) \]
    10. Applied egg-rr59.0%

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

    if 1.7499999999999999e226 < x < 1.5e246

    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}{\sin x \cdot \frac{\sinh y}{x}} \]
    3. Simplified100.0%

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

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

        \[\leadsto \color{blue}{y \cdot \frac{\sin x}{x}} \]
    7. Simplified26.9%

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

      \[\leadsto y \cdot \color{blue}{\left(1 + -0.16666666666666666 \cdot {x}^{2}\right)} \]
    9. Taylor expanded in x around inf 25.4%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({x}^{2} \cdot y\right)} \]
    10. Step-by-step derivation
      1. associate-*r*25.4%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {x}^{2}\right) \cdot y} \]
      2. *-commutative25.4%

        \[\leadsto \color{blue}{y \cdot \left(-0.16666666666666666 \cdot {x}^{2}\right)} \]
      3. *-commutative25.4%

        \[\leadsto y \cdot \color{blue}{\left({x}^{2} \cdot -0.16666666666666666\right)} \]
    11. Simplified25.4%

      \[\leadsto \color{blue}{y \cdot \left({x}^{2} \cdot -0.16666666666666666\right)} \]
    12. Step-by-step derivation
      1. unpow225.4%

        \[\leadsto y \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot -0.16666666666666666\right) \]
    13. Applied egg-rr25.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.3 \cdot 10^{+102}:\\ \;\;\;\;x \cdot \frac{y}{x}\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{+158}:\\ \;\;\;\;y \cdot \left(1 + -0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{+226} \lor \neg \left(x \leq 1.5 \cdot 10^{+246}\right):\\ \;\;\;\;x \cdot \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 51.3% accurate, 12.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2.3 \cdot 10^{+102} \lor \neg \left(x \leq 1.65 \cdot 10^{+158}\right):\\ \;\;\;\;x \cdot \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= x 2.3e+102) (not (<= x 1.65e+158)))
   (* x (/ y x))
   (* y (* -0.16666666666666666 (* x x)))))
double code(double x, double y) {
	double tmp;
	if ((x <= 2.3e+102) || !(x <= 1.65e+158)) {
		tmp = x * (y / x);
	} else {
		tmp = y * (-0.16666666666666666 * (x * x));
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((x <= 2.3d+102) .or. (.not. (x <= 1.65d+158))) then
        tmp = x * (y / x)
    else
        tmp = y * ((-0.16666666666666666d0) * (x * x))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((x <= 2.3e+102) || !(x <= 1.65e+158)) {
		tmp = x * (y / x);
	} else {
		tmp = y * (-0.16666666666666666 * (x * x));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x <= 2.3e+102) or not (x <= 1.65e+158):
		tmp = x * (y / x)
	else:
		tmp = y * (-0.16666666666666666 * (x * x))
	return tmp
function code(x, y)
	tmp = 0.0
	if ((x <= 2.3e+102) || !(x <= 1.65e+158))
		tmp = Float64(x * Float64(y / x));
	else
		tmp = Float64(y * Float64(-0.16666666666666666 * Float64(x * x)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x <= 2.3e+102) || ~((x <= 1.65e+158)))
		tmp = x * (y / x);
	else
		tmp = y * (-0.16666666666666666 * (x * x));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[x, 2.3e+102], N[Not[LessEqual[x, 1.65e+158]], $MachinePrecision]], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], N[(y * N[(-0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.3 \cdot 10^{+102} \lor \neg \left(x \leq 1.65 \cdot 10^{+158}\right):\\
\;\;\;\;x \cdot \frac{y}{x}\\

\mathbf{else}:\\
\;\;\;\;y \cdot \left(-0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2.2999999999999999e102 or 1.65000000000000009e158 < x

    1. Initial program 85.8%

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{y}{x}} \]
      2. *-commutative54.6%

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

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

    if 2.2999999999999999e102 < x < 1.65000000000000009e158

    1. Initial program 99.8%

      \[\frac{\sin x \cdot \sinh y}{x} \]
    2. Step-by-step derivation
      1. associate-/l*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. Add Preprocessing
    5. Taylor expanded in y around 0 17.2%

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

        \[\leadsto \color{blue}{y \cdot \frac{\sin x}{x}} \]
    7. Simplified17.4%

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

      \[\leadsto y \cdot \color{blue}{\left(1 + -0.16666666666666666 \cdot {x}^{2}\right)} \]
    9. Taylor expanded in x around inf 59.0%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({x}^{2} \cdot y\right)} \]
    10. Step-by-step derivation
      1. associate-*r*59.0%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {x}^{2}\right) \cdot y} \]
      2. *-commutative59.0%

        \[\leadsto \color{blue}{y \cdot \left(-0.16666666666666666 \cdot {x}^{2}\right)} \]
      3. *-commutative59.0%

        \[\leadsto y \cdot \color{blue}{\left({x}^{2} \cdot -0.16666666666666666\right)} \]
    11. Simplified59.0%

      \[\leadsto \color{blue}{y \cdot \left({x}^{2} \cdot -0.16666666666666666\right)} \]
    12. Step-by-step derivation
      1. unpow259.0%

        \[\leadsto y \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot -0.16666666666666666\right) \]
    13. Applied egg-rr59.0%

      \[\leadsto y \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot -0.16666666666666666\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification54.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.3 \cdot 10^{+102} \lor \neg \left(x \leq 1.65 \cdot 10^{+158}\right):\\ \;\;\;\;x \cdot \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 51.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 86.1%

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

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

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

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

      \[\leadsto \color{blue}{\frac{y}{x} \cdot x} \]
  6. Applied egg-rr53.2%

    \[\leadsto \color{blue}{\frac{y}{x} \cdot x} \]
  7. Final simplification53.2%

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

Alternative 7: 28.8% 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 86.1%

    \[\frac{\sin x \cdot \sinh y}{x} \]
  2. Step-by-step derivation
    1. associate-/l*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. Add Preprocessing
  5. Taylor expanded in y around 0 36.2%

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

      \[\leadsto \color{blue}{y \cdot \frac{\sin x}{x}} \]
  7. Simplified50.0%

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

    \[\leadsto \color{blue}{y} \]
  9. Final simplification31.0%

    \[\leadsto y \]
  10. Add Preprocessing

Developer target: 99.8% 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 2024076 
(FPCore (x y)
  :name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
  :precision binary64

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

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