Linear.Quaternion:$csin from linear-1.19.1.3

Percentage Accurate: 100.0% → 100.0%
Time: 8.2s
Alternatives: 13
Speedup: 1.0×

Specification

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

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

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

    \[\cos x \cdot \frac{\sinh y}{y} \]
  2. Final simplification100.0%

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

Alternative 2: 84.5% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sinh y}{y}\\ t_1 := t_0 \cdot \left(1 + \left(x \cdot x\right) \cdot -0.5\right)\\ \mathbf{if}\;y \leq 90:\\ \;\;\;\;\cos x \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 10^{+136}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+154}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\cos x \cdot \left(y \cdot 0.16666666666666666\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ (sinh y) y)) (t_1 (* t_0 (+ 1.0 (* (* x x) -0.5)))))
   (if (<= y 90.0)
     (* (cos x) (+ 1.0 (* 0.16666666666666666 (* y y))))
     (if (<= y 1.8e+31)
       t_1
       (if (<= y 1e+136)
         t_0
         (if (<= y 5e+154)
           t_1
           (* y (* (cos x) (* y 0.16666666666666666)))))))))
double code(double x, double y) {
	double t_0 = sinh(y) / y;
	double t_1 = t_0 * (1.0 + ((x * x) * -0.5));
	double tmp;
	if (y <= 90.0) {
		tmp = cos(x) * (1.0 + (0.16666666666666666 * (y * y)));
	} else if (y <= 1.8e+31) {
		tmp = t_1;
	} else if (y <= 1e+136) {
		tmp = t_0;
	} else if (y <= 5e+154) {
		tmp = t_1;
	} else {
		tmp = y * (cos(x) * (y * 0.16666666666666666));
	}
	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 = sinh(y) / y
    t_1 = t_0 * (1.0d0 + ((x * x) * (-0.5d0)))
    if (y <= 90.0d0) then
        tmp = cos(x) * (1.0d0 + (0.16666666666666666d0 * (y * y)))
    else if (y <= 1.8d+31) then
        tmp = t_1
    else if (y <= 1d+136) then
        tmp = t_0
    else if (y <= 5d+154) then
        tmp = t_1
    else
        tmp = y * (cos(x) * (y * 0.16666666666666666d0))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = Math.sinh(y) / y;
	double t_1 = t_0 * (1.0 + ((x * x) * -0.5));
	double tmp;
	if (y <= 90.0) {
		tmp = Math.cos(x) * (1.0 + (0.16666666666666666 * (y * y)));
	} else if (y <= 1.8e+31) {
		tmp = t_1;
	} else if (y <= 1e+136) {
		tmp = t_0;
	} else if (y <= 5e+154) {
		tmp = t_1;
	} else {
		tmp = y * (Math.cos(x) * (y * 0.16666666666666666));
	}
	return tmp;
}
def code(x, y):
	t_0 = math.sinh(y) / y
	t_1 = t_0 * (1.0 + ((x * x) * -0.5))
	tmp = 0
	if y <= 90.0:
		tmp = math.cos(x) * (1.0 + (0.16666666666666666 * (y * y)))
	elif y <= 1.8e+31:
		tmp = t_1
	elif y <= 1e+136:
		tmp = t_0
	elif y <= 5e+154:
		tmp = t_1
	else:
		tmp = y * (math.cos(x) * (y * 0.16666666666666666))
	return tmp
function code(x, y)
	t_0 = Float64(sinh(y) / y)
	t_1 = Float64(t_0 * Float64(1.0 + Float64(Float64(x * x) * -0.5)))
	tmp = 0.0
	if (y <= 90.0)
		tmp = Float64(cos(x) * Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y))));
	elseif (y <= 1.8e+31)
		tmp = t_1;
	elseif (y <= 1e+136)
		tmp = t_0;
	elseif (y <= 5e+154)
		tmp = t_1;
	else
		tmp = Float64(y * Float64(cos(x) * Float64(y * 0.16666666666666666)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = sinh(y) / y;
	t_1 = t_0 * (1.0 + ((x * x) * -0.5));
	tmp = 0.0;
	if (y <= 90.0)
		tmp = cos(x) * (1.0 + (0.16666666666666666 * (y * y)));
	elseif (y <= 1.8e+31)
		tmp = t_1;
	elseif (y <= 1e+136)
		tmp = t_0;
	elseif (y <= 5e+154)
		tmp = t_1;
	else
		tmp = y * (cos(x) * (y * 0.16666666666666666));
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 90.0], N[(N[Cos[x], $MachinePrecision] * N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.8e+31], t$95$1, If[LessEqual[y, 1e+136], t$95$0, If[LessEqual[y, 5e+154], t$95$1, N[(y * N[(N[Cos[x], $MachinePrecision] * N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\sinh y}{y}\\
t_1 := t_0 \cdot \left(1 + \left(x \cdot x\right) \cdot -0.5\right)\\
\mathbf{if}\;y \leq 90:\\
\;\;\;\;\cos x \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\

\mathbf{elif}\;y \leq 1.8 \cdot 10^{+31}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 10^{+136}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 5 \cdot 10^{+154}:\\
\;\;\;\;t_1\\

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


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

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Taylor expanded in y around 0 84.5%

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

        \[\leadsto 1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)} \]
    4. Simplified84.5%

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

    if 90 < y < 1.79999999999999998e31 or 1.00000000000000006e136 < y < 5.00000000000000004e154

    1. Initial program 99.9%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Taylor expanded in x around 0 92.2%

      \[\leadsto \color{blue}{\left(1 + -0.5 \cdot {x}^{2}\right)} \cdot \frac{\sinh y}{y} \]
    3. Step-by-step derivation
      1. *-commutative18.6%

        \[\leadsto 1 + \color{blue}{{x}^{2} \cdot -0.5} \]
      2. unpow218.6%

        \[\leadsto 1 + \color{blue}{\left(x \cdot x\right)} \cdot -0.5 \]
    4. Simplified92.2%

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

    if 1.79999999999999998e31 < y < 1.00000000000000006e136

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Step-by-step derivation
      1. add-log-exp100.0%

        \[\leadsto \color{blue}{\log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      2. *-un-lft-identity100.0%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      3. log-prod100.0%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      4. metadata-eval100.0%

        \[\leadsto \color{blue}{0} + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right) \]
      5. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\cos x \cdot \frac{\sinh y}{y}} \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{0 + \cos x \cdot \frac{\sinh y}{y}} \]
    4. Step-by-step derivation
      1. +-lft-identity100.0%

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

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

        \[\leadsto \color{blue}{\frac{\cos x}{y} \cdot \sinh y} \]
      4. *-commutative100.0%

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

      \[\leadsto \color{blue}{\sinh y \cdot \frac{\cos x}{y}} \]
    6. Taylor expanded in x around 0 82.6%

      \[\leadsto \sinh y \cdot \color{blue}{\frac{1}{y}} \]
    7. Step-by-step derivation
      1. expm1-log1p-u82.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sinh y \cdot \frac{1}{y}\right)\right)} \]
      2. expm1-udef82.6%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sinh y \cdot \frac{1}{y}\right)} - 1} \]
      3. un-div-inv82.6%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sinh y}{y}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def82.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sinh y}{y}\right)\right)} \]
      2. expm1-log1p82.6%

        \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]
    10. Simplified82.6%

      \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]

    if 5.00000000000000004e154 < y

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Taylor expanded in y around 0 100.0%

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

        \[\leadsto 1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)} \]
    4. Simplified100.0%

      \[\leadsto \cos x \cdot \color{blue}{\left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)} \]
    5. Taylor expanded in y around inf 100.0%

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

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

        \[\leadsto \left(\cos x \cdot \color{blue}{\left(y \cdot y\right)}\right) \cdot 0.16666666666666666 \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(\left(\cos x \cdot y\right) \cdot y\right)} \cdot 0.16666666666666666 \]
      4. *-commutative100.0%

        \[\leadsto \left(\color{blue}{\left(y \cdot \cos x\right)} \cdot y\right) \cdot 0.16666666666666666 \]
      5. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(y \cdot \cos x\right) \cdot \left(y \cdot 0.16666666666666666\right)} \]
      6. associate-*l*100.0%

        \[\leadsto \color{blue}{y \cdot \left(\cos x \cdot \left(y \cdot 0.16666666666666666\right)\right)} \]
    7. Simplified100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 90:\\ \;\;\;\;\cos x \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+31}:\\ \;\;\;\;\frac{\sinh y}{y} \cdot \left(1 + \left(x \cdot x\right) \cdot -0.5\right)\\ \mathbf{elif}\;y \leq 10^{+136}:\\ \;\;\;\;\frac{\sinh y}{y}\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+154}:\\ \;\;\;\;\frac{\sinh y}{y} \cdot \left(1 + \left(x \cdot x\right) \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\cos x \cdot \left(y \cdot 0.16666666666666666\right)\right)\\ \end{array} \]

Alternative 3: 72.3% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 90:\\
\;\;\;\;\cos x\\

\mathbf{elif}\;y \leq 3.8 \cdot 10^{+154}:\\
\;\;\;\;\sinh y \cdot \frac{1}{y}\\

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


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

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Taylor expanded in y around 0 59.3%

      \[\leadsto \color{blue}{\cos x} \]

    if 90 < y < 3.7999999999999998e154

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Step-by-step derivation
      1. add-log-exp97.3%

        \[\leadsto \color{blue}{\log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      2. *-un-lft-identity97.3%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      3. log-prod97.3%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      4. metadata-eval97.3%

        \[\leadsto \color{blue}{0} + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right) \]
      5. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\cos x \cdot \frac{\sinh y}{y}} \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{0 + \cos x \cdot \frac{\sinh y}{y}} \]
    4. Step-by-step derivation
      1. +-lft-identity100.0%

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

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

        \[\leadsto \color{blue}{\frac{\cos x}{y} \cdot \sinh y} \]
      4. *-commutative100.0%

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

      \[\leadsto \color{blue}{\sinh y \cdot \frac{\cos x}{y}} \]
    6. Taylor expanded in x around 0 72.2%

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

    if 3.7999999999999998e154 < y

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Taylor expanded in y around 0 100.0%

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

        \[\leadsto 1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)} \]
    4. Simplified100.0%

      \[\leadsto \cos x \cdot \color{blue}{\left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)} \]
    5. Taylor expanded in y around inf 100.0%

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

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

        \[\leadsto \left(\cos x \cdot \color{blue}{\left(y \cdot y\right)}\right) \cdot 0.16666666666666666 \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(\left(\cos x \cdot y\right) \cdot y\right)} \cdot 0.16666666666666666 \]
      4. *-commutative100.0%

        \[\leadsto \left(\color{blue}{\left(y \cdot \cos x\right)} \cdot y\right) \cdot 0.16666666666666666 \]
      5. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(y \cdot \cos x\right) \cdot \left(y \cdot 0.16666666666666666\right)} \]
      6. associate-*l*100.0%

        \[\leadsto \color{blue}{y \cdot \left(\cos x \cdot \left(y \cdot 0.16666666666666666\right)\right)} \]
    7. Simplified100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 90:\\ \;\;\;\;\cos x\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{+154}:\\ \;\;\;\;\sinh y \cdot \frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\cos x \cdot \left(y \cdot 0.16666666666666666\right)\right)\\ \end{array} \]

Alternative 4: 84.7% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 90:\\
\;\;\;\;\cos x \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\

\mathbf{elif}\;y \leq 3.3 \cdot 10^{+154}:\\
\;\;\;\;\sinh y \cdot \frac{1}{y}\\

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


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

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Taylor expanded in y around 0 84.5%

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

        \[\leadsto 1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)} \]
    4. Simplified84.5%

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

    if 90 < y < 3.3e154

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Step-by-step derivation
      1. add-log-exp97.3%

        \[\leadsto \color{blue}{\log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      2. *-un-lft-identity97.3%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      3. log-prod97.3%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      4. metadata-eval97.3%

        \[\leadsto \color{blue}{0} + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right) \]
      5. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\cos x \cdot \frac{\sinh y}{y}} \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{0 + \cos x \cdot \frac{\sinh y}{y}} \]
    4. Step-by-step derivation
      1. +-lft-identity100.0%

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

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

        \[\leadsto \color{blue}{\frac{\cos x}{y} \cdot \sinh y} \]
      4. *-commutative100.0%

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

      \[\leadsto \color{blue}{\sinh y \cdot \frac{\cos x}{y}} \]
    6. Taylor expanded in x around 0 72.2%

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

    if 3.3e154 < y

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Taylor expanded in y around 0 100.0%

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

        \[\leadsto 1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)} \]
    4. Simplified100.0%

      \[\leadsto \cos x \cdot \color{blue}{\left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)} \]
    5. Taylor expanded in y around inf 100.0%

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

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

        \[\leadsto \left(\cos x \cdot \color{blue}{\left(y \cdot y\right)}\right) \cdot 0.16666666666666666 \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(\left(\cos x \cdot y\right) \cdot y\right)} \cdot 0.16666666666666666 \]
      4. *-commutative100.0%

        \[\leadsto \left(\color{blue}{\left(y \cdot \cos x\right)} \cdot y\right) \cdot 0.16666666666666666 \]
      5. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(y \cdot \cos x\right) \cdot \left(y \cdot 0.16666666666666666\right)} \]
      6. associate-*l*100.0%

        \[\leadsto \color{blue}{y \cdot \left(\cos x \cdot \left(y \cdot 0.16666666666666666\right)\right)} \]
    7. Simplified100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 90:\\ \;\;\;\;\cos x \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{+154}:\\ \;\;\;\;\sinh y \cdot \frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\cos x \cdot \left(y \cdot 0.16666666666666666\right)\right)\\ \end{array} \]

Alternative 5: 69.3% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 90:\\ \;\;\;\;\cos x\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{+166} \lor \neg \left(y \leq 2.25 \cdot 10^{+275}\right):\\ \;\;\;\;\frac{\sinh y}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \cdot \left(1 + \left(x \cdot x\right) \cdot -0.5\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y 90.0)
   (cos x)
   (if (or (<= y 4.3e+166) (not (<= y 2.25e+275)))
     (/ (sinh y) y)
     (* (+ 1.0 (* 0.16666666666666666 (* y y))) (+ 1.0 (* (* x x) -0.5))))))
double code(double x, double y) {
	double tmp;
	if (y <= 90.0) {
		tmp = cos(x);
	} else if ((y <= 4.3e+166) || !(y <= 2.25e+275)) {
		tmp = sinh(y) / y;
	} else {
		tmp = (1.0 + (0.16666666666666666 * (y * y))) * (1.0 + ((x * x) * -0.5));
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= 90.0d0) then
        tmp = cos(x)
    else if ((y <= 4.3d+166) .or. (.not. (y <= 2.25d+275))) then
        tmp = sinh(y) / y
    else
        tmp = (1.0d0 + (0.16666666666666666d0 * (y * y))) * (1.0d0 + ((x * x) * (-0.5d0)))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= 90.0) {
		tmp = Math.cos(x);
	} else if ((y <= 4.3e+166) || !(y <= 2.25e+275)) {
		tmp = Math.sinh(y) / y;
	} else {
		tmp = (1.0 + (0.16666666666666666 * (y * y))) * (1.0 + ((x * x) * -0.5));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= 90.0:
		tmp = math.cos(x)
	elif (y <= 4.3e+166) or not (y <= 2.25e+275):
		tmp = math.sinh(y) / y
	else:
		tmp = (1.0 + (0.16666666666666666 * (y * y))) * (1.0 + ((x * x) * -0.5))
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= 90.0)
		tmp = cos(x);
	elseif ((y <= 4.3e+166) || !(y <= 2.25e+275))
		tmp = Float64(sinh(y) / y);
	else
		tmp = Float64(Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y))) * Float64(1.0 + Float64(Float64(x * x) * -0.5)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= 90.0)
		tmp = cos(x);
	elseif ((y <= 4.3e+166) || ~((y <= 2.25e+275)))
		tmp = sinh(y) / y;
	else
		tmp = (1.0 + (0.16666666666666666 * (y * y))) * (1.0 + ((x * x) * -0.5));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, 90.0], N[Cos[x], $MachinePrecision], If[Or[LessEqual[y, 4.3e+166], N[Not[LessEqual[y, 2.25e+275]], $MachinePrecision]], N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision], N[(N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 90:\\
\;\;\;\;\cos x\\

\mathbf{elif}\;y \leq 4.3 \cdot 10^{+166} \lor \neg \left(y \leq 2.25 \cdot 10^{+275}\right):\\
\;\;\;\;\frac{\sinh y}{y}\\

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


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

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Taylor expanded in y around 0 59.3%

      \[\leadsto \color{blue}{\cos x} \]

    if 90 < y < 4.3e166 or 2.24999999999999987e275 < y

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Step-by-step derivation
      1. add-log-exp97.8%

        \[\leadsto \color{blue}{\log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      2. *-un-lft-identity97.8%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      3. log-prod97.8%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      4. metadata-eval97.8%

        \[\leadsto \color{blue}{0} + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right) \]
      5. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\cos x \cdot \frac{\sinh y}{y}} \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{0 + \cos x \cdot \frac{\sinh y}{y}} \]
    4. Step-by-step derivation
      1. +-lft-identity100.0%

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

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

        \[\leadsto \color{blue}{\frac{\cos x}{y} \cdot \sinh y} \]
      4. *-commutative100.0%

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

      \[\leadsto \color{blue}{\sinh y \cdot \frac{\cos x}{y}} \]
    6. Taylor expanded in x around 0 74.4%

      \[\leadsto \sinh y \cdot \color{blue}{\frac{1}{y}} \]
    7. Step-by-step derivation
      1. expm1-log1p-u74.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sinh y \cdot \frac{1}{y}\right)\right)} \]
      2. expm1-udef74.2%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sinh y \cdot \frac{1}{y}\right)} - 1} \]
      3. un-div-inv74.2%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sinh y}{y}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def74.2%

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

        \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]
    10. Simplified74.4%

      \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]

    if 4.3e166 < y < 2.24999999999999987e275

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Taylor expanded in y around 0 100.0%

      \[\leadsto \cos x \cdot \color{blue}{\left(1 + 0.16666666666666666 \cdot {y}^{2}\right)} \]
    3. Step-by-step derivation
      1. unpow255.6%

        \[\leadsto 1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)} \]
    4. Simplified100.0%

      \[\leadsto \cos x \cdot \color{blue}{\left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)} \]
    5. Taylor expanded in x around 0 72.2%

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

        \[\leadsto 1 + \color{blue}{{x}^{2} \cdot -0.5} \]
      2. unpow219.0%

        \[\leadsto 1 + \color{blue}{\left(x \cdot x\right)} \cdot -0.5 \]
    7. Simplified72.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 90:\\ \;\;\;\;\cos x\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{+166} \lor \neg \left(y \leq 2.25 \cdot 10^{+275}\right):\\ \;\;\;\;\frac{\sinh y}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \cdot \left(1 + \left(x \cdot x\right) \cdot -0.5\right)\\ \end{array} \]

Alternative 6: 69.2% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 90:\\ \;\;\;\;\cos x\\ \mathbf{elif}\;y \leq 10^{+165}:\\ \;\;\;\;\sinh y \cdot \frac{1}{y}\\ \mathbf{elif}\;y \leq 2.45 \cdot 10^{+275}:\\ \;\;\;\;\left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \cdot \left(1 + \left(x \cdot x\right) \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sinh y}{y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y 90.0)
   (cos x)
   (if (<= y 1e+165)
     (* (sinh y) (/ 1.0 y))
     (if (<= y 2.45e+275)
       (* (+ 1.0 (* 0.16666666666666666 (* y y))) (+ 1.0 (* (* x x) -0.5)))
       (/ (sinh y) y)))))
double code(double x, double y) {
	double tmp;
	if (y <= 90.0) {
		tmp = cos(x);
	} else if (y <= 1e+165) {
		tmp = sinh(y) * (1.0 / y);
	} else if (y <= 2.45e+275) {
		tmp = (1.0 + (0.16666666666666666 * (y * y))) * (1.0 + ((x * x) * -0.5));
	} else {
		tmp = sinh(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 <= 90.0d0) then
        tmp = cos(x)
    else if (y <= 1d+165) then
        tmp = sinh(y) * (1.0d0 / y)
    else if (y <= 2.45d+275) then
        tmp = (1.0d0 + (0.16666666666666666d0 * (y * y))) * (1.0d0 + ((x * x) * (-0.5d0)))
    else
        tmp = sinh(y) / y
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= 90.0) {
		tmp = Math.cos(x);
	} else if (y <= 1e+165) {
		tmp = Math.sinh(y) * (1.0 / y);
	} else if (y <= 2.45e+275) {
		tmp = (1.0 + (0.16666666666666666 * (y * y))) * (1.0 + ((x * x) * -0.5));
	} else {
		tmp = Math.sinh(y) / y;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= 90.0:
		tmp = math.cos(x)
	elif y <= 1e+165:
		tmp = math.sinh(y) * (1.0 / y)
	elif y <= 2.45e+275:
		tmp = (1.0 + (0.16666666666666666 * (y * y))) * (1.0 + ((x * x) * -0.5))
	else:
		tmp = math.sinh(y) / y
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= 90.0)
		tmp = cos(x);
	elseif (y <= 1e+165)
		tmp = Float64(sinh(y) * Float64(1.0 / y));
	elseif (y <= 2.45e+275)
		tmp = Float64(Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y))) * Float64(1.0 + Float64(Float64(x * x) * -0.5)));
	else
		tmp = Float64(sinh(y) / y);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= 90.0)
		tmp = cos(x);
	elseif (y <= 1e+165)
		tmp = sinh(y) * (1.0 / y);
	elseif (y <= 2.45e+275)
		tmp = (1.0 + (0.16666666666666666 * (y * y))) * (1.0 + ((x * x) * -0.5));
	else
		tmp = sinh(y) / y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, 90.0], N[Cos[x], $MachinePrecision], If[LessEqual[y, 1e+165], N[(N[Sinh[y], $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.45e+275], N[(N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 90:\\
\;\;\;\;\cos x\\

\mathbf{elif}\;y \leq 10^{+165}:\\
\;\;\;\;\sinh y \cdot \frac{1}{y}\\

\mathbf{elif}\;y \leq 2.45 \cdot 10^{+275}:\\
\;\;\;\;\left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \cdot \left(1 + \left(x \cdot x\right) \cdot -0.5\right)\\

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


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

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Taylor expanded in y around 0 59.3%

      \[\leadsto \color{blue}{\cos x} \]

    if 90 < y < 9.99999999999999899e164

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Step-by-step derivation
      1. add-log-exp97.5%

        \[\leadsto \color{blue}{\log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      2. *-un-lft-identity97.5%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      3. log-prod97.5%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      4. metadata-eval97.5%

        \[\leadsto \color{blue}{0} + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right) \]
      5. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\cos x \cdot \frac{\sinh y}{y}} \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{0 + \cos x \cdot \frac{\sinh y}{y}} \]
    4. Step-by-step derivation
      1. +-lft-identity100.0%

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

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

        \[\leadsto \color{blue}{\frac{\cos x}{y} \cdot \sinh y} \]
      4. *-commutative100.0%

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

      \[\leadsto \color{blue}{\sinh y \cdot \frac{\cos x}{y}} \]
    6. Taylor expanded in x around 0 73.7%

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

    if 9.99999999999999899e164 < y < 2.4499999999999999e275

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Taylor expanded in y around 0 100.0%

      \[\leadsto \cos x \cdot \color{blue}{\left(1 + 0.16666666666666666 \cdot {y}^{2}\right)} \]
    3. Step-by-step derivation
      1. unpow255.6%

        \[\leadsto 1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)} \]
    4. Simplified100.0%

      \[\leadsto \cos x \cdot \color{blue}{\left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)} \]
    5. Taylor expanded in x around 0 72.2%

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

        \[\leadsto 1 + \color{blue}{{x}^{2} \cdot -0.5} \]
      2. unpow219.0%

        \[\leadsto 1 + \color{blue}{\left(x \cdot x\right)} \cdot -0.5 \]
    7. Simplified72.2%

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

    if 2.4499999999999999e275 < y

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Step-by-step derivation
      1. add-log-exp100.0%

        \[\leadsto \color{blue}{\log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      2. *-un-lft-identity100.0%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      3. log-prod100.0%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      4. metadata-eval100.0%

        \[\leadsto \color{blue}{0} + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right) \]
      5. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\cos x \cdot \frac{\sinh y}{y}} \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{0 + \cos x \cdot \frac{\sinh y}{y}} \]
    4. Step-by-step derivation
      1. +-lft-identity100.0%

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

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

        \[\leadsto \color{blue}{\frac{\cos x}{y} \cdot \sinh y} \]
      4. *-commutative100.0%

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

      \[\leadsto \color{blue}{\sinh y \cdot \frac{\cos x}{y}} \]
    6. Taylor expanded in x around 0 80.0%

      \[\leadsto \sinh y \cdot \color{blue}{\frac{1}{y}} \]
    7. Step-by-step derivation
      1. expm1-log1p-u80.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sinh y \cdot \frac{1}{y}\right)\right)} \]
      2. expm1-udef80.0%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sinh y \cdot \frac{1}{y}\right)} - 1} \]
      3. un-div-inv80.0%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sinh y}{y}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def80.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sinh y}{y}\right)\right)} \]
      2. expm1-log1p80.0%

        \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]
    10. Simplified80.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 90:\\ \;\;\;\;\cos x\\ \mathbf{elif}\;y \leq 10^{+165}:\\ \;\;\;\;\sinh y \cdot \frac{1}{y}\\ \mathbf{elif}\;y \leq 2.45 \cdot 10^{+275}:\\ \;\;\;\;\left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \cdot \left(1 + \left(x \cdot x\right) \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sinh y}{y}\\ \end{array} \]

Alternative 7: 62.6% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\ \mathbf{if}\;y \leq 115:\\ \;\;\;\;\cos x\\ \mathbf{elif}\;y \leq 10^{+275}:\\ \;\;\;\;t_0 \cdot \left(1 + \left(x \cdot x\right) \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ 1.0 (* 0.16666666666666666 (* y y)))))
   (if (<= y 115.0)
     (cos x)
     (if (<= y 1e+275) (* t_0 (+ 1.0 (* (* x x) -0.5))) t_0))))
double code(double x, double y) {
	double t_0 = 1.0 + (0.16666666666666666 * (y * y));
	double tmp;
	if (y <= 115.0) {
		tmp = cos(x);
	} else if (y <= 1e+275) {
		tmp = t_0 * (1.0 + ((x * x) * -0.5));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 + (0.16666666666666666d0 * (y * y))
    if (y <= 115.0d0) then
        tmp = cos(x)
    else if (y <= 1d+275) then
        tmp = t_0 * (1.0d0 + ((x * x) * (-0.5d0)))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = 1.0 + (0.16666666666666666 * (y * y));
	double tmp;
	if (y <= 115.0) {
		tmp = Math.cos(x);
	} else if (y <= 1e+275) {
		tmp = t_0 * (1.0 + ((x * x) * -0.5));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 + (0.16666666666666666 * (y * y))
	tmp = 0
	if y <= 115.0:
		tmp = math.cos(x)
	elif y <= 1e+275:
		tmp = t_0 * (1.0 + ((x * x) * -0.5))
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)))
	tmp = 0.0
	if (y <= 115.0)
		tmp = cos(x);
	elseif (y <= 1e+275)
		tmp = Float64(t_0 * Float64(1.0 + Float64(Float64(x * x) * -0.5)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = 1.0 + (0.16666666666666666 * (y * y));
	tmp = 0.0;
	if (y <= 115.0)
		tmp = cos(x);
	elseif (y <= 1e+275)
		tmp = t_0 * (1.0 + ((x * x) * -0.5));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 115.0], N[Cos[x], $MachinePrecision], If[LessEqual[y, 1e+275], N[(t$95$0 * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\
\mathbf{if}\;y \leq 115:\\
\;\;\;\;\cos x\\

\mathbf{elif}\;y \leq 10^{+275}:\\
\;\;\;\;t_0 \cdot \left(1 + \left(x \cdot x\right) \cdot -0.5\right)\\

\mathbf{else}:\\
\;\;\;\;t_0\\


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

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Taylor expanded in y around 0 59.3%

      \[\leadsto \color{blue}{\cos x} \]

    if 115 < y < 9.9999999999999996e274

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Taylor expanded in y around 0 39.2%

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

        \[\leadsto 1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)} \]
    4. Simplified39.2%

      \[\leadsto \cos x \cdot \color{blue}{\left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)} \]
    5. Taylor expanded in x around 0 38.1%

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

        \[\leadsto 1 + \color{blue}{{x}^{2} \cdot -0.5} \]
      2. unpow214.9%

        \[\leadsto 1 + \color{blue}{\left(x \cdot x\right)} \cdot -0.5 \]
    7. Simplified38.1%

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

    if 9.9999999999999996e274 < y

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Step-by-step derivation
      1. add-log-exp100.0%

        \[\leadsto \color{blue}{\log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      2. *-un-lft-identity100.0%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      3. log-prod100.0%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      4. metadata-eval100.0%

        \[\leadsto \color{blue}{0} + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right) \]
      5. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\cos x \cdot \frac{\sinh y}{y}} \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{0 + \cos x \cdot \frac{\sinh y}{y}} \]
    4. Step-by-step derivation
      1. +-lft-identity100.0%

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

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

        \[\leadsto \color{blue}{\frac{\cos x}{y} \cdot \sinh y} \]
      4. *-commutative100.0%

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

      \[\leadsto \color{blue}{\sinh y \cdot \frac{\cos x}{y}} \]
    6. Taylor expanded in x around 0 80.0%

      \[\leadsto \sinh y \cdot \color{blue}{\frac{1}{y}} \]
    7. Step-by-step derivation
      1. expm1-log1p-u80.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sinh y \cdot \frac{1}{y}\right)\right)} \]
      2. expm1-udef80.0%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sinh y \cdot \frac{1}{y}\right)} - 1} \]
      3. un-div-inv80.0%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sinh y}{y}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def80.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sinh y}{y}\right)\right)} \]
      2. expm1-log1p80.0%

        \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]
    10. Simplified80.0%

      \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]
    11. Taylor expanded in y around 0 80.0%

      \[\leadsto \color{blue}{1 + 0.16666666666666666 \cdot {y}^{2}} \]
    12. Step-by-step derivation
      1. unpow280.0%

        \[\leadsto 1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)} \]
    13. Simplified80.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 115:\\ \;\;\;\;\cos x\\ \mathbf{elif}\;y \leq 10^{+275}:\\ \;\;\;\;\left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \cdot \left(1 + \left(x \cdot x\right) \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\ \end{array} \]

Alternative 8: 49.8% accurate, 10.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\ \mathbf{if}\;y \leq 1.25 \cdot 10^{+275}:\\ \;\;\;\;t_0 \cdot \left(\left(2 + x \cdot \left(x \cdot -0.5\right)\right) + -1\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ 1.0 (* 0.16666666666666666 (* y y)))))
   (if (<= y 1.25e+275) (* t_0 (+ (+ 2.0 (* x (* x -0.5))) -1.0)) t_0)))
double code(double x, double y) {
	double t_0 = 1.0 + (0.16666666666666666 * (y * y));
	double tmp;
	if (y <= 1.25e+275) {
		tmp = t_0 * ((2.0 + (x * (x * -0.5))) + -1.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 + (0.16666666666666666d0 * (y * y))
    if (y <= 1.25d+275) then
        tmp = t_0 * ((2.0d0 + (x * (x * (-0.5d0)))) + (-1.0d0))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = 1.0 + (0.16666666666666666 * (y * y));
	double tmp;
	if (y <= 1.25e+275) {
		tmp = t_0 * ((2.0 + (x * (x * -0.5))) + -1.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 + (0.16666666666666666 * (y * y))
	tmp = 0
	if y <= 1.25e+275:
		tmp = t_0 * ((2.0 + (x * (x * -0.5))) + -1.0)
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)))
	tmp = 0.0
	if (y <= 1.25e+275)
		tmp = Float64(t_0 * Float64(Float64(2.0 + Float64(x * Float64(x * -0.5))) + -1.0));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = 1.0 + (0.16666666666666666 * (y * y));
	tmp = 0.0;
	if (y <= 1.25e+275)
		tmp = t_0 * ((2.0 + (x * (x * -0.5))) + -1.0);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 1.25e+275], N[(t$95$0 * N[(N[(2.0 + N[(x * N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\
\mathbf{if}\;y \leq 1.25 \cdot 10^{+275}:\\
\;\;\;\;t_0 \cdot \left(\left(2 + x \cdot \left(x \cdot -0.5\right)\right) + -1\right)\\

\mathbf{else}:\\
\;\;\;\;t_0\\


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

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Taylor expanded in y around 0 74.4%

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

        \[\leadsto 1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)} \]
    4. Simplified74.4%

      \[\leadsto \cos x \cdot \color{blue}{\left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u74.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos x\right)\right)} \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \]
      2. expm1-udef74.3%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\cos x\right)} - 1\right)} \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \]
      3. log1p-udef74.3%

        \[\leadsto \left(e^{\color{blue}{\log \left(1 + \cos x\right)}} - 1\right) \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \]
      4. rem-exp-log74.3%

        \[\leadsto \left(\color{blue}{\left(1 + \cos x\right)} - 1\right) \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \]
    6. Applied egg-rr74.3%

      \[\leadsto \color{blue}{\left(\left(1 + \cos x\right) - 1\right)} \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \]
    7. Taylor expanded in x around 0 47.0%

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

        \[\leadsto \left(\left(2 + \color{blue}{{x}^{2} \cdot -0.5}\right) - 1\right) \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \]
      2. unpow247.0%

        \[\leadsto \left(\left(2 + \color{blue}{\left(x \cdot x\right)} \cdot -0.5\right) - 1\right) \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \]
      3. associate-*r*47.0%

        \[\leadsto \left(\left(2 + \color{blue}{x \cdot \left(x \cdot -0.5\right)}\right) - 1\right) \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \]
      4. *-commutative47.0%

        \[\leadsto \left(\left(2 + x \cdot \color{blue}{\left(-0.5 \cdot x\right)}\right) - 1\right) \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \]
    9. Simplified47.0%

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

    if 1.2500000000000001e275 < y

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Step-by-step derivation
      1. add-log-exp100.0%

        \[\leadsto \color{blue}{\log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      2. *-un-lft-identity100.0%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      3. log-prod100.0%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      4. metadata-eval100.0%

        \[\leadsto \color{blue}{0} + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right) \]
      5. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\cos x \cdot \frac{\sinh y}{y}} \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{0 + \cos x \cdot \frac{\sinh y}{y}} \]
    4. Step-by-step derivation
      1. +-lft-identity100.0%

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

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

        \[\leadsto \color{blue}{\frac{\cos x}{y} \cdot \sinh y} \]
      4. *-commutative100.0%

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

      \[\leadsto \color{blue}{\sinh y \cdot \frac{\cos x}{y}} \]
    6. Taylor expanded in x around 0 80.0%

      \[\leadsto \sinh y \cdot \color{blue}{\frac{1}{y}} \]
    7. Step-by-step derivation
      1. expm1-log1p-u80.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sinh y \cdot \frac{1}{y}\right)\right)} \]
      2. expm1-udef80.0%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sinh y \cdot \frac{1}{y}\right)} - 1} \]
      3. un-div-inv80.0%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sinh y}{y}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def80.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sinh y}{y}\right)\right)} \]
      2. expm1-log1p80.0%

        \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]
    10. Simplified80.0%

      \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]
    11. Taylor expanded in y around 0 80.0%

      \[\leadsto \color{blue}{1 + 0.16666666666666666 \cdot {y}^{2}} \]
    12. Step-by-step derivation
      1. unpow280.0%

        \[\leadsto 1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)} \]
    13. Simplified80.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.25 \cdot 10^{+275}:\\ \;\;\;\;\left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \cdot \left(\left(2 + x \cdot \left(x \cdot -0.5\right)\right) + -1\right)\\ \mathbf{else}:\\ \;\;\;\;1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\ \end{array} \]

Alternative 9: 49.8% accurate, 12.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\ \mathbf{if}\;y \leq 1.1 \cdot 10^{+275}:\\ \;\;\;\;t_0 \cdot \left(1 + \left(x \cdot x\right) \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ 1.0 (* 0.16666666666666666 (* y y)))))
   (if (<= y 1.1e+275) (* t_0 (+ 1.0 (* (* x x) -0.5))) t_0)))
double code(double x, double y) {
	double t_0 = 1.0 + (0.16666666666666666 * (y * y));
	double tmp;
	if (y <= 1.1e+275) {
		tmp = t_0 * (1.0 + ((x * x) * -0.5));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 + (0.16666666666666666d0 * (y * y))
    if (y <= 1.1d+275) then
        tmp = t_0 * (1.0d0 + ((x * x) * (-0.5d0)))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = 1.0 + (0.16666666666666666 * (y * y));
	double tmp;
	if (y <= 1.1e+275) {
		tmp = t_0 * (1.0 + ((x * x) * -0.5));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 + (0.16666666666666666 * (y * y))
	tmp = 0
	if y <= 1.1e+275:
		tmp = t_0 * (1.0 + ((x * x) * -0.5))
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)))
	tmp = 0.0
	if (y <= 1.1e+275)
		tmp = Float64(t_0 * Float64(1.0 + Float64(Float64(x * x) * -0.5)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = 1.0 + (0.16666666666666666 * (y * y));
	tmp = 0.0;
	if (y <= 1.1e+275)
		tmp = t_0 * (1.0 + ((x * x) * -0.5));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 1.1e+275], N[(t$95$0 * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\
\mathbf{if}\;y \leq 1.1 \cdot 10^{+275}:\\
\;\;\;\;t_0 \cdot \left(1 + \left(x \cdot x\right) \cdot -0.5\right)\\

\mathbf{else}:\\
\;\;\;\;t_0\\


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

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Taylor expanded in y around 0 74.4%

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

        \[\leadsto 1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)} \]
    4. Simplified74.4%

      \[\leadsto \cos x \cdot \color{blue}{\left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)} \]
    5. Taylor expanded in x around 0 47.0%

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

        \[\leadsto 1 + \color{blue}{{x}^{2} \cdot -0.5} \]
      2. unpow231.6%

        \[\leadsto 1 + \color{blue}{\left(x \cdot x\right)} \cdot -0.5 \]
    7. Simplified47.0%

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

    if 1.1e275 < y

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Step-by-step derivation
      1. add-log-exp100.0%

        \[\leadsto \color{blue}{\log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      2. *-un-lft-identity100.0%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      3. log-prod100.0%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      4. metadata-eval100.0%

        \[\leadsto \color{blue}{0} + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right) \]
      5. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\cos x \cdot \frac{\sinh y}{y}} \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{0 + \cos x \cdot \frac{\sinh y}{y}} \]
    4. Step-by-step derivation
      1. +-lft-identity100.0%

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

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

        \[\leadsto \color{blue}{\frac{\cos x}{y} \cdot \sinh y} \]
      4. *-commutative100.0%

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

      \[\leadsto \color{blue}{\sinh y \cdot \frac{\cos x}{y}} \]
    6. Taylor expanded in x around 0 80.0%

      \[\leadsto \sinh y \cdot \color{blue}{\frac{1}{y}} \]
    7. Step-by-step derivation
      1. expm1-log1p-u80.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sinh y \cdot \frac{1}{y}\right)\right)} \]
      2. expm1-udef80.0%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sinh y \cdot \frac{1}{y}\right)} - 1} \]
      3. un-div-inv80.0%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sinh y}{y}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def80.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sinh y}{y}\right)\right)} \]
      2. expm1-log1p80.0%

        \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]
    10. Simplified80.0%

      \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]
    11. Taylor expanded in y around 0 80.0%

      \[\leadsto \color{blue}{1 + 0.16666666666666666 \cdot {y}^{2}} \]
    12. Step-by-step derivation
      1. unpow280.0%

        \[\leadsto 1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)} \]
    13. Simplified80.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.1 \cdot 10^{+275}:\\ \;\;\;\;\left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \cdot \left(1 + \left(x \cdot x\right) \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\ \end{array} \]

Alternative 10: 48.8% accurate, 13.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\ \mathbf{if}\;x \leq 1.4 \cdot 10^{+81}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(\left(x \cdot x\right) \cdot -0.5\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ 1.0 (* 0.16666666666666666 (* y y)))))
   (if (<= x 1.4e+81) t_0 (* t_0 (* (* x x) -0.5)))))
double code(double x, double y) {
	double t_0 = 1.0 + (0.16666666666666666 * (y * y));
	double tmp;
	if (x <= 1.4e+81) {
		tmp = t_0;
	} else {
		tmp = t_0 * ((x * x) * -0.5);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 + (0.16666666666666666d0 * (y * y))
    if (x <= 1.4d+81) then
        tmp = t_0
    else
        tmp = t_0 * ((x * x) * (-0.5d0))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = 1.0 + (0.16666666666666666 * (y * y));
	double tmp;
	if (x <= 1.4e+81) {
		tmp = t_0;
	} else {
		tmp = t_0 * ((x * x) * -0.5);
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 + (0.16666666666666666 * (y * y))
	tmp = 0
	if x <= 1.4e+81:
		tmp = t_0
	else:
		tmp = t_0 * ((x * x) * -0.5)
	return tmp
function code(x, y)
	t_0 = Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)))
	tmp = 0.0
	if (x <= 1.4e+81)
		tmp = t_0;
	else
		tmp = Float64(t_0 * Float64(Float64(x * x) * -0.5));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = 1.0 + (0.16666666666666666 * (y * y));
	tmp = 0.0;
	if (x <= 1.4e+81)
		tmp = t_0;
	else
		tmp = t_0 * ((x * x) * -0.5);
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.4e+81], t$95$0, N[(t$95$0 * N[(N[(x * x), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\
\mathbf{if}\;x \leq 1.4 \cdot 10^{+81}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(\left(x \cdot x\right) \cdot -0.5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.39999999999999997e81

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Step-by-step derivation
      1. add-log-exp98.5%

        \[\leadsto \color{blue}{\log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      2. *-un-lft-identity98.5%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      3. log-prod98.5%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      4. metadata-eval98.5%

        \[\leadsto \color{blue}{0} + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right) \]
      5. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\cos x \cdot \frac{\sinh y}{y}} \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{0 + \cos x \cdot \frac{\sinh y}{y}} \]
    4. Step-by-step derivation
      1. +-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{\cos x \cdot \sinh y}{y}} \]
      3. associate-*l/99.9%

        \[\leadsto \color{blue}{\frac{\cos x}{y} \cdot \sinh y} \]
      4. *-commutative99.9%

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

      \[\leadsto \color{blue}{\sinh y \cdot \frac{\cos x}{y}} \]
    6. Taylor expanded in x around 0 72.3%

      \[\leadsto \sinh y \cdot \color{blue}{\frac{1}{y}} \]
    7. Step-by-step derivation
      1. expm1-log1p-u72.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sinh y \cdot \frac{1}{y}\right)\right)} \]
      2. expm1-udef72.3%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sinh y \cdot \frac{1}{y}\right)} - 1} \]
      3. un-div-inv72.3%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sinh y}{y}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def72.3%

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

        \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]
    10. Simplified72.3%

      \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]
    11. Taylor expanded in y around 0 51.6%

      \[\leadsto \color{blue}{1 + 0.16666666666666666 \cdot {y}^{2}} \]
    12. Step-by-step derivation
      1. unpow251.6%

        \[\leadsto 1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)} \]
    13. Simplified51.6%

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

    if 1.39999999999999997e81 < x

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Taylor expanded in y around 0 79.4%

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

        \[\leadsto 1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)} \]
    4. Simplified79.4%

      \[\leadsto \cos x \cdot \color{blue}{\left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u79.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos x\right)\right)} \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \]
      2. expm1-udef79.1%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\cos x\right)} - 1\right)} \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \]
      3. log1p-udef79.1%

        \[\leadsto \left(e^{\color{blue}{\log \left(1 + \cos x\right)}} - 1\right) \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \]
      4. rem-exp-log79.1%

        \[\leadsto \left(\color{blue}{\left(1 + \cos x\right)} - 1\right) \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \]
    6. Applied egg-rr79.1%

      \[\leadsto \color{blue}{\left(\left(1 + \cos x\right) - 1\right)} \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \]
    7. Taylor expanded in x around 0 29.5%

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

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

        \[\leadsto \left(\left(2 + \color{blue}{\left(x \cdot x\right)} \cdot -0.5\right) - 1\right) \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \]
      3. associate-*r*29.5%

        \[\leadsto \left(\left(2 + \color{blue}{x \cdot \left(x \cdot -0.5\right)}\right) - 1\right) \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \]
      4. *-commutative29.5%

        \[\leadsto \left(\left(2 + x \cdot \color{blue}{\left(-0.5 \cdot x\right)}\right) - 1\right) \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \]
    9. Simplified29.5%

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

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

        \[\leadsto \left(-0.5 \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \]
    12. Simplified29.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.4 \cdot 10^{+81}:\\ \;\;\;\;1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right) \cdot \left(\left(x \cdot x\right) \cdot -0.5\right)\\ \end{array} \]

Alternative 11: 47.6% accurate, 18.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.7 \cdot 10^{+149} \lor \neg \left(x \leq 8.6 \cdot 10^{+202}\right):\\
\;\;\;\;1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\

\mathbf{else}:\\
\;\;\;\;1 + \left(x \cdot x\right) \cdot -0.5\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 3.69999999999999978e149 or 8.6000000000000005e202 < x

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Step-by-step derivation
      1. add-log-exp98.6%

        \[\leadsto \color{blue}{\log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      2. *-un-lft-identity98.6%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      3. log-prod98.6%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
      4. metadata-eval98.6%

        \[\leadsto \color{blue}{0} + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right) \]
      5. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\cos x \cdot \frac{\sinh y}{y}} \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{0 + \cos x \cdot \frac{\sinh y}{y}} \]
    4. Step-by-step derivation
      1. +-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{\cos x \cdot \sinh y}{y}} \]
      3. associate-*l/99.9%

        \[\leadsto \color{blue}{\frac{\cos x}{y} \cdot \sinh y} \]
      4. *-commutative99.9%

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

      \[\leadsto \color{blue}{\sinh y \cdot \frac{\cos x}{y}} \]
    6. Taylor expanded in x around 0 67.0%

      \[\leadsto \sinh y \cdot \color{blue}{\frac{1}{y}} \]
    7. Step-by-step derivation
      1. expm1-log1p-u67.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sinh y \cdot \frac{1}{y}\right)\right)} \]
      2. expm1-udef67.0%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sinh y \cdot \frac{1}{y}\right)} - 1} \]
      3. un-div-inv67.0%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sinh y}{y}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def67.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sinh y}{y}\right)\right)} \]
      2. expm1-log1p67.1%

        \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]
    10. Simplified67.1%

      \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]
    11. Taylor expanded in y around 0 47.5%

      \[\leadsto \color{blue}{1 + 0.16666666666666666 \cdot {y}^{2}} \]
    12. Step-by-step derivation
      1. unpow247.5%

        \[\leadsto 1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)} \]
    13. Simplified47.5%

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

    if 3.69999999999999978e149 < x < 8.6000000000000005e202

    1. Initial program 100.0%

      \[\cos x \cdot \frac{\sinh y}{y} \]
    2. Taylor expanded in y around 0 47.1%

      \[\leadsto \color{blue}{\cos x} \]
    3. Taylor expanded in x around 0 35.0%

      \[\leadsto \color{blue}{1 + -0.5 \cdot {x}^{2}} \]
    4. Step-by-step derivation
      1. *-commutative35.0%

        \[\leadsto 1 + \color{blue}{{x}^{2} \cdot -0.5} \]
      2. unpow235.0%

        \[\leadsto 1 + \color{blue}{\left(x \cdot x\right)} \cdot -0.5 \]
    5. Simplified35.0%

      \[\leadsto \color{blue}{1 + \left(x \cdot x\right) \cdot -0.5} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification46.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.7 \cdot 10^{+149} \lor \neg \left(x \leq 8.6 \cdot 10^{+202}\right):\\ \;\;\;\;1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \left(x \cdot x\right) \cdot -0.5\\ \end{array} \]

Alternative 12: 47.5% accurate, 29.3× speedup?

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

\\
1 + 0.16666666666666666 \cdot \left(y \cdot y\right)
\end{array}
Derivation
  1. Initial program 100.0%

    \[\cos x \cdot \frac{\sinh y}{y} \]
  2. Step-by-step derivation
    1. add-log-exp98.7%

      \[\leadsto \color{blue}{\log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
    2. *-un-lft-identity98.7%

      \[\leadsto \log \color{blue}{\left(1 \cdot e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
    3. log-prod98.7%

      \[\leadsto \color{blue}{\log 1 + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right)} \]
    4. metadata-eval98.7%

      \[\leadsto \color{blue}{0} + \log \left(e^{\cos x \cdot \frac{\sinh y}{y}}\right) \]
    5. add-log-exp100.0%

      \[\leadsto 0 + \color{blue}{\cos x \cdot \frac{\sinh y}{y}} \]
  3. Applied egg-rr100.0%

    \[\leadsto \color{blue}{0 + \cos x \cdot \frac{\sinh y}{y}} \]
  4. Step-by-step derivation
    1. +-lft-identity100.0%

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

      \[\leadsto \color{blue}{\frac{\cos x \cdot \sinh y}{y}} \]
    3. associate-*l/99.9%

      \[\leadsto \color{blue}{\frac{\cos x}{y} \cdot \sinh y} \]
    4. *-commutative99.9%

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

    \[\leadsto \color{blue}{\sinh y \cdot \frac{\cos x}{y}} \]
  6. Taylor expanded in x around 0 64.2%

    \[\leadsto \sinh y \cdot \color{blue}{\frac{1}{y}} \]
  7. Step-by-step derivation
    1. expm1-log1p-u64.2%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sinh y \cdot \frac{1}{y}\right)\right)} \]
    2. expm1-udef64.2%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sinh y \cdot \frac{1}{y}\right)} - 1} \]
    3. un-div-inv64.2%

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

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sinh y}{y}\right)} - 1} \]
  9. Step-by-step derivation
    1. expm1-def64.2%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sinh y}{y}\right)\right)} \]
    2. expm1-log1p64.2%

      \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]
  10. Simplified64.2%

    \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]
  11. Taylor expanded in y around 0 45.8%

    \[\leadsto \color{blue}{1 + 0.16666666666666666 \cdot {y}^{2}} \]
  12. Step-by-step derivation
    1. unpow245.8%

      \[\leadsto 1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)} \]
  13. Simplified45.8%

    \[\leadsto \color{blue}{1 + 0.16666666666666666 \cdot \left(y \cdot y\right)} \]
  14. Final simplification45.8%

    \[\leadsto 1 + 0.16666666666666666 \cdot \left(y \cdot y\right) \]

Alternative 13: 29.2% accurate, 205.0× speedup?

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

\\
1
\end{array}
Derivation
  1. Initial program 100.0%

    \[\cos x \cdot \frac{\sinh y}{y} \]
  2. Taylor expanded in y around 0 45.9%

    \[\leadsto \color{blue}{\cos x} \]
  3. Taylor expanded in x around 0 26.0%

    \[\leadsto \color{blue}{1} \]
  4. Final simplification26.0%

    \[\leadsto 1 \]

Reproduce

?
herbie shell --seed 2023207 
(FPCore (x y)
  :name "Linear.Quaternion:$csin from linear-1.19.1.3"
  :precision binary64
  (* (cos x) (/ (sinh y) y)))