Average Error: 0.1 → 0.1
Time: 6.8s
Precision: binary64
Cost: 6984
\[x \cdot \frac{\sin y}{y} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -1.513357304447594 \cdot 10^{-5}:\\ \;\;\;\;\frac{x \cdot \sin y}{y}\\ \mathbf{elif}\;y \leq 5.1180502069597055 \cdot 10^{-20}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\sin y \cdot \frac{x}{y}\\ \end{array} \]
(FPCore (x y) :precision binary64 (* x (/ (sin y) y)))
(FPCore (x y)
 :precision binary64
 (if (<= y -1.513357304447594e-5)
   (/ (* x (sin y)) y)
   (if (<= y 5.1180502069597055e-20) x (* (sin y) (/ x y)))))
double code(double x, double y) {
	return x * (sin(y) / y);
}
double code(double x, double y) {
	double tmp;
	if (y <= -1.513357304447594e-5) {
		tmp = (x * sin(y)) / y;
	} else if (y <= 5.1180502069597055e-20) {
		tmp = x;
	} else {
		tmp = sin(y) * (x / y);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = x * (sin(y) / y)
end function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-1.513357304447594d-5)) then
        tmp = (x * sin(y)) / y
    else if (y <= 5.1180502069597055d-20) then
        tmp = x
    else
        tmp = sin(y) * (x / y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	return x * (Math.sin(y) / y);
}
public static double code(double x, double y) {
	double tmp;
	if (y <= -1.513357304447594e-5) {
		tmp = (x * Math.sin(y)) / y;
	} else if (y <= 5.1180502069597055e-20) {
		tmp = x;
	} else {
		tmp = Math.sin(y) * (x / y);
	}
	return tmp;
}
def code(x, y):
	return x * (math.sin(y) / y)
def code(x, y):
	tmp = 0
	if y <= -1.513357304447594e-5:
		tmp = (x * math.sin(y)) / y
	elif y <= 5.1180502069597055e-20:
		tmp = x
	else:
		tmp = math.sin(y) * (x / y)
	return tmp
function code(x, y)
	return Float64(x * Float64(sin(y) / y))
end
function code(x, y)
	tmp = 0.0
	if (y <= -1.513357304447594e-5)
		tmp = Float64(Float64(x * sin(y)) / y);
	elseif (y <= 5.1180502069597055e-20)
		tmp = x;
	else
		tmp = Float64(sin(y) * Float64(x / y));
	end
	return tmp
end
function tmp = code(x, y)
	tmp = x * (sin(y) / y);
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -1.513357304447594e-5)
		tmp = (x * sin(y)) / y;
	elseif (y <= 5.1180502069597055e-20)
		tmp = x;
	else
		tmp = sin(y) * (x / y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := If[LessEqual[y, -1.513357304447594e-5], N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[y, 5.1180502069597055e-20], x, N[(N[Sin[y], $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]]
x \cdot \frac{\sin y}{y}
\begin{array}{l}
\mathbf{if}\;y \leq -1.513357304447594 \cdot 10^{-5}:\\
\;\;\;\;\frac{x \cdot \sin y}{y}\\

\mathbf{elif}\;y \leq 5.1180502069597055 \cdot 10^{-20}:\\
\;\;\;\;x\\

\mathbf{else}:\\
\;\;\;\;\sin y \cdot \frac{x}{y}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if y < -1.51335730444759396e-5

    1. Initial program 0.3

      \[x \cdot \frac{\sin y}{y} \]
    2. Taylor expanded in x around 0 0.2

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

    if -1.51335730444759396e-5 < y < 5.11805020695970547e-20

    1. Initial program 0.0

      \[x \cdot \frac{\sin y}{y} \]
    2. Applied egg-rr14.4

      \[\leadsto \color{blue}{\frac{1}{\frac{y}{x \cdot \sin y}}} \]
    3. Taylor expanded in y around 0 14.4

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

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{y} \cdot \frac{y}{x}}} \]
    5. Taylor expanded in y around 0 0.0

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

    if 5.11805020695970547e-20 < y

    1. Initial program 0.2

      \[x \cdot \frac{\sin y}{y} \]
    2. Taylor expanded in x around 0 0.3

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

      \[\leadsto \color{blue}{\sin y \cdot \frac{x}{y}} \]
      Proof
      (*.f64 (sin.f64 y) (/.f64 x y)): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 (sin.f64 y) x) y)): 58 points increase in error, 59 points decrease in error
  3. Recombined 3 regimes into one program.
  4. Final simplification0.1

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

Alternatives

Alternative 1
Error0.2
Cost6984
\[\begin{array}{l} t_0 := \sin y \cdot \frac{x}{y}\\ \mathbf{if}\;y \leq -1.513357304447594 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 5.1180502069597055 \cdot 10^{-20}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.1
Cost6720
\[x \cdot \frac{\sin y}{y} \]
Alternative 3
Error23.4
Cost840
\[\begin{array}{l} t_0 := \frac{1}{0.16666666666666666 \cdot \left(y \cdot \frac{y}{x}\right)}\\ \mathbf{if}\;y \leq -159.7043585464012:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.05641409254771451:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error23.4
Cost712
\[\begin{array}{l} t_0 := x \cdot \frac{6}{y \cdot y}\\ \mathbf{if}\;y \leq -159.7043585464012:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.05641409254771451:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error23.3
Cost704
\[\frac{x}{y \cdot \left(\frac{1}{y} + y \cdot 0.16666666666666666\right)} \]
Alternative 6
Error23.6
Cost584
\[\begin{array}{l} t_0 := \left(x + 1\right) + -1\\ \mathbf{if}\;y \leq -1.2768787602011338 \cdot 10^{+20}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 10598571496.341658:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error31.1
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022317 
(FPCore (x y)
  :name "Linear.Quaternion:$cexp from linear-1.19.1.3"
  :precision binary64
  (* x (/ (sin y) y)))