
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (<= y 1.5e-10) (sin x) (* (sinh y) (/ x y))))
double code(double x, double y) {
double tmp;
if (y <= 1.5e-10) {
tmp = sin(x);
} else {
tmp = sinh(y) * (x / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.5d-10) then
tmp = sin(x)
else
tmp = sinh(y) * (x / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.5e-10) {
tmp = Math.sin(x);
} else {
tmp = Math.sinh(y) * (x / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.5e-10: tmp = math.sin(x) else: tmp = math.sinh(y) * (x / y) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.5e-10) tmp = sin(x); else tmp = Float64(sinh(y) * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.5e-10) tmp = sin(x); else tmp = sinh(y) * (x / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.5e-10], N[Sin[x], $MachinePrecision], N[(N[Sinh[y], $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.5 \cdot 10^{-10}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\sinh y \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < 1.5e-10Initial program 100.0%
Taylor expanded in y around 0 65.5%
if 1.5e-10 < y Initial program 100.0%
add-log-exp99.0%
*-un-lft-identity99.0%
log-prod99.0%
metadata-eval99.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/100.0%
associate-*l/74.6%
*-commutative74.6%
Simplified74.6%
Taylor expanded in x around 0 54.9%
Final simplification62.8%
(FPCore (x y) :precision binary64 (if (<= y 1.5e-10) (sin x) (/ (* x (sinh y)) y)))
double code(double x, double y) {
double tmp;
if (y <= 1.5e-10) {
tmp = sin(x);
} else {
tmp = (x * sinh(y)) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.5d-10) then
tmp = sin(x)
else
tmp = (x * sinh(y)) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.5e-10) {
tmp = Math.sin(x);
} else {
tmp = (x * Math.sinh(y)) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.5e-10: tmp = math.sin(x) else: tmp = (x * math.sinh(y)) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 1.5e-10) tmp = sin(x); else tmp = Float64(Float64(x * sinh(y)) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.5e-10) tmp = sin(x); else tmp = (x * sinh(y)) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.5e-10], N[Sin[x], $MachinePrecision], N[(N[(x * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.5 \cdot 10^{-10}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \sinh y}{y}\\
\end{array}
\end{array}
if y < 1.5e-10Initial program 100.0%
Taylor expanded in y around 0 65.5%
if 1.5e-10 < y Initial program 100.0%
add-log-exp99.0%
*-un-lft-identity99.0%
log-prod99.0%
metadata-eval99.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/100.0%
associate-*l/74.6%
*-commutative74.6%
Simplified74.6%
Taylor expanded in x around 0 54.9%
associate-*r/80.3%
Applied egg-rr80.3%
Final simplification69.4%
(FPCore (x y) :precision binary64 (if (<= y 2.55e+88) (sin x) (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 2.55e+88) {
tmp = sin(x);
} else {
tmp = (x * 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.55d+88) then
tmp = sin(x)
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 2.55e+88) {
tmp = Math.sin(x);
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.55e+88: tmp = math.sin(x) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 2.55e+88) tmp = sin(x); else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2.55e+88) tmp = sin(x); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.55e+88], N[Sin[x], $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.55 \cdot 10^{+88}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 2.5499999999999999e88Initial program 100.0%
Taylor expanded in y around 0 60.1%
if 2.5499999999999999e88 < y Initial program 100.0%
add-log-exp100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/100.0%
associate-*l/63.8%
*-commutative63.8%
Simplified63.8%
Taylor expanded in x around 0 48.9%
associate-*r/85.1%
Applied egg-rr85.1%
Taylor expanded in y around 0 16.6%
Final simplification52.1%
(FPCore (x y) :precision binary64 (if (<= x 1.6e+41) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (x <= 1.6e+41) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 1.6d+41) then
tmp = x
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 1.6e+41) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.6e+41: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (x <= 1.6e+41) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.6e+41) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.6e+41], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.6 \cdot 10^{+41}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if x < 1.60000000000000005e41Initial program 100.0%
Taylor expanded in x around 0 51.9%
associate-*r/51.9%
rec-exp51.9%
Simplified51.9%
Taylor expanded in y around 0 30.6%
if 1.60000000000000005e41 < x Initial program 100.0%
add-log-exp99.5%
*-un-lft-identity99.5%
log-prod99.5%
metadata-eval99.5%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/99.7%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in x around 0 14.1%
associate-*r/14.4%
Applied egg-rr14.4%
Taylor expanded in y around 0 9.5%
Final simplification25.9%
(FPCore (x y) :precision binary64 (if (<= x 4100000.0) x 0.5))
double code(double x, double y) {
double tmp;
if (x <= 4100000.0) {
tmp = x;
} else {
tmp = 0.5;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 4100000.0d0) then
tmp = x
else
tmp = 0.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 4100000.0) {
tmp = x;
} else {
tmp = 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 4100000.0: tmp = x else: tmp = 0.5 return tmp
function code(x, y) tmp = 0.0 if (x <= 4100000.0) tmp = x; else tmp = 0.5; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 4100000.0) tmp = x; else tmp = 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 4100000.0], x, 0.5]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4100000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < 4.1e6Initial program 100.0%
Taylor expanded in x around 0 54.3%
associate-*r/54.3%
rec-exp54.3%
Simplified54.3%
Taylor expanded in y around 0 31.9%
if 4.1e6 < x Initial program 100.0%
add-log-exp99.5%
*-un-lft-identity99.5%
log-prod99.5%
metadata-eval99.5%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/99.7%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Applied egg-rr8.7%
Final simplification25.9%
(FPCore (x y) :precision binary64 -2.0)
double code(double x, double y) {
return -2.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -2.0d0
end function
public static double code(double x, double y) {
return -2.0;
}
def code(x, y): return -2.0
function code(x, y) return -2.0 end
function tmp = code(x, y) tmp = -2.0; end
code[x_, y_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 100.0%
add-log-exp78.0%
*-un-lft-identity78.0%
log-prod78.0%
metadata-eval78.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/89.5%
associate-*l/85.4%
*-commutative85.4%
Simplified85.4%
Applied egg-rr4.3%
Final simplification4.3%
(FPCore (x y) :precision binary64 -0.5)
double code(double x, double y) {
return -0.5;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -0.5d0
end function
public static double code(double x, double y) {
return -0.5;
}
def code(x, y): return -0.5
function code(x, y) return -0.5 end
function tmp = code(x, y) tmp = -0.5; end
code[x_, y_] := -0.5
\begin{array}{l}
\\
-0.5
\end{array}
Initial program 100.0%
add-log-exp78.0%
*-un-lft-identity78.0%
log-prod78.0%
metadata-eval78.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/89.5%
associate-*l/85.4%
*-commutative85.4%
Simplified85.4%
Applied egg-rr4.5%
Final simplification4.5%
(FPCore (x y) :precision binary64 0.25)
double code(double x, double y) {
return 0.25;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.25d0
end function
public static double code(double x, double y) {
return 0.25;
}
def code(x, y): return 0.25
function code(x, y) return 0.25 end
function tmp = code(x, y) tmp = 0.25; end
code[x_, y_] := 0.25
\begin{array}{l}
\\
0.25
\end{array}
Initial program 100.0%
add-log-exp78.0%
*-un-lft-identity78.0%
log-prod78.0%
metadata-eval78.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/89.5%
associate-*l/85.4%
*-commutative85.4%
Simplified85.4%
Applied egg-rr4.6%
Final simplification4.6%
(FPCore (x y) :precision binary64 0.5)
double code(double x, double y) {
return 0.5;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.5d0
end function
public static double code(double x, double y) {
return 0.5;
}
def code(x, y): return 0.5
function code(x, y) return 0.5 end
function tmp = code(x, y) tmp = 0.5; end
code[x_, y_] := 0.5
\begin{array}{l}
\\
0.5
\end{array}
Initial program 100.0%
add-log-exp78.0%
*-un-lft-identity78.0%
log-prod78.0%
metadata-eval78.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/89.5%
associate-*l/85.4%
*-commutative85.4%
Simplified85.4%
Applied egg-rr4.9%
Final simplification4.9%
herbie shell --seed 2024130
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))