Linear.Quaternion:$csin from linear-1.19.1.3

Percentage Accurate: 100.0% → 100.0%
Time: 7.9s
Alternatives: 12
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 12 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: 80.7% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.16666666666666666 \cdot \left(y \cdot y\right)\\ \mathbf{if}\;y \leq 580:\\ \;\;\;\;\cos x \cdot \left(1 + t_0\right)\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{+102}:\\ \;\;\;\;\left(1 + x \cdot \left(x \cdot -0.5\right)\right) \cdot \mathsf{fma}\left(0.16666666666666666, y \cdot y, 1\right)\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot \left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;\cos x \cdot t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* 0.16666666666666666 (* y y))))
   (if (<= y 580.0)
     (* (cos x) (+ 1.0 t_0))
     (if (<= y 8.2e+102)
       (* (+ 1.0 (* x (* x -0.5))) (fma 0.16666666666666666 (* y y) 1.0))
       (if (<= y 1.35e+154)
         (* 0.5 (/ (* y (+ (* y (* y 0.3333333333333333)) 2.0)) y))
         (* (cos x) t_0))))))
double code(double x, double y) {
	double t_0 = 0.16666666666666666 * (y * y);
	double tmp;
	if (y <= 580.0) {
		tmp = cos(x) * (1.0 + t_0);
	} else if (y <= 8.2e+102) {
		tmp = (1.0 + (x * (x * -0.5))) * fma(0.16666666666666666, (y * y), 1.0);
	} else if (y <= 1.35e+154) {
		tmp = 0.5 * ((y * ((y * (y * 0.3333333333333333)) + 2.0)) / y);
	} else {
		tmp = cos(x) * t_0;
	}
	return tmp;
}
function code(x, y)
	t_0 = Float64(0.16666666666666666 * Float64(y * y))
	tmp = 0.0
	if (y <= 580.0)
		tmp = Float64(cos(x) * Float64(1.0 + t_0));
	elseif (y <= 8.2e+102)
		tmp = Float64(Float64(1.0 + Float64(x * Float64(x * -0.5))) * fma(0.16666666666666666, Float64(y * y), 1.0));
	elseif (y <= 1.35e+154)
		tmp = Float64(0.5 * Float64(Float64(y * Float64(Float64(y * Float64(y * 0.3333333333333333)) + 2.0)) / y));
	else
		tmp = Float64(cos(x) * t_0);
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 580.0], N[(N[Cos[x], $MachinePrecision] * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.2e+102], N[(N[(1.0 + N[(x * N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.16666666666666666 * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.35e+154], N[(0.5 * N[(N[(y * N[(N[(y * N[(y * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(N[Cos[x], $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 8.2 \cdot 10^{+102}:\\
\;\;\;\;\left(1 + x \cdot \left(x \cdot -0.5\right)\right) \cdot \mathsf{fma}\left(0.16666666666666666, y \cdot y, 1\right)\\

\mathbf{elif}\;y \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \frac{y \cdot \left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}{y}\\

\mathbf{else}:\\
\;\;\;\;\cos x \cdot t_0\\


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

    1. Initial program 100.0%

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

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

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

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

    if 580 < y < 8.1999999999999999e102

    1. Initial program 100.0%

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

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

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

      \[\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. +-commutative43.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.1999999999999999e102 < y < 1.35000000000000003e154

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{e^{y} - \frac{1}{e^{y}}}{y}} \]
    3. Step-by-step derivation
      1. rec-exp90.9%

        \[\leadsto 0.5 \cdot \frac{e^{y} - \color{blue}{e^{-y}}}{y} \]
    4. Simplified90.9%

      \[\leadsto \color{blue}{0.5 \cdot \frac{e^{y} - e^{-y}}{y}} \]
    5. Taylor expanded in y around 0 90.9%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{0.3333333333333333 \cdot {y}^{3} + 2 \cdot y}}{y} \]
    6. Step-by-step derivation
      1. unpow390.9%

        \[\leadsto 0.5 \cdot \frac{0.3333333333333333 \cdot \color{blue}{\left(\left(y \cdot y\right) \cdot y\right)} + 2 \cdot y}{y} \]
      2. unpow290.9%

        \[\leadsto 0.5 \cdot \frac{0.3333333333333333 \cdot \left(\color{blue}{{y}^{2}} \cdot y\right) + 2 \cdot y}{y} \]
      3. associate-*r*90.9%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(0.3333333333333333 \cdot {y}^{2}\right) \cdot y} + 2 \cdot y}{y} \]
      4. distribute-rgt-out90.9%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{y \cdot \left(0.3333333333333333 \cdot {y}^{2} + 2\right)}}{y} \]
      5. *-commutative90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\color{blue}{{y}^{2} \cdot 0.3333333333333333} + 2\right)}{y} \]
      6. fma-def90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\mathsf{fma}\left({y}^{2}, 0.3333333333333333, 2\right)}}{y} \]
      7. unpow290.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \mathsf{fma}\left(\color{blue}{y \cdot y}, 0.3333333333333333, 2\right)}{y} \]
    7. Simplified90.9%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}{y} \]
    8. Step-by-step derivation
      1. *-un-lft-identity90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(1 \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right)}}{y} \]
      2. *-commutative90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot 1\right)}}{y} \]
      3. metadata-eval90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{{y}^{0}}\right)}{y} \]
      4. metadata-eval90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot {y}^{\color{blue}{\left(1 + -1\right)}}\right)}{y} \]
      5. pow-prod-up90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{\left({y}^{1} \cdot {y}^{-1}\right)}\right)}{y} \]
      6. pow190.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(\color{blue}{y} \cdot {y}^{-1}\right)\right)}{y} \]
      7. inv-pow90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(y \cdot \color{blue}{\frac{1}{y}}\right)\right)}{y} \]
      8. associate-*l*90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(\left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot y\right) \cdot \frac{1}{y}\right)}}{y} \]
      9. *-commutative90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\color{blue}{\left(y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right)} \cdot \frac{1}{y}\right)}{y} \]
      10. *-commutative90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(\frac{1}{y} \cdot \left(y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right)\right)}}{y} \]
      11. associate-/r/90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\frac{1}{\frac{y}{y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}}}{y} \]
      12. clear-num90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\color{blue}{\frac{1}{\frac{y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}{y}}}}}{y} \]
      13. div-inv90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\left(y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right) \cdot \frac{1}{y}}}}}{y} \]
      14. *-commutative90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot y\right)} \cdot \frac{1}{y}}}}{y} \]
      15. associate-*l*90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(y \cdot \frac{1}{y}\right)}}}}{y} \]
      16. pow190.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(\color{blue}{{y}^{1}} \cdot \frac{1}{y}\right)}}}{y} \]
      17. inv-pow90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left({y}^{1} \cdot \color{blue}{{y}^{-1}}\right)}}}{y} \]
      18. pow-prod-up90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{{y}^{\left(1 + -1\right)}}}}}{y} \]
      19. metadata-eval90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot {y}^{\color{blue}{0}}}}}{y} \]
      20. metadata-eval90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{1}}}}{y} \]
      21. *-commutative90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{1 \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}}}{y} \]
      22. *-un-lft-identity90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}}}{y} \]
      23. fma-udef90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\left(y \cdot y\right) \cdot 0.3333333333333333 + 2}}}}{y} \]
      24. associate-*l*90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{y \cdot \left(y \cdot 0.3333333333333333\right)} + 2}}}{y} \]
      25. fma-def90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y, y \cdot 0.3333333333333333, 2\right)}}}}{y} \]
    9. Applied egg-rr90.9%

      \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\frac{1}{\frac{1}{\mathsf{fma}\left(y, y \cdot 0.3333333333333333, 2\right)}}}}{y} \]
    10. Step-by-step derivation
      1. remove-double-div90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\mathsf{fma}\left(y, y \cdot 0.3333333333333333, 2\right)}}{y} \]
      2. fma-udef90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}}{y} \]
    11. Applied egg-rr90.9%

      \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}}{y} \]

    if 1.35000000000000003e154 < 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. *-commutative100.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 580:\\ \;\;\;\;\cos x \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{+102}:\\ \;\;\;\;\left(1 + x \cdot \left(x \cdot -0.5\right)\right) \cdot \mathsf{fma}\left(0.16666666666666666, y \cdot y, 1\right)\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot \left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;\cos x \cdot \left(0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\ \end{array} \]

Alternative 3: 68.0% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 23:\\ \;\;\;\;\cos x\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{+102}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \left(x \cdot x\right)\right)\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{+154}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot \left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(y \cdot \left(\cos x \cdot 0.16666666666666666\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y 23.0)
   (cos x)
   (if (<= y 8.2e+102)
     (* (* y y) (+ 0.16666666666666666 (* -0.08333333333333333 (* x x))))
     (if (<= y 4.5e+154)
       (* 0.5 (/ (* y (+ (* y (* y 0.3333333333333333)) 2.0)) y))
       (* y (* y (* (cos x) 0.16666666666666666)))))))
double code(double x, double y) {
	double tmp;
	if (y <= 23.0) {
		tmp = cos(x);
	} else if (y <= 8.2e+102) {
		tmp = (y * y) * (0.16666666666666666 + (-0.08333333333333333 * (x * x)));
	} else if (y <= 4.5e+154) {
		tmp = 0.5 * ((y * ((y * (y * 0.3333333333333333)) + 2.0)) / y);
	} else {
		tmp = y * (y * (cos(x) * 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 <= 23.0d0) then
        tmp = cos(x)
    else if (y <= 8.2d+102) then
        tmp = (y * y) * (0.16666666666666666d0 + ((-0.08333333333333333d0) * (x * x)))
    else if (y <= 4.5d+154) then
        tmp = 0.5d0 * ((y * ((y * (y * 0.3333333333333333d0)) + 2.0d0)) / y)
    else
        tmp = y * (y * (cos(x) * 0.16666666666666666d0))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= 23.0) {
		tmp = Math.cos(x);
	} else if (y <= 8.2e+102) {
		tmp = (y * y) * (0.16666666666666666 + (-0.08333333333333333 * (x * x)));
	} else if (y <= 4.5e+154) {
		tmp = 0.5 * ((y * ((y * (y * 0.3333333333333333)) + 2.0)) / y);
	} else {
		tmp = y * (y * (Math.cos(x) * 0.16666666666666666));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= 23.0:
		tmp = math.cos(x)
	elif y <= 8.2e+102:
		tmp = (y * y) * (0.16666666666666666 + (-0.08333333333333333 * (x * x)))
	elif y <= 4.5e+154:
		tmp = 0.5 * ((y * ((y * (y * 0.3333333333333333)) + 2.0)) / y)
	else:
		tmp = y * (y * (math.cos(x) * 0.16666666666666666))
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= 23.0)
		tmp = cos(x);
	elseif (y <= 8.2e+102)
		tmp = Float64(Float64(y * y) * Float64(0.16666666666666666 + Float64(-0.08333333333333333 * Float64(x * x))));
	elseif (y <= 4.5e+154)
		tmp = Float64(0.5 * Float64(Float64(y * Float64(Float64(y * Float64(y * 0.3333333333333333)) + 2.0)) / y));
	else
		tmp = Float64(y * Float64(y * Float64(cos(x) * 0.16666666666666666)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= 23.0)
		tmp = cos(x);
	elseif (y <= 8.2e+102)
		tmp = (y * y) * (0.16666666666666666 + (-0.08333333333333333 * (x * x)));
	elseif (y <= 4.5e+154)
		tmp = 0.5 * ((y * ((y * (y * 0.3333333333333333)) + 2.0)) / y);
	else
		tmp = y * (y * (cos(x) * 0.16666666666666666));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, 23.0], N[Cos[x], $MachinePrecision], If[LessEqual[y, 8.2e+102], N[(N[(y * y), $MachinePrecision] * N[(0.16666666666666666 + N[(-0.08333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.5e+154], N[(0.5 * N[(N[(y * N[(N[(y * N[(y * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(y * N[(y * N[(N[Cos[x], $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 8.2 \cdot 10^{+102}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \left(x \cdot x\right)\right)\\

\mathbf{elif}\;y \leq 4.5 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \frac{y \cdot \left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}{y}\\

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


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

    1. Initial program 100.0%

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

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

    if 23 < y < 8.1999999999999999e102

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(0.16666666666666666 \cdot \cos x\right) \]
    10. Simplified4.5%

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

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

        \[\leadsto \left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \color{blue}{\left(x \cdot x\right)}\right) \]
    13. Simplified42.4%

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

    if 8.1999999999999999e102 < y < 4.50000000000000009e154

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{e^{y} - \frac{1}{e^{y}}}{y}} \]
    3. Step-by-step derivation
      1. rec-exp91.7%

        \[\leadsto 0.5 \cdot \frac{e^{y} - \color{blue}{e^{-y}}}{y} \]
    4. Simplified91.7%

      \[\leadsto \color{blue}{0.5 \cdot \frac{e^{y} - e^{-y}}{y}} \]
    5. Taylor expanded in y around 0 91.7%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{0.3333333333333333 \cdot {y}^{3} + 2 \cdot y}}{y} \]
    6. Step-by-step derivation
      1. unpow391.7%

        \[\leadsto 0.5 \cdot \frac{0.3333333333333333 \cdot \color{blue}{\left(\left(y \cdot y\right) \cdot y\right)} + 2 \cdot y}{y} \]
      2. unpow291.7%

        \[\leadsto 0.5 \cdot \frac{0.3333333333333333 \cdot \left(\color{blue}{{y}^{2}} \cdot y\right) + 2 \cdot y}{y} \]
      3. associate-*r*91.7%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(0.3333333333333333 \cdot {y}^{2}\right) \cdot y} + 2 \cdot y}{y} \]
      4. distribute-rgt-out91.7%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{y \cdot \left(0.3333333333333333 \cdot {y}^{2} + 2\right)}}{y} \]
      5. *-commutative91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\color{blue}{{y}^{2} \cdot 0.3333333333333333} + 2\right)}{y} \]
      6. fma-def91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\mathsf{fma}\left({y}^{2}, 0.3333333333333333, 2\right)}}{y} \]
      7. unpow291.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \mathsf{fma}\left(\color{blue}{y \cdot y}, 0.3333333333333333, 2\right)}{y} \]
    7. Simplified91.7%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}{y} \]
    8. Step-by-step derivation
      1. *-un-lft-identity91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(1 \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right)}}{y} \]
      2. *-commutative91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot 1\right)}}{y} \]
      3. metadata-eval91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{{y}^{0}}\right)}{y} \]
      4. metadata-eval91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot {y}^{\color{blue}{\left(1 + -1\right)}}\right)}{y} \]
      5. pow-prod-up91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{\left({y}^{1} \cdot {y}^{-1}\right)}\right)}{y} \]
      6. pow191.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(\color{blue}{y} \cdot {y}^{-1}\right)\right)}{y} \]
      7. inv-pow91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(y \cdot \color{blue}{\frac{1}{y}}\right)\right)}{y} \]
      8. associate-*l*91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(\left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot y\right) \cdot \frac{1}{y}\right)}}{y} \]
      9. *-commutative91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\color{blue}{\left(y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right)} \cdot \frac{1}{y}\right)}{y} \]
      10. *-commutative91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(\frac{1}{y} \cdot \left(y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right)\right)}}{y} \]
      11. associate-/r/91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\frac{1}{\frac{y}{y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}}}{y} \]
      12. clear-num91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\color{blue}{\frac{1}{\frac{y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}{y}}}}}{y} \]
      13. div-inv91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\left(y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right) \cdot \frac{1}{y}}}}}{y} \]
      14. *-commutative91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot y\right)} \cdot \frac{1}{y}}}}{y} \]
      15. associate-*l*91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(y \cdot \frac{1}{y}\right)}}}}{y} \]
      16. pow191.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(\color{blue}{{y}^{1}} \cdot \frac{1}{y}\right)}}}{y} \]
      17. inv-pow91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left({y}^{1} \cdot \color{blue}{{y}^{-1}}\right)}}}{y} \]
      18. pow-prod-up91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{{y}^{\left(1 + -1\right)}}}}}{y} \]
      19. metadata-eval91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot {y}^{\color{blue}{0}}}}}{y} \]
      20. metadata-eval91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{1}}}}{y} \]
      21. *-commutative91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{1 \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}}}{y} \]
      22. *-un-lft-identity91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}}}{y} \]
      23. fma-udef91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\left(y \cdot y\right) \cdot 0.3333333333333333 + 2}}}}{y} \]
      24. associate-*l*91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{y \cdot \left(y \cdot 0.3333333333333333\right)} + 2}}}{y} \]
      25. fma-def91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y, y \cdot 0.3333333333333333, 2\right)}}}}{y} \]
    9. Applied egg-rr91.7%

      \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\frac{1}{\frac{1}{\mathsf{fma}\left(y, y \cdot 0.3333333333333333, 2\right)}}}}{y} \]
    10. Step-by-step derivation
      1. remove-double-div91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\mathsf{fma}\left(y, y \cdot 0.3333333333333333, 2\right)}}{y} \]
      2. fma-udef91.7%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}}{y} \]
    11. Applied egg-rr91.7%

      \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}}{y} \]

    if 4.50000000000000009e154 < 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. *-commutative100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 23:\\ \;\;\;\;\cos x\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{+102}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \left(x \cdot x\right)\right)\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{+154}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot \left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(y \cdot \left(\cos x \cdot 0.16666666666666666\right)\right)\\ \end{array} \]

Alternative 4: 68.0% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 23:\\ \;\;\;\;\cos x\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{+102}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \left(x \cdot x\right)\right)\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot \left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;\cos x \cdot \left(0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y 23.0)
   (cos x)
   (if (<= y 8.2e+102)
     (* (* y y) (+ 0.16666666666666666 (* -0.08333333333333333 (* x x))))
     (if (<= y 1.35e+154)
       (* 0.5 (/ (* y (+ (* y (* y 0.3333333333333333)) 2.0)) y))
       (* (cos x) (* 0.16666666666666666 (* y y)))))))
double code(double x, double y) {
	double tmp;
	if (y <= 23.0) {
		tmp = cos(x);
	} else if (y <= 8.2e+102) {
		tmp = (y * y) * (0.16666666666666666 + (-0.08333333333333333 * (x * x)));
	} else if (y <= 1.35e+154) {
		tmp = 0.5 * ((y * ((y * (y * 0.3333333333333333)) + 2.0)) / y);
	} else {
		tmp = cos(x) * (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 <= 23.0d0) then
        tmp = cos(x)
    else if (y <= 8.2d+102) then
        tmp = (y * y) * (0.16666666666666666d0 + ((-0.08333333333333333d0) * (x * x)))
    else if (y <= 1.35d+154) then
        tmp = 0.5d0 * ((y * ((y * (y * 0.3333333333333333d0)) + 2.0d0)) / y)
    else
        tmp = cos(x) * (0.16666666666666666d0 * (y * y))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= 23.0) {
		tmp = Math.cos(x);
	} else if (y <= 8.2e+102) {
		tmp = (y * y) * (0.16666666666666666 + (-0.08333333333333333 * (x * x)));
	} else if (y <= 1.35e+154) {
		tmp = 0.5 * ((y * ((y * (y * 0.3333333333333333)) + 2.0)) / y);
	} else {
		tmp = Math.cos(x) * (0.16666666666666666 * (y * y));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= 23.0:
		tmp = math.cos(x)
	elif y <= 8.2e+102:
		tmp = (y * y) * (0.16666666666666666 + (-0.08333333333333333 * (x * x)))
	elif y <= 1.35e+154:
		tmp = 0.5 * ((y * ((y * (y * 0.3333333333333333)) + 2.0)) / y)
	else:
		tmp = math.cos(x) * (0.16666666666666666 * (y * y))
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= 23.0)
		tmp = cos(x);
	elseif (y <= 8.2e+102)
		tmp = Float64(Float64(y * y) * Float64(0.16666666666666666 + Float64(-0.08333333333333333 * Float64(x * x))));
	elseif (y <= 1.35e+154)
		tmp = Float64(0.5 * Float64(Float64(y * Float64(Float64(y * Float64(y * 0.3333333333333333)) + 2.0)) / y));
	else
		tmp = Float64(cos(x) * Float64(0.16666666666666666 * Float64(y * y)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= 23.0)
		tmp = cos(x);
	elseif (y <= 8.2e+102)
		tmp = (y * y) * (0.16666666666666666 + (-0.08333333333333333 * (x * x)));
	elseif (y <= 1.35e+154)
		tmp = 0.5 * ((y * ((y * (y * 0.3333333333333333)) + 2.0)) / y);
	else
		tmp = cos(x) * (0.16666666666666666 * (y * y));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, 23.0], N[Cos[x], $MachinePrecision], If[LessEqual[y, 8.2e+102], N[(N[(y * y), $MachinePrecision] * N[(0.16666666666666666 + N[(-0.08333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.35e+154], N[(0.5 * N[(N[(y * N[(N[(y * N[(y * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(N[Cos[x], $MachinePrecision] * N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 8.2 \cdot 10^{+102}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \left(x \cdot x\right)\right)\\

\mathbf{elif}\;y \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \frac{y \cdot \left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}{y}\\

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


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

    1. Initial program 100.0%

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

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

    if 23 < y < 8.1999999999999999e102

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(0.16666666666666666 \cdot \cos x\right) \]
    10. Simplified4.5%

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

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

        \[\leadsto \left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \color{blue}{\left(x \cdot x\right)}\right) \]
    13. Simplified42.4%

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

    if 8.1999999999999999e102 < y < 1.35000000000000003e154

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{e^{y} - \frac{1}{e^{y}}}{y}} \]
    3. Step-by-step derivation
      1. rec-exp90.9%

        \[\leadsto 0.5 \cdot \frac{e^{y} - \color{blue}{e^{-y}}}{y} \]
    4. Simplified90.9%

      \[\leadsto \color{blue}{0.5 \cdot \frac{e^{y} - e^{-y}}{y}} \]
    5. Taylor expanded in y around 0 90.9%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{0.3333333333333333 \cdot {y}^{3} + 2 \cdot y}}{y} \]
    6. Step-by-step derivation
      1. unpow390.9%

        \[\leadsto 0.5 \cdot \frac{0.3333333333333333 \cdot \color{blue}{\left(\left(y \cdot y\right) \cdot y\right)} + 2 \cdot y}{y} \]
      2. unpow290.9%

        \[\leadsto 0.5 \cdot \frac{0.3333333333333333 \cdot \left(\color{blue}{{y}^{2}} \cdot y\right) + 2 \cdot y}{y} \]
      3. associate-*r*90.9%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(0.3333333333333333 \cdot {y}^{2}\right) \cdot y} + 2 \cdot y}{y} \]
      4. distribute-rgt-out90.9%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{y \cdot \left(0.3333333333333333 \cdot {y}^{2} + 2\right)}}{y} \]
      5. *-commutative90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\color{blue}{{y}^{2} \cdot 0.3333333333333333} + 2\right)}{y} \]
      6. fma-def90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\mathsf{fma}\left({y}^{2}, 0.3333333333333333, 2\right)}}{y} \]
      7. unpow290.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \mathsf{fma}\left(\color{blue}{y \cdot y}, 0.3333333333333333, 2\right)}{y} \]
    7. Simplified90.9%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}{y} \]
    8. Step-by-step derivation
      1. *-un-lft-identity90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(1 \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right)}}{y} \]
      2. *-commutative90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot 1\right)}}{y} \]
      3. metadata-eval90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{{y}^{0}}\right)}{y} \]
      4. metadata-eval90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot {y}^{\color{blue}{\left(1 + -1\right)}}\right)}{y} \]
      5. pow-prod-up90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{\left({y}^{1} \cdot {y}^{-1}\right)}\right)}{y} \]
      6. pow190.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(\color{blue}{y} \cdot {y}^{-1}\right)\right)}{y} \]
      7. inv-pow90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(y \cdot \color{blue}{\frac{1}{y}}\right)\right)}{y} \]
      8. associate-*l*90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(\left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot y\right) \cdot \frac{1}{y}\right)}}{y} \]
      9. *-commutative90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\color{blue}{\left(y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right)} \cdot \frac{1}{y}\right)}{y} \]
      10. *-commutative90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(\frac{1}{y} \cdot \left(y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right)\right)}}{y} \]
      11. associate-/r/90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\frac{1}{\frac{y}{y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}}}{y} \]
      12. clear-num90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\color{blue}{\frac{1}{\frac{y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}{y}}}}}{y} \]
      13. div-inv90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\left(y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right) \cdot \frac{1}{y}}}}}{y} \]
      14. *-commutative90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot y\right)} \cdot \frac{1}{y}}}}{y} \]
      15. associate-*l*90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(y \cdot \frac{1}{y}\right)}}}}{y} \]
      16. pow190.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(\color{blue}{{y}^{1}} \cdot \frac{1}{y}\right)}}}{y} \]
      17. inv-pow90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left({y}^{1} \cdot \color{blue}{{y}^{-1}}\right)}}}{y} \]
      18. pow-prod-up90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{{y}^{\left(1 + -1\right)}}}}}{y} \]
      19. metadata-eval90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot {y}^{\color{blue}{0}}}}}{y} \]
      20. metadata-eval90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{1}}}}{y} \]
      21. *-commutative90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{1 \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}}}{y} \]
      22. *-un-lft-identity90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}}}{y} \]
      23. fma-udef90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\left(y \cdot y\right) \cdot 0.3333333333333333 + 2}}}}{y} \]
      24. associate-*l*90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{y \cdot \left(y \cdot 0.3333333333333333\right)} + 2}}}{y} \]
      25. fma-def90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y, y \cdot 0.3333333333333333, 2\right)}}}}{y} \]
    9. Applied egg-rr90.9%

      \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\frac{1}{\frac{1}{\mathsf{fma}\left(y, y \cdot 0.3333333333333333, 2\right)}}}}{y} \]
    10. Step-by-step derivation
      1. remove-double-div90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\mathsf{fma}\left(y, y \cdot 0.3333333333333333, 2\right)}}{y} \]
      2. fma-udef90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}}{y} \]
    11. Applied egg-rr90.9%

      \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}}{y} \]

    if 1.35000000000000003e154 < 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. *-commutative100.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 23:\\ \;\;\;\;\cos x\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{+102}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \left(x \cdot x\right)\right)\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot \left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;\cos x \cdot \left(0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\ \end{array} \]

Alternative 5: 80.7% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;y \leq 8.2 \cdot 10^{+102}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \left(x \cdot x\right)\right)\\

\mathbf{elif}\;y \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \frac{y \cdot \left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}{y}\\

\mathbf{else}:\\
\;\;\;\;\cos x \cdot t_0\\


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

    1. Initial program 100.0%

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

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

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

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

    if 520 < y < 8.1999999999999999e102

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \color{blue}{\left(x \cdot x\right)}\right) \]
    13. Simplified43.7%

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

    if 8.1999999999999999e102 < y < 1.35000000000000003e154

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{e^{y} - \frac{1}{e^{y}}}{y}} \]
    3. Step-by-step derivation
      1. rec-exp90.9%

        \[\leadsto 0.5 \cdot \frac{e^{y} - \color{blue}{e^{-y}}}{y} \]
    4. Simplified90.9%

      \[\leadsto \color{blue}{0.5 \cdot \frac{e^{y} - e^{-y}}{y}} \]
    5. Taylor expanded in y around 0 90.9%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{0.3333333333333333 \cdot {y}^{3} + 2 \cdot y}}{y} \]
    6. Step-by-step derivation
      1. unpow390.9%

        \[\leadsto 0.5 \cdot \frac{0.3333333333333333 \cdot \color{blue}{\left(\left(y \cdot y\right) \cdot y\right)} + 2 \cdot y}{y} \]
      2. unpow290.9%

        \[\leadsto 0.5 \cdot \frac{0.3333333333333333 \cdot \left(\color{blue}{{y}^{2}} \cdot y\right) + 2 \cdot y}{y} \]
      3. associate-*r*90.9%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(0.3333333333333333 \cdot {y}^{2}\right) \cdot y} + 2 \cdot y}{y} \]
      4. distribute-rgt-out90.9%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{y \cdot \left(0.3333333333333333 \cdot {y}^{2} + 2\right)}}{y} \]
      5. *-commutative90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\color{blue}{{y}^{2} \cdot 0.3333333333333333} + 2\right)}{y} \]
      6. fma-def90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\mathsf{fma}\left({y}^{2}, 0.3333333333333333, 2\right)}}{y} \]
      7. unpow290.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \mathsf{fma}\left(\color{blue}{y \cdot y}, 0.3333333333333333, 2\right)}{y} \]
    7. Simplified90.9%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}{y} \]
    8. Step-by-step derivation
      1. *-un-lft-identity90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(1 \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right)}}{y} \]
      2. *-commutative90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot 1\right)}}{y} \]
      3. metadata-eval90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{{y}^{0}}\right)}{y} \]
      4. metadata-eval90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot {y}^{\color{blue}{\left(1 + -1\right)}}\right)}{y} \]
      5. pow-prod-up90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{\left({y}^{1} \cdot {y}^{-1}\right)}\right)}{y} \]
      6. pow190.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(\color{blue}{y} \cdot {y}^{-1}\right)\right)}{y} \]
      7. inv-pow90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(y \cdot \color{blue}{\frac{1}{y}}\right)\right)}{y} \]
      8. associate-*l*90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(\left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot y\right) \cdot \frac{1}{y}\right)}}{y} \]
      9. *-commutative90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\color{blue}{\left(y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right)} \cdot \frac{1}{y}\right)}{y} \]
      10. *-commutative90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(\frac{1}{y} \cdot \left(y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right)\right)}}{y} \]
      11. associate-/r/90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\frac{1}{\frac{y}{y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}}}{y} \]
      12. clear-num90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\color{blue}{\frac{1}{\frac{y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}{y}}}}}{y} \]
      13. div-inv90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\left(y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right) \cdot \frac{1}{y}}}}}{y} \]
      14. *-commutative90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot y\right)} \cdot \frac{1}{y}}}}{y} \]
      15. associate-*l*90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(y \cdot \frac{1}{y}\right)}}}}{y} \]
      16. pow190.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(\color{blue}{{y}^{1}} \cdot \frac{1}{y}\right)}}}{y} \]
      17. inv-pow90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left({y}^{1} \cdot \color{blue}{{y}^{-1}}\right)}}}{y} \]
      18. pow-prod-up90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{{y}^{\left(1 + -1\right)}}}}}{y} \]
      19. metadata-eval90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot {y}^{\color{blue}{0}}}}}{y} \]
      20. metadata-eval90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{1}}}}{y} \]
      21. *-commutative90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{1 \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}}}{y} \]
      22. *-un-lft-identity90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}}}{y} \]
      23. fma-udef90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\left(y \cdot y\right) \cdot 0.3333333333333333 + 2}}}}{y} \]
      24. associate-*l*90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{y \cdot \left(y \cdot 0.3333333333333333\right)} + 2}}}{y} \]
      25. fma-def90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y, y \cdot 0.3333333333333333, 2\right)}}}}{y} \]
    9. Applied egg-rr90.9%

      \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\frac{1}{\frac{1}{\mathsf{fma}\left(y, y \cdot 0.3333333333333333, 2\right)}}}}{y} \]
    10. Step-by-step derivation
      1. remove-double-div90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\mathsf{fma}\left(y, y \cdot 0.3333333333333333, 2\right)}}{y} \]
      2. fma-udef90.9%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}}{y} \]
    11. Applied egg-rr90.9%

      \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}}{y} \]

    if 1.35000000000000003e154 < 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. *-commutative100.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 520:\\ \;\;\;\;\cos x \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{+102}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \left(x \cdot x\right)\right)\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot \left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;\cos x \cdot \left(0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\ \end{array} \]

Alternative 6: 64.6% accurate, 2.0× speedup?

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

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

\mathbf{elif}\;y \leq 8.5 \cdot 10^{+102}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \left(x \cdot x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y \cdot \left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}{y}\\


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

    1. Initial program 100.0%

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

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

    if 23 < y < 8.4999999999999996e102

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(0.16666666666666666 \cdot \cos x\right) \]
    10. Simplified4.5%

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

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

        \[\leadsto \left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \color{blue}{\left(x \cdot x\right)}\right) \]
    13. Simplified42.4%

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

    if 8.4999999999999996e102 < y

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{e^{y} - \frac{1}{e^{y}}}{y}} \]
    3. Step-by-step derivation
      1. rec-exp81.6%

        \[\leadsto 0.5 \cdot \frac{e^{y} - \color{blue}{e^{-y}}}{y} \]
    4. Simplified81.6%

      \[\leadsto \color{blue}{0.5 \cdot \frac{e^{y} - e^{-y}}{y}} \]
    5. Taylor expanded in y around 0 81.6%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{0.3333333333333333 \cdot {y}^{3} + 2 \cdot y}}{y} \]
    6. Step-by-step derivation
      1. unpow381.6%

        \[\leadsto 0.5 \cdot \frac{0.3333333333333333 \cdot \color{blue}{\left(\left(y \cdot y\right) \cdot y\right)} + 2 \cdot y}{y} \]
      2. unpow281.6%

        \[\leadsto 0.5 \cdot \frac{0.3333333333333333 \cdot \left(\color{blue}{{y}^{2}} \cdot y\right) + 2 \cdot y}{y} \]
      3. associate-*r*81.6%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(0.3333333333333333 \cdot {y}^{2}\right) \cdot y} + 2 \cdot y}{y} \]
      4. distribute-rgt-out81.6%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{y \cdot \left(0.3333333333333333 \cdot {y}^{2} + 2\right)}}{y} \]
      5. *-commutative81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\color{blue}{{y}^{2} \cdot 0.3333333333333333} + 2\right)}{y} \]
      6. fma-def81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\mathsf{fma}\left({y}^{2}, 0.3333333333333333, 2\right)}}{y} \]
      7. unpow281.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \mathsf{fma}\left(\color{blue}{y \cdot y}, 0.3333333333333333, 2\right)}{y} \]
    7. Simplified81.6%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}{y} \]
    8. Step-by-step derivation
      1. *-un-lft-identity81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(1 \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right)}}{y} \]
      2. *-commutative81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot 1\right)}}{y} \]
      3. metadata-eval81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{{y}^{0}}\right)}{y} \]
      4. metadata-eval81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot {y}^{\color{blue}{\left(1 + -1\right)}}\right)}{y} \]
      5. pow-prod-up81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{\left({y}^{1} \cdot {y}^{-1}\right)}\right)}{y} \]
      6. pow181.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(\color{blue}{y} \cdot {y}^{-1}\right)\right)}{y} \]
      7. inv-pow81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(y \cdot \color{blue}{\frac{1}{y}}\right)\right)}{y} \]
      8. associate-*l*81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(\left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot y\right) \cdot \frac{1}{y}\right)}}{y} \]
      9. *-commutative81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\color{blue}{\left(y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right)} \cdot \frac{1}{y}\right)}{y} \]
      10. *-commutative81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(\frac{1}{y} \cdot \left(y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right)\right)}}{y} \]
      11. associate-/r/81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\frac{1}{\frac{y}{y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}}}{y} \]
      12. clear-num81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\color{blue}{\frac{1}{\frac{y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}{y}}}}}{y} \]
      13. div-inv81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\left(y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right) \cdot \frac{1}{y}}}}}{y} \]
      14. *-commutative81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot y\right)} \cdot \frac{1}{y}}}}{y} \]
      15. associate-*l*81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(y \cdot \frac{1}{y}\right)}}}}{y} \]
      16. pow181.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(\color{blue}{{y}^{1}} \cdot \frac{1}{y}\right)}}}{y} \]
      17. inv-pow81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left({y}^{1} \cdot \color{blue}{{y}^{-1}}\right)}}}{y} \]
      18. pow-prod-up81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{{y}^{\left(1 + -1\right)}}}}}{y} \]
      19. metadata-eval81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot {y}^{\color{blue}{0}}}}}{y} \]
      20. metadata-eval81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{1}}}}{y} \]
      21. *-commutative81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{1 \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}}}{y} \]
      22. *-un-lft-identity81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}}}{y} \]
      23. fma-udef81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\left(y \cdot y\right) \cdot 0.3333333333333333 + 2}}}}{y} \]
      24. associate-*l*81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{y \cdot \left(y \cdot 0.3333333333333333\right)} + 2}}}{y} \]
      25. fma-def81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y, y \cdot 0.3333333333333333, 2\right)}}}}{y} \]
    9. Applied egg-rr81.6%

      \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\frac{1}{\frac{1}{\mathsf{fma}\left(y, y \cdot 0.3333333333333333, 2\right)}}}}{y} \]
    10. Step-by-step derivation
      1. remove-double-div81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\mathsf{fma}\left(y, y \cdot 0.3333333333333333, 2\right)}}{y} \]
      2. fma-udef81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}}{y} \]
    11. Applied egg-rr81.6%

      \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}}{y} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification66.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 23:\\ \;\;\;\;\cos x\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{+102}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \left(x \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot \left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}{y}\\ \end{array} \]

Alternative 7: 51.9% accurate, 12.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 250:\\ \;\;\;\;1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{+102}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \left(x \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot \left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}{y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y 250.0)
   (+ 1.0 (* 0.16666666666666666 (* y y)))
   (if (<= y 8.2e+102)
     (* (* y y) (+ 0.16666666666666666 (* -0.08333333333333333 (* x x))))
     (* 0.5 (/ (* y (+ (* y (* y 0.3333333333333333)) 2.0)) y)))))
double code(double x, double y) {
	double tmp;
	if (y <= 250.0) {
		tmp = 1.0 + (0.16666666666666666 * (y * y));
	} else if (y <= 8.2e+102) {
		tmp = (y * y) * (0.16666666666666666 + (-0.08333333333333333 * (x * x)));
	} else {
		tmp = 0.5 * ((y * ((y * (y * 0.3333333333333333)) + 2.0)) / y);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= 250.0d0) then
        tmp = 1.0d0 + (0.16666666666666666d0 * (y * y))
    else if (y <= 8.2d+102) then
        tmp = (y * y) * (0.16666666666666666d0 + ((-0.08333333333333333d0) * (x * x)))
    else
        tmp = 0.5d0 * ((y * ((y * (y * 0.3333333333333333d0)) + 2.0d0)) / y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= 250.0) {
		tmp = 1.0 + (0.16666666666666666 * (y * y));
	} else if (y <= 8.2e+102) {
		tmp = (y * y) * (0.16666666666666666 + (-0.08333333333333333 * (x * x)));
	} else {
		tmp = 0.5 * ((y * ((y * (y * 0.3333333333333333)) + 2.0)) / y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= 250.0:
		tmp = 1.0 + (0.16666666666666666 * (y * y))
	elif y <= 8.2e+102:
		tmp = (y * y) * (0.16666666666666666 + (-0.08333333333333333 * (x * x)))
	else:
		tmp = 0.5 * ((y * ((y * (y * 0.3333333333333333)) + 2.0)) / y)
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= 250.0)
		tmp = Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)));
	elseif (y <= 8.2e+102)
		tmp = Float64(Float64(y * y) * Float64(0.16666666666666666 + Float64(-0.08333333333333333 * Float64(x * x))));
	else
		tmp = Float64(0.5 * Float64(Float64(y * Float64(Float64(y * Float64(y * 0.3333333333333333)) + 2.0)) / y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= 250.0)
		tmp = 1.0 + (0.16666666666666666 * (y * y));
	elseif (y <= 8.2e+102)
		tmp = (y * y) * (0.16666666666666666 + (-0.08333333333333333 * (x * x)));
	else
		tmp = 0.5 * ((y * ((y * (y * 0.3333333333333333)) + 2.0)) / y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, 250.0], N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.2e+102], N[(N[(y * y), $MachinePrecision] * N[(0.16666666666666666 + N[(-0.08333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y * N[(N[(y * N[(y * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 8.2 \cdot 10^{+102}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \left(x \cdot x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y \cdot \left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}{y}\\


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

    1. Initial program 100.0%

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

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

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

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

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

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

    if 250 < y < 8.1999999999999999e102

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \color{blue}{\left(x \cdot x\right)}\right) \]
    13. Simplified43.7%

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

    if 8.1999999999999999e102 < y

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{e^{y} - \frac{1}{e^{y}}}{y}} \]
    3. Step-by-step derivation
      1. rec-exp81.6%

        \[\leadsto 0.5 \cdot \frac{e^{y} - \color{blue}{e^{-y}}}{y} \]
    4. Simplified81.6%

      \[\leadsto \color{blue}{0.5 \cdot \frac{e^{y} - e^{-y}}{y}} \]
    5. Taylor expanded in y around 0 81.6%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{0.3333333333333333 \cdot {y}^{3} + 2 \cdot y}}{y} \]
    6. Step-by-step derivation
      1. unpow381.6%

        \[\leadsto 0.5 \cdot \frac{0.3333333333333333 \cdot \color{blue}{\left(\left(y \cdot y\right) \cdot y\right)} + 2 \cdot y}{y} \]
      2. unpow281.6%

        \[\leadsto 0.5 \cdot \frac{0.3333333333333333 \cdot \left(\color{blue}{{y}^{2}} \cdot y\right) + 2 \cdot y}{y} \]
      3. associate-*r*81.6%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(0.3333333333333333 \cdot {y}^{2}\right) \cdot y} + 2 \cdot y}{y} \]
      4. distribute-rgt-out81.6%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{y \cdot \left(0.3333333333333333 \cdot {y}^{2} + 2\right)}}{y} \]
      5. *-commutative81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\color{blue}{{y}^{2} \cdot 0.3333333333333333} + 2\right)}{y} \]
      6. fma-def81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\mathsf{fma}\left({y}^{2}, 0.3333333333333333, 2\right)}}{y} \]
      7. unpow281.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \mathsf{fma}\left(\color{blue}{y \cdot y}, 0.3333333333333333, 2\right)}{y} \]
    7. Simplified81.6%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}{y} \]
    8. Step-by-step derivation
      1. *-un-lft-identity81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(1 \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right)}}{y} \]
      2. *-commutative81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot 1\right)}}{y} \]
      3. metadata-eval81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{{y}^{0}}\right)}{y} \]
      4. metadata-eval81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot {y}^{\color{blue}{\left(1 + -1\right)}}\right)}{y} \]
      5. pow-prod-up81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{\left({y}^{1} \cdot {y}^{-1}\right)}\right)}{y} \]
      6. pow181.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(\color{blue}{y} \cdot {y}^{-1}\right)\right)}{y} \]
      7. inv-pow81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(y \cdot \color{blue}{\frac{1}{y}}\right)\right)}{y} \]
      8. associate-*l*81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(\left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot y\right) \cdot \frac{1}{y}\right)}}{y} \]
      9. *-commutative81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \left(\color{blue}{\left(y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right)} \cdot \frac{1}{y}\right)}{y} \]
      10. *-commutative81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(\frac{1}{y} \cdot \left(y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right)\right)}}{y} \]
      11. associate-/r/81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\frac{1}{\frac{y}{y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}}}{y} \]
      12. clear-num81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\color{blue}{\frac{1}{\frac{y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}{y}}}}}{y} \]
      13. div-inv81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\left(y \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)\right) \cdot \frac{1}{y}}}}}{y} \]
      14. *-commutative81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\left(\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot y\right)} \cdot \frac{1}{y}}}}{y} \]
      15. associate-*l*81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(y \cdot \frac{1}{y}\right)}}}}{y} \]
      16. pow181.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left(\color{blue}{{y}^{1}} \cdot \frac{1}{y}\right)}}}{y} \]
      17. inv-pow81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \left({y}^{1} \cdot \color{blue}{{y}^{-1}}\right)}}}{y} \]
      18. pow-prod-up81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{{y}^{\left(1 + -1\right)}}}}}{y} \]
      19. metadata-eval81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot {y}^{\color{blue}{0}}}}}{y} \]
      20. metadata-eval81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right) \cdot \color{blue}{1}}}}{y} \]
      21. *-commutative81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{1 \cdot \mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}}}{y} \]
      22. *-un-lft-identity81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y \cdot y, 0.3333333333333333, 2\right)}}}}{y} \]
      23. fma-udef81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\left(y \cdot y\right) \cdot 0.3333333333333333 + 2}}}}{y} \]
      24. associate-*l*81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{y \cdot \left(y \cdot 0.3333333333333333\right)} + 2}}}{y} \]
      25. fma-def81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y, y \cdot 0.3333333333333333, 2\right)}}}}{y} \]
    9. Applied egg-rr81.6%

      \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\frac{1}{\frac{1}{\mathsf{fma}\left(y, y \cdot 0.3333333333333333, 2\right)}}}}{y} \]
    10. Step-by-step derivation
      1. remove-double-div81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\mathsf{fma}\left(y, y \cdot 0.3333333333333333, 2\right)}}{y} \]
      2. fma-udef81.6%

        \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}}{y} \]
    11. Applied egg-rr81.6%

      \[\leadsto 0.5 \cdot \frac{y \cdot \color{blue}{\left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}}{y} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification52.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 250:\\ \;\;\;\;1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{+102}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \left(x \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot \left(y \cdot \left(y \cdot 0.3333333333333333\right) + 2\right)}{y}\\ \end{array} \]

Alternative 8: 50.4% accurate, 15.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 78:\\ \;\;\;\;1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(0.16666666666666666 + -0.08333333333333333 \cdot \left(x \cdot x\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y 78.0)
   (+ 1.0 (* 0.16666666666666666 (* y y)))
   (* (* y y) (+ 0.16666666666666666 (* -0.08333333333333333 (* x x))))))
double code(double x, double y) {
	double tmp;
	if (y <= 78.0) {
		tmp = 1.0 + (0.16666666666666666 * (y * y));
	} else {
		tmp = (y * y) * (0.16666666666666666 + (-0.08333333333333333 * (x * x)));
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= 78.0d0) then
        tmp = 1.0d0 + (0.16666666666666666d0 * (y * y))
    else
        tmp = (y * y) * (0.16666666666666666d0 + ((-0.08333333333333333d0) * (x * x)))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= 78.0) {
		tmp = 1.0 + (0.16666666666666666 * (y * y));
	} else {
		tmp = (y * y) * (0.16666666666666666 + (-0.08333333333333333 * (x * x)));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= 78.0:
		tmp = 1.0 + (0.16666666666666666 * (y * y))
	else:
		tmp = (y * y) * (0.16666666666666666 + (-0.08333333333333333 * (x * x)))
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= 78.0)
		tmp = Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)));
	else
		tmp = Float64(Float64(y * y) * Float64(0.16666666666666666 + Float64(-0.08333333333333333 * Float64(x * x))));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= 78.0)
		tmp = 1.0 + (0.16666666666666666 * (y * y));
	else
		tmp = (y * y) * (0.16666666666666666 + (-0.08333333333333333 * (x * x)));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, 78.0], N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * y), $MachinePrecision] * N[(0.16666666666666666 + N[(-0.08333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

    if 78 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(0.16666666666666666 \cdot \cos x\right) \]
    10. Simplified46.5%

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

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

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

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

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

Alternative 9: 38.0% accurate, 29.0× speedup?

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

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

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


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{e^{y} - \frac{1}{e^{y}}}{y}} \]
    3. Step-by-step derivation
      1. rec-exp28.2%

        \[\leadsto 0.5 \cdot \frac{e^{y} - \color{blue}{e^{-y}}}{y} \]
    4. Simplified28.2%

      \[\leadsto \color{blue}{0.5 \cdot \frac{e^{y} - e^{-y}}{y}} \]
    5. Taylor expanded in y around 0 35.0%

      \[\leadsto 0.5 \cdot \color{blue}{2} \]

    if 2.64999999999999991 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{y}^{2} \cdot 0.16666666666666666} \]
      2. unpow235.6%

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

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

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

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

Alternative 10: 38.0% accurate, 29.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.5:\\
\;\;\;\;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 < 2.5

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{e^{y} - \frac{1}{e^{y}}}{y}} \]
    3. Step-by-step derivation
      1. rec-exp28.2%

        \[\leadsto 0.5 \cdot \frac{e^{y} - \color{blue}{e^{-y}}}{y} \]
    4. Simplified28.2%

      \[\leadsto \color{blue}{0.5 \cdot \frac{e^{y} - e^{-y}}{y}} \]
    5. Taylor expanded in y around 0 35.0%

      \[\leadsto 0.5 \cdot \color{blue}{2} \]

    if 2.5 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 47.8% 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 74.1%

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

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

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

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

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

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

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

Alternative 12: 28.9% 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 x around 0 38.4%

    \[\leadsto \color{blue}{0.5 \cdot \frac{e^{y} - \frac{1}{e^{y}}}{y}} \]
  3. Step-by-step derivation
    1. rec-exp38.5%

      \[\leadsto 0.5 \cdot \frac{e^{y} - \color{blue}{e^{-y}}}{y} \]
  4. Simplified38.5%

    \[\leadsto \color{blue}{0.5 \cdot \frac{e^{y} - e^{-y}}{y}} \]
  5. Taylor expanded in y around 0 27.0%

    \[\leadsto 0.5 \cdot \color{blue}{2} \]
  6. Final simplification27.0%

    \[\leadsto 1 \]

Reproduce

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