Linear.Quaternion:$csin from linear-1.19.1.3

Percentage Accurate: 100.0% → 100.0%
Time: 7.8s
Alternatives: 11
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 11 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: 86.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sinh y}{y}\\ \mathbf{if}\;t_0 \leq 1.0000000005:\\ \;\;\;\;\cos x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ (sinh y) y))) (if (<= t_0 1.0000000005) (cos x) t_0)))
double code(double x, double y) {
	double t_0 = sinh(y) / y;
	double tmp;
	if (t_0 <= 1.0000000005) {
		tmp = cos(x);
	} 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 = sinh(y) / y
    if (t_0 <= 1.0000000005d0) then
        tmp = cos(x)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = Math.sinh(y) / y;
	double tmp;
	if (t_0 <= 1.0000000005) {
		tmp = Math.cos(x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = math.sinh(y) / y
	tmp = 0
	if t_0 <= 1.0000000005:
		tmp = math.cos(x)
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(sinh(y) / y)
	tmp = 0.0
	if (t_0 <= 1.0000000005)
		tmp = cos(x);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = sinh(y) / y;
	tmp = 0.0;
	if (t_0 <= 1.0000000005)
		tmp = cos(x);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, 1.0000000005], N[Cos[x], $MachinePrecision], t$95$0]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\sinh y}{y}\\
\mathbf{if}\;t_0 \leq 1.0000000005:\\
\;\;\;\;\cos x\\

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


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

    1. Initial program 100.0%

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

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

    if 1.0000000005 < (/.f64 (sinh.f64 y) y)

    1. Initial program 100.0%

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

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

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

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

        \[\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}} \]
      6. clear-num100.0%

        \[\leadsto 0 + \cos x \cdot \color{blue}{\frac{1}{\frac{y}{\sinh y}}} \]
      7. un-div-inv100.0%

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

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

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

        \[\leadsto \color{blue}{\frac{\cos x}{y} \cdot \sinh y} \]
      3. *-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 76.5%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]
    10. Simplified76.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sinh y}{y} \leq 1.0000000005:\\ \;\;\;\;\cos x\\ \mathbf{else}:\\ \;\;\;\;\frac{\sinh y}{y}\\ \end{array} \]

Alternative 3: 85.0% accurate, 1.6× speedup?

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

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

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

\mathbf{elif}\;y \leq 1.5 \cdot 10^{+151}:\\
\;\;\;\;\frac{0.027777777777777776 \cdot {y}^{4} + -1}{y \cdot \left(y \cdot 0.16666666666666666\right) + -1} \cdot \left(1 + -0.5 \cdot \left(x \cdot x\right)\right)\\

\mathbf{elif}\;y \leq 4 \cdot 10^{+154}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 100.0%

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

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

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

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

    if 0.064000000000000001 < y < 1.00000000000000002e116 or 1.5e151 < y < 4.00000000000000015e154

    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}} \]
      6. clear-num100.0%

        \[\leadsto 0 + \cos x \cdot \color{blue}{\frac{1}{\frac{y}{\sinh y}}} \]
      7. un-div-inv100.0%

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

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

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

        \[\leadsto \color{blue}{\frac{\cos x}{y} \cdot \sinh y} \]
      3. *-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 78.6%

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

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

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

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

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

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

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

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

    if 1.00000000000000002e116 < y < 1.5e151

    1. Initial program 100.0%

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

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

        \[\leadsto \cos x \cdot \left(1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)}\right) \]
    4. Simplified9.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 54.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right)} \cdot \left({x}^{2} \cdot -0.5\right) + \left(0.16666666666666666 \cdot \left(y \cdot y\right) + 1\right) \]
      11. *-commutative54.5%

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \color{blue}{\left(-0.5 \cdot {x}^{2}\right)} + \left(0.16666666666666666 \cdot \left(y \cdot y\right) + 1\right) \]
      12. associate-*r*54.5%

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot {x}^{2}\right) + \left(\color{blue}{\left(0.16666666666666666 \cdot y\right) \cdot y} + 1\right) \]
      13. *-commutative54.5%

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

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot {x}^{2}\right) + \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right)} \]
      15. *-rgt-identity54.5%

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot {x}^{2}\right) + \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot 1} \]
      16. distribute-lft-out54.5%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot \left(x \cdot x\right) + 1\right)} \]
    8. Step-by-step derivation
      1. fma-udef54.5%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(0.16666666666666666 \cdot 0.16666666666666666\right) \cdot \left(\left(y \cdot y\right) \cdot \left(y \cdot y\right)\right)} - 1 \cdot 1}{y \cdot \left(0.16666666666666666 \cdot y\right) - 1} \cdot \left(-0.5 \cdot \left(x \cdot x\right) + 1\right) \]
      10. metadata-eval100.0%

        \[\leadsto \frac{\color{blue}{0.027777777777777776} \cdot \left(\left(y \cdot y\right) \cdot \left(y \cdot y\right)\right) - 1 \cdot 1}{y \cdot \left(0.16666666666666666 \cdot y\right) - 1} \cdot \left(-0.5 \cdot \left(x \cdot x\right) + 1\right) \]
      11. pow2100.0%

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

        \[\leadsto \frac{0.027777777777777776 \cdot \left({y}^{2} \cdot \color{blue}{{y}^{2}}\right) - 1 \cdot 1}{y \cdot \left(0.16666666666666666 \cdot y\right) - 1} \cdot \left(-0.5 \cdot \left(x \cdot x\right) + 1\right) \]
      13. pow-prod-up100.0%

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

        \[\leadsto \frac{0.027777777777777776 \cdot {y}^{\color{blue}{4}} - 1 \cdot 1}{y \cdot \left(0.16666666666666666 \cdot y\right) - 1} \cdot \left(-0.5 \cdot \left(x \cdot x\right) + 1\right) \]
      15. metadata-eval100.0%

        \[\leadsto \frac{0.027777777777777776 \cdot {y}^{4} - \color{blue}{1}}{y \cdot \left(0.16666666666666666 \cdot y\right) - 1} \cdot \left(-0.5 \cdot \left(x \cdot x\right) + 1\right) \]
      16. *-commutative100.0%

        \[\leadsto \frac{0.027777777777777776 \cdot {y}^{4} - 1}{y \cdot \color{blue}{\left(y \cdot 0.16666666666666666\right)} - 1} \cdot \left(-0.5 \cdot \left(x \cdot x\right) + 1\right) \]
    9. Applied egg-rr100.0%

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

    if 4.00000000000000015e154 < 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. unpow2100.0%

        \[\leadsto \cos x \cdot \left(1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)}\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. unpow2100.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 0.064:\\ \;\;\;\;\cos x \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\ \mathbf{elif}\;y \leq 10^{+116}:\\ \;\;\;\;\frac{\sinh y}{y}\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+151}:\\ \;\;\;\;\frac{0.027777777777777776 \cdot {y}^{4} + -1}{y \cdot \left(y \cdot 0.16666666666666666\right) + -1} \cdot \left(1 + -0.5 \cdot \left(x \cdot x\right)\right)\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+154}:\\ \;\;\;\;\frac{\sinh y}{y}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(0.16666666666666666 \cdot \left(\cos x \cdot y\right)\right)\\ \end{array} \]

Alternative 4: 71.9% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.7 \cdot 10^{-5}:\\
\;\;\;\;\cos x\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 5.7000000000000003e-5

    1. Initial program 100.0%

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

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

    if 5.7000000000000003e-5 < y < 3.6000000000000001e154

    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}} \]
      6. clear-num100.0%

        \[\leadsto 0 + \cos x \cdot \color{blue}{\frac{1}{\frac{y}{\sinh y}}} \]
      7. un-div-inv100.0%

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

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

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

        \[\leadsto \color{blue}{\frac{\cos x}{y} \cdot \sinh y} \]
      3. *-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 69.4%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]
    10. Simplified69.5%

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

    if 3.6000000000000001e154 < 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. unpow2100.0%

        \[\leadsto \cos x \cdot \left(1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)}\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. unpow2100.0%

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

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

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

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

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

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

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

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

Alternative 5: 84.9% accurate, 1.8× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

    if 0.034000000000000002 < y < 3.9000000000000003e154

    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}} \]
      6. clear-num100.0%

        \[\leadsto 0 + \cos x \cdot \color{blue}{\frac{1}{\frac{y}{\sinh y}}} \]
      7. un-div-inv100.0%

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

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

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

        \[\leadsto \color{blue}{\frac{\cos x}{y} \cdot \sinh y} \]
      3. *-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 69.4%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sinh y}{y}} \]
    10. Simplified69.5%

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

    if 3.9000000000000003e154 < 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. unpow2100.0%

        \[\leadsto \cos x \cdot \left(1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)}\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. unpow2100.0%

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

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

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

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

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

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

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

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

Alternative 6: 62.1% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 5.7 \cdot 10^{-5}:\\ \;\;\;\;\cos x\\ \mathbf{elif}\;y \leq 3.4 \cdot 10^{+198} \lor \neg \left(y \leq 1.76 \cdot 10^{+255}\right):\\ \;\;\;\;\left(1 + -0.5 \cdot \left(x \cdot x\right)\right) \cdot \left(1 + y \cdot \left(y \cdot 0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y 5.7e-5)
   (cos x)
   (if (or (<= y 3.4e+198) (not (<= y 1.76e+255)))
     (* (+ 1.0 (* -0.5 (* x x))) (+ 1.0 (* y (* y 0.16666666666666666))))
     (+ 1.0 (* 0.16666666666666666 (* y y))))))
double code(double x, double y) {
	double tmp;
	if (y <= 5.7e-5) {
		tmp = cos(x);
	} else if ((y <= 3.4e+198) || !(y <= 1.76e+255)) {
		tmp = (1.0 + (-0.5 * (x * x))) * (1.0 + (y * (y * 0.16666666666666666)));
	} else {
		tmp = 1.0 + (0.16666666666666666 * (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 <= 5.7d-5) then
        tmp = cos(x)
    else if ((y <= 3.4d+198) .or. (.not. (y <= 1.76d+255))) then
        tmp = (1.0d0 + ((-0.5d0) * (x * x))) * (1.0d0 + (y * (y * 0.16666666666666666d0)))
    else
        tmp = 1.0d0 + (0.16666666666666666d0 * (y * y))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= 5.7e-5) {
		tmp = Math.cos(x);
	} else if ((y <= 3.4e+198) || !(y <= 1.76e+255)) {
		tmp = (1.0 + (-0.5 * (x * x))) * (1.0 + (y * (y * 0.16666666666666666)));
	} else {
		tmp = 1.0 + (0.16666666666666666 * (y * y));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= 5.7e-5:
		tmp = math.cos(x)
	elif (y <= 3.4e+198) or not (y <= 1.76e+255):
		tmp = (1.0 + (-0.5 * (x * x))) * (1.0 + (y * (y * 0.16666666666666666)))
	else:
		tmp = 1.0 + (0.16666666666666666 * (y * y))
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= 5.7e-5)
		tmp = cos(x);
	elseif ((y <= 3.4e+198) || !(y <= 1.76e+255))
		tmp = Float64(Float64(1.0 + Float64(-0.5 * Float64(x * x))) * Float64(1.0 + Float64(y * Float64(y * 0.16666666666666666))));
	else
		tmp = Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= 5.7e-5)
		tmp = cos(x);
	elseif ((y <= 3.4e+198) || ~((y <= 1.76e+255)))
		tmp = (1.0 + (-0.5 * (x * x))) * (1.0 + (y * (y * 0.16666666666666666)));
	else
		tmp = 1.0 + (0.16666666666666666 * (y * y));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, 5.7e-5], N[Cos[x], $MachinePrecision], If[Or[LessEqual[y, 3.4e+198], N[Not[LessEqual[y, 1.76e+255]], $MachinePrecision]], N[(N[(1.0 + N[(-0.5 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(y * N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.7 \cdot 10^{-5}:\\
\;\;\;\;\cos x\\

\mathbf{elif}\;y \leq 3.4 \cdot 10^{+198} \lor \neg \left(y \leq 1.76 \cdot 10^{+255}\right):\\
\;\;\;\;\left(1 + -0.5 \cdot \left(x \cdot x\right)\right) \cdot \left(1 + y \cdot \left(y \cdot 0.16666666666666666\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 5.7000000000000003e-5

    1. Initial program 100.0%

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

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

    if 5.7000000000000003e-5 < y < 3.4e198 or 1.7600000000000001e255 < y

    1. Initial program 100.0%

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

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

        \[\leadsto \cos x \cdot \left(1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)}\right) \]
    4. Simplified29.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 18.4%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right)} \cdot \left({x}^{2} \cdot -0.5\right) + \left(0.16666666666666666 \cdot \left(y \cdot y\right) + 1\right) \]
      11. *-commutative18.4%

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \color{blue}{\left(-0.5 \cdot {x}^{2}\right)} + \left(0.16666666666666666 \cdot \left(y \cdot y\right) + 1\right) \]
      12. associate-*r*18.4%

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot {x}^{2}\right) + \left(\color{blue}{\left(0.16666666666666666 \cdot y\right) \cdot y} + 1\right) \]
      13. *-commutative18.4%

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot {x}^{2}\right) + \left(\color{blue}{y \cdot \left(0.16666666666666666 \cdot y\right)} + 1\right) \]
      14. fma-udef18.4%

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot {x}^{2}\right) + \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right)} \]
      15. *-rgt-identity18.4%

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot {x}^{2}\right) + \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot 1} \]
      16. distribute-lft-out33.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot {x}^{2} + 1\right)} \]
    7. Simplified33.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot \left(x \cdot x\right) + 1\right)} \]
    8. Step-by-step derivation
      1. fma-udef33.2%

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

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

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

    if 3.4e198 < y < 1.7600000000000001e255

    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. unpow2100.0%

        \[\leadsto \cos x \cdot \left(1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)}\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 93.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 5.7 \cdot 10^{-5}:\\ \;\;\;\;\cos x\\ \mathbf{elif}\;y \leq 3.4 \cdot 10^{+198} \lor \neg \left(y \leq 1.76 \cdot 10^{+255}\right):\\ \;\;\;\;\left(1 + -0.5 \cdot \left(x \cdot x\right)\right) \cdot \left(1 + y \cdot \left(y \cdot 0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\ \end{array} \]

Alternative 7: 40.0% accurate, 9.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 2.25 \cdot 10^{-57}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+198} \lor \neg \left(y \leq 10^{+256}\right):\\ \;\;\;\;\left(1 + -0.5 \cdot \left(x \cdot x\right)\right) \cdot \left(1 + y \cdot \left(y \cdot 0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y 2.25e-57)
   1.0
   (if (or (<= y 5e+198) (not (<= y 1e+256)))
     (* (+ 1.0 (* -0.5 (* x x))) (+ 1.0 (* y (* y 0.16666666666666666))))
     (+ 1.0 (* 0.16666666666666666 (* y y))))))
double code(double x, double y) {
	double tmp;
	if (y <= 2.25e-57) {
		tmp = 1.0;
	} else if ((y <= 5e+198) || !(y <= 1e+256)) {
		tmp = (1.0 + (-0.5 * (x * x))) * (1.0 + (y * (y * 0.16666666666666666)));
	} else {
		tmp = 1.0 + (0.16666666666666666 * (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 <= 2.25d-57) then
        tmp = 1.0d0
    else if ((y <= 5d+198) .or. (.not. (y <= 1d+256))) then
        tmp = (1.0d0 + ((-0.5d0) * (x * x))) * (1.0d0 + (y * (y * 0.16666666666666666d0)))
    else
        tmp = 1.0d0 + (0.16666666666666666d0 * (y * y))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= 2.25e-57) {
		tmp = 1.0;
	} else if ((y <= 5e+198) || !(y <= 1e+256)) {
		tmp = (1.0 + (-0.5 * (x * x))) * (1.0 + (y * (y * 0.16666666666666666)));
	} else {
		tmp = 1.0 + (0.16666666666666666 * (y * y));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= 2.25e-57:
		tmp = 1.0
	elif (y <= 5e+198) or not (y <= 1e+256):
		tmp = (1.0 + (-0.5 * (x * x))) * (1.0 + (y * (y * 0.16666666666666666)))
	else:
		tmp = 1.0 + (0.16666666666666666 * (y * y))
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= 2.25e-57)
		tmp = 1.0;
	elseif ((y <= 5e+198) || !(y <= 1e+256))
		tmp = Float64(Float64(1.0 + Float64(-0.5 * Float64(x * x))) * Float64(1.0 + Float64(y * Float64(y * 0.16666666666666666))));
	else
		tmp = Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= 2.25e-57)
		tmp = 1.0;
	elseif ((y <= 5e+198) || ~((y <= 1e+256)))
		tmp = (1.0 + (-0.5 * (x * x))) * (1.0 + (y * (y * 0.16666666666666666)));
	else
		tmp = 1.0 + (0.16666666666666666 * (y * y));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, 2.25e-57], 1.0, If[Or[LessEqual[y, 5e+198], N[Not[LessEqual[y, 1e+256]], $MachinePrecision]], N[(N[(1.0 + N[(-0.5 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(y * N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.25 \cdot 10^{-57}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq 5 \cdot 10^{+198} \lor \neg \left(y \leq 10^{+256}\right):\\
\;\;\;\;\left(1 + -0.5 \cdot \left(x \cdot x\right)\right) \cdot \left(1 + y \cdot \left(y \cdot 0.16666666666666666\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 2.24999999999999986e-57

    1. Initial program 100.0%

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

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

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

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

        \[\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}} \]
      6. clear-num100.0%

        \[\leadsto 0 + \cos x \cdot \color{blue}{\frac{1}{\frac{y}{\sinh y}}} \]
      7. un-div-inv100.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1} \]

    if 2.24999999999999986e-57 < y < 5.00000000000000049e198 or 1e256 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right)} \cdot \left({x}^{2} \cdot -0.5\right) + \left(0.16666666666666666 \cdot \left(y \cdot y\right) + 1\right) \]
      11. *-commutative30.2%

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \color{blue}{\left(-0.5 \cdot {x}^{2}\right)} + \left(0.16666666666666666 \cdot \left(y \cdot y\right) + 1\right) \]
      12. associate-*r*30.2%

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot {x}^{2}\right) + \left(\color{blue}{\left(0.16666666666666666 \cdot y\right) \cdot y} + 1\right) \]
      13. *-commutative30.2%

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot {x}^{2}\right) + \left(\color{blue}{y \cdot \left(0.16666666666666666 \cdot y\right)} + 1\right) \]
      14. fma-udef30.2%

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot {x}^{2}\right) + \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right)} \]
      15. *-rgt-identity30.2%

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot {x}^{2}\right) + \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot 1} \]
      16. distribute-lft-out40.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot {x}^{2} + 1\right)} \]
    7. Simplified40.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot \left(x \cdot x\right) + 1\right)} \]
    8. Step-by-step derivation
      1. fma-udef40.8%

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

        \[\leadsto \left(y \cdot \color{blue}{\left(y \cdot 0.16666666666666666\right)} + 1\right) \cdot \left(-0.5 \cdot \left(x \cdot x\right) + 1\right) \]
    9. Applied egg-rr40.8%

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

    if 5.00000000000000049e198 < y < 1e256

    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. unpow2100.0%

        \[\leadsto \cos x \cdot \left(1 + 0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)}\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 93.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2.25 \cdot 10^{-57}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+198} \lor \neg \left(y \leq 10^{+256}\right):\\ \;\;\;\;\left(1 + -0.5 \cdot \left(x \cdot x\right)\right) \cdot \left(1 + y \cdot \left(y \cdot 0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\ \end{array} \]

Alternative 8: 49.5% accurate, 15.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{+30} \lor \neg \left(y \leq 2.05 \cdot 10^{+151}\right):\\
\;\;\;\;1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.3499999999999999e30 or 2.0499999999999999e151 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if 1.3499999999999999e30 < y < 2.0499999999999999e151

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right)} \cdot \left({x}^{2} \cdot -0.5\right) + \left(0.16666666666666666 \cdot \left(y \cdot y\right) + 1\right) \]
      11. *-commutative28.2%

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \color{blue}{\left(-0.5 \cdot {x}^{2}\right)} + \left(0.16666666666666666 \cdot \left(y \cdot y\right) + 1\right) \]
      12. associate-*r*28.2%

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot {x}^{2}\right) + \left(\color{blue}{\left(0.16666666666666666 \cdot y\right) \cdot y} + 1\right) \]
      13. *-commutative28.2%

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot {x}^{2}\right) + \left(\color{blue}{y \cdot \left(0.16666666666666666 \cdot y\right)} + 1\right) \]
      14. fma-udef28.2%

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot {x}^{2}\right) + \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right)} \]
      15. *-rgt-identity28.2%

        \[\leadsto \mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot {x}^{2}\right) + \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot 1} \]
      16. distribute-lft-out28.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot {x}^{2} + 1\right)} \]
    7. Simplified28.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, 0.16666666666666666 \cdot y, 1\right) \cdot \left(-0.5 \cdot \left(x \cdot x\right) + 1\right)} \]
    8. Taylor expanded in y around inf 28.2%

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

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

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

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

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

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

        \[\leadsto 0.16666666666666666 \cdot \left(\left(y \cdot y\right) \cdot \color{blue}{\mathsf{fma}\left(x \cdot -0.5, x, 1\right)}\right) \]
    10. Simplified28.2%

      \[\leadsto \color{blue}{0.16666666666666666 \cdot \left(\left(y \cdot y\right) \cdot \mathsf{fma}\left(x \cdot -0.5, x, 1\right)\right)} \]
    11. Taylor expanded in x around inf 25.8%

      \[\leadsto \color{blue}{-0.08333333333333333 \cdot \left({y}^{2} \cdot {x}^{2}\right)} \]
    12. Step-by-step derivation
      1. *-commutative25.8%

        \[\leadsto \color{blue}{\left({y}^{2} \cdot {x}^{2}\right) \cdot -0.08333333333333333} \]
      2. unpow225.8%

        \[\leadsto \left(\color{blue}{\left(y \cdot y\right)} \cdot {x}^{2}\right) \cdot -0.08333333333333333 \]
      3. unpow225.8%

        \[\leadsto \left(\left(y \cdot y\right) \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot -0.08333333333333333 \]
      4. associate-*l*25.8%

        \[\leadsto \color{blue}{\left(y \cdot \left(y \cdot \left(x \cdot x\right)\right)\right)} \cdot -0.08333333333333333 \]
    13. Simplified25.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.35 \cdot 10^{+30} \lor \neg \left(y \leq 2.05 \cdot 10^{+151}\right):\\ \;\;\;\;1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot \left(y \cdot \left(x \cdot x\right)\right)\right) \cdot -0.08333333333333333\\ \end{array} \]

Alternative 9: 38.1% accurate, 29.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.96:\\
\;\;\;\;1\\

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


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

    1. Initial program 100.0%

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

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

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

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

        \[\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}} \]
      6. clear-num100.0%

        \[\leadsto 0 + \cos x \cdot \color{blue}{\frac{1}{\frac{y}{\sinh y}}} \]
      7. un-div-inv100.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1} \]

    if 0.95999999999999996 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.16666666666666666 \cdot {y}^{2}} \]
    9. Step-by-step derivation
      1. unpow239.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 0.96:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;0.16666666666666666 \cdot \left(y \cdot y\right)\\ \end{array} \]

Alternative 10: 48.0% 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. Taylor expanded in y around 0 77.7%

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

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

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

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

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

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

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

Alternative 11: 28.6% 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. Step-by-step derivation
    1. add-log-exp99.4%

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

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

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

      \[\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}} \]
    6. clear-num100.0%

      \[\leadsto 0 + \cos x \cdot \color{blue}{\frac{1}{\frac{y}{\sinh y}}} \]
    7. un-div-inv100.0%

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

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

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

      \[\leadsto \color{blue}{\frac{\cos x}{y} \cdot \sinh y} \]
    3. *-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 66.8%

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

    \[\leadsto \color{blue}{1} \]
  8. Final simplification30.8%

    \[\leadsto 1 \]

Reproduce

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