
(FPCore (x y) :precision binary64 :pre TRUE (* x (/ (sin y) y)))
double code(double x, double y) {
return x * (sin(y) / y);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (sin(y) / y)
end function
public static double code(double x, double y) {
return x * (Math.sin(y) / y);
}
def code(x, y): return x * (math.sin(y) / y)
function code(x, y) return Float64(x * Float64(sin(y) / y)) end
function tmp = code(x, y) tmp = x * (sin(y) / y); end
code[x_, y_] := N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = x * ((sin(y)) / y) END code
x \cdot \frac{\sin y}{y}
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (* x (/ (sin y) y)))
double code(double x, double y) {
return x * (sin(y) / y);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (sin(y) / y)
end function
public static double code(double x, double y) {
return x * (Math.sin(y) / y);
}
def code(x, y): return x * (math.sin(y) / y)
function code(x, y) return Float64(x * Float64(sin(y) / y)) end
function tmp = code(x, y) tmp = x * (sin(y) / y); end
code[x_, y_] := N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = x * ((sin(y)) / y) END code
x \cdot \frac{\sin y}{y}
(FPCore (x y) :precision binary64 :pre TRUE (if (<= (/ (sin y) y) 0.9995) (/ (* x (sin y)) y) (* x (fma (* y y) -0.16666666666666666 1.0))))
double code(double x, double y) {
double tmp;
if ((sin(y) / y) <= 0.9995) {
tmp = (x * sin(y)) / y;
} else {
tmp = x * fma((y * y), -0.16666666666666666, 1.0);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(sin(y) / y) <= 0.9995) tmp = Float64(Float64(x * sin(y)) / y); else tmp = Float64(x * fma(Float64(y * y), -0.16666666666666666, 1.0)); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], 0.9995], N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(x * N[(N[(y * y), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision]), $MachinePrecision]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp = IF (((sin(y)) / y) <= (9995000000000000550670620214077644050121307373046875e-52)) THEN ((x * (sin(y))) / y) ELSE (x * (((y * y) * (-1666666666666666574148081281236954964697360992431640625e-55)) + (1))) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\frac{\sin y}{y} \leq 0.9995:\\
\;\;\;\;\frac{x \cdot \sin y}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \mathsf{fma}\left(y \cdot y, -0.16666666666666666, 1\right)\\
\end{array}
if (/.f64 (sin.f64 y) y) < 0.99950000000000006Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites88.8%
if 0.99950000000000006 < (/.f64 (sin.f64 y) y) Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites50.5%
Applied rewrites50.5%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= (fabs y) 26110.61450005739) (* x (+ (fma (* -0.16666666666666666 (fabs y)) (fabs y) 0.5) 0.5)) (/ 1.0 (* (* 0.16666666666666666 (fabs y)) (/ (fabs y) x)))))
double code(double x, double y) {
double tmp;
if (fabs(y) <= 26110.61450005739) {
tmp = x * (fma((-0.16666666666666666 * fabs(y)), fabs(y), 0.5) + 0.5);
} else {
tmp = 1.0 / ((0.16666666666666666 * fabs(y)) * (fabs(y) / x));
}
return tmp;
}
function code(x, y) tmp = 0.0 if (abs(y) <= 26110.61450005739) tmp = Float64(x * Float64(fma(Float64(-0.16666666666666666 * abs(y)), abs(y), 0.5) + 0.5)); else tmp = Float64(1.0 / Float64(Float64(0.16666666666666666 * abs(y)) * Float64(abs(y) / x))); end return tmp end
code[x_, y_] := If[LessEqual[N[Abs[y], $MachinePrecision], 26110.61450005739], N[(x * N[(N[(N[(-0.16666666666666666 * N[Abs[y], $MachinePrecision]), $MachinePrecision] * N[Abs[y], $MachinePrecision] + 0.5), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(0.16666666666666666 * N[Abs[y], $MachinePrecision]), $MachinePrecision] * N[(N[Abs[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp = IF ((abs(y)) <= (2611061450005738879553973674774169921875e-35)) THEN (x * (((((-1666666666666666574148081281236954964697360992431640625e-55) * (abs(y))) * (abs(y))) + (5e-1)) + (5e-1))) ELSE ((1) / (((1666666666666666574148081281236954964697360992431640625e-55) * (abs(y))) * ((abs(y)) / x))) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\left|y\right| \leq 26110.61450005739:\\
\;\;\;\;x \cdot \left(\mathsf{fma}\left(-0.16666666666666666 \cdot \left|y\right|, \left|y\right|, 0.5\right) + 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(0.16666666666666666 \cdot \left|y\right|\right) \cdot \frac{\left|y\right|}{x}}\\
\end{array}
if y < 26110.614500057389Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites50.5%
Applied rewrites50.5%
if 26110.614500057389 < y Initial program 99.8%
Applied rewrites88.3%
Taylor expanded in y around 0
Applied rewrites63.2%
Taylor expanded in y around inf
Applied rewrites16.6%
Applied rewrites16.6%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= (/ (sin y) y) 3.1115210104175464e-119) (* 0.0 1.0) (* x 1.0)))
double code(double x, double y) {
double tmp;
if ((sin(y) / y) <= 3.1115210104175464e-119) {
tmp = 0.0 * 1.0;
} else {
tmp = x * 1.0;
}
return tmp;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((sin(y) / y) <= 3.1115210104175464d-119) then
tmp = 0.0d0 * 1.0d0
else
tmp = x * 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.sin(y) / y) <= 3.1115210104175464e-119) {
tmp = 0.0 * 1.0;
} else {
tmp = x * 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sin(y) / y) <= 3.1115210104175464e-119: tmp = 0.0 * 1.0 else: tmp = x * 1.0 return tmp
function code(x, y) tmp = 0.0 if (Float64(sin(y) / y) <= 3.1115210104175464e-119) tmp = Float64(0.0 * 1.0); else tmp = Float64(x * 1.0); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((sin(y) / y) <= 3.1115210104175464e-119) tmp = 0.0 * 1.0; else tmp = x * 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], 3.1115210104175464e-119], N[(0.0 * 1.0), $MachinePrecision], N[(x * 1.0), $MachinePrecision]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp = IF (((sin(y)) / y) <= (311152101041754642290024565439875431740613962063175481148591194442996388678289957470708513147988336046540112239599631655494021672392081353289379760901846390424021238903116260518260409730045459215395629766697200463532105992136490754611180397706904128805760152687370442659154707830946630375823502845378243364393711090087890625e-442)) THEN ((0) * (1)) ELSE (x * (1)) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\frac{\sin y}{y} \leq 3.1115210104175464 \cdot 10^{-119}:\\
\;\;\;\;0 \cdot 1\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1\\
\end{array}
if (/.f64 (sin.f64 y) y) < 3.1115210104175464e-119Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites51.2%
Taylor expanded in undef-var around zero
Applied rewrites15.8%
if 3.1115210104175464e-119 < (/.f64 (sin.f64 y) y) Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites51.2%
(FPCore (x y) :precision binary64 :pre TRUE (/ 1.0 (fma (* 0.16666666666666666 y) (/ y x) (/ 1.0 x))))
double code(double x, double y) {
return 1.0 / fma((0.16666666666666666 * y), (y / x), (1.0 / x));
}
function code(x, y) return Float64(1.0 / fma(Float64(0.16666666666666666 * y), Float64(y / x), Float64(1.0 / x))) end
code[x_, y_] := N[(1.0 / N[(N[(0.16666666666666666 * y), $MachinePrecision] * N[(y / x), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (1) / ((((1666666666666666574148081281236954964697360992431640625e-55) * y) * (y / x)) + ((1) / x)) END code
\frac{1}{\mathsf{fma}\left(0.16666666666666666 \cdot y, \frac{y}{x}, \frac{1}{x}\right)}
Initial program 99.8%
Applied rewrites88.3%
Taylor expanded in y around 0
Applied rewrites63.2%
Applied rewrites63.2%
(FPCore (x y) :precision binary64 :pre TRUE (/ 1.0 (/ (fma (* y y) 0.16666666666666666 1.0) x)))
double code(double x, double y) {
return 1.0 / (fma((y * y), 0.16666666666666666, 1.0) / x);
}
function code(x, y) return Float64(1.0 / Float64(fma(Float64(y * y), 0.16666666666666666, 1.0) / x)) end
code[x_, y_] := N[(1.0 / N[(N[(N[(y * y), $MachinePrecision] * 0.16666666666666666 + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (1) / ((((y * y) * (1666666666666666574148081281236954964697360992431640625e-55)) + (1)) / x) END code
\frac{1}{\frac{\mathsf{fma}\left(y \cdot y, 0.16666666666666666, 1\right)}{x}}
Initial program 99.8%
Applied rewrites88.3%
Taylor expanded in y around 0
Applied rewrites63.2%
Applied rewrites63.2%
(FPCore (x y) :precision binary64 :pre TRUE (* x 1.0))
double code(double x, double y) {
return x * 1.0;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * 1.0d0
end function
public static double code(double x, double y) {
return x * 1.0;
}
def code(x, y): return x * 1.0
function code(x, y) return Float64(x * 1.0) end
function tmp = code(x, y) tmp = x * 1.0; end
code[x_, y_] := N[(x * 1.0), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = x * (1) END code
x \cdot 1
Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites51.2%
herbie shell --seed 2026092
(FPCore (x y)
:name "Linear.Quaternion:$cexp from linear-1.19.1.3"
:precision binary64
(* x (/ (sin y) y)))