
(FPCore (x y) :precision binary64 (/ (* (sin x) (sinh y)) x))
double code(double x, double y) {
return (sin(x) * sinh(y)) / x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) * sinh(y)) / x
end function
public static double code(double x, double y) {
return (Math.sin(x) * Math.sinh(y)) / x;
}
def code(x, y): return (math.sin(x) * math.sinh(y)) / x
function code(x, y) return Float64(Float64(sin(x) * sinh(y)) / x) end
function tmp = code(x, y) tmp = (sin(x) * sinh(y)) / x; end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x \cdot \sinh y}{x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* (sin x) (sinh y)) x))
double code(double x, double y) {
return (sin(x) * sinh(y)) / x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) * sinh(y)) / x
end function
public static double code(double x, double y) {
return (Math.sin(x) * Math.sinh(y)) / x;
}
def code(x, y): return (math.sin(x) * math.sinh(y)) / x
function code(x, y) return Float64(Float64(sin(x) * sinh(y)) / x) end
function tmp = code(x, y) tmp = (sin(x) * sinh(y)) / x; end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x \cdot \sinh y}{x}
\end{array}
(FPCore (x y) :precision binary64 (* (/ (sin x) x) (sinh y)))
double code(double x, double y) {
return (sin(x) / x) * sinh(y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) / x) * sinh(y)
end function
public static double code(double x, double y) {
return (Math.sin(x) / x) * Math.sinh(y);
}
def code(x, y): return (math.sin(x) / x) * math.sinh(y)
function code(x, y) return Float64(Float64(sin(x) / x) * sinh(y)) end
function tmp = code(x, y) tmp = (sin(x) / x) * sinh(y); end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x}{x} \cdot \sinh y
\end{array}
Initial program 89.4%
associate-*l/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 1e-8) (* (sin x) (/ y x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 1e-8) {
tmp = sin(x) * (y / x);
} else {
tmp = sinh(y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (sinh(y) <= 1d-8) then
tmp = sin(x) * (y / x)
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 1e-8) {
tmp = Math.sin(x) * (y / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 1e-8: tmp = math.sin(x) * (y / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 1e-8) tmp = Float64(sin(x) * Float64(y / x)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 1e-8) tmp = sin(x) * (y / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 1e-8], N[(N[Sin[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 10^{-8}:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 1e-8Initial program 85.3%
*-commutative85.3%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 53.7%
associate-/l*68.3%
associate-/r/78.4%
Simplified78.4%
if 1e-8 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 77.8%
Final simplification78.2%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 1e-8) (* (/ (sin x) x) y) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 1e-8) {
tmp = (sin(x) / x) * y;
} else {
tmp = sinh(y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (sinh(y) <= 1d-8) then
tmp = (sin(x) / x) * y
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 1e-8) {
tmp = (Math.sin(x) / x) * y;
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 1e-8: tmp = (math.sin(x) / x) * y else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 1e-8) tmp = Float64(Float64(sin(x) / x) * y); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 1e-8) tmp = (sin(x) / x) * y; else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 1e-8], N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 10^{-8}:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 1e-8Initial program 85.3%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 68.3%
if 1e-8 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 77.8%
Final simplification70.9%
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) x)))
double code(double x, double y) {
return sin(x) * (sinh(y) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / x)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / x);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / x)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / x)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / x); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{x}
\end{array}
Initial program 89.4%
*-commutative89.4%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2e-17) (/ y (* x (+ (* x 0.16666666666666666) (/ 1.0 x)))) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2e-17) {
tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x)));
} else {
tmp = sinh(y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (sinh(y) <= 2d-17) then
tmp = y / (x * ((x * 0.16666666666666666d0) + (1.0d0 / x)))
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 2e-17) {
tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x)));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2e-17: tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x))) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2e-17) tmp = Float64(y / Float64(x * Float64(Float64(x * 0.16666666666666666) + Float64(1.0 / x)))); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 2e-17) tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x))); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2e-17], N[(y / N[(x * N[(N[(x * 0.16666666666666666), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 2 \cdot 10^{-17}:\\
\;\;\;\;\frac{y}{x \cdot \left(x \cdot 0.16666666666666666 + \frac{1}{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 2.00000000000000014e-17Initial program 85.2%
*-commutative85.2%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 53.4%
associate-/l*68.1%
associate-/r/78.2%
Simplified78.2%
associate-/r/68.1%
div-inv68.0%
associate-/r*78.2%
Applied egg-rr78.2%
Taylor expanded in x around 0 58.5%
Taylor expanded in y around 0 48.3%
if 2.00000000000000014e-17 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 78.1%
Final simplification56.8%
(FPCore (x y) :precision binary64 (if (<= y 215.0) (/ y (* x (+ (* x 0.16666666666666666) (/ 1.0 x)))) (/ (/ y x) (* x 0.16666666666666666))))
double code(double x, double y) {
double tmp;
if (y <= 215.0) {
tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x)));
} else {
tmp = (y / x) / (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 <= 215.0d0) then
tmp = y / (x * ((x * 0.16666666666666666d0) + (1.0d0 / x)))
else
tmp = (y / x) / (x * 0.16666666666666666d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 215.0) {
tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x)));
} else {
tmp = (y / x) / (x * 0.16666666666666666);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 215.0: tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x))) else: tmp = (y / x) / (x * 0.16666666666666666) return tmp
function code(x, y) tmp = 0.0 if (y <= 215.0) tmp = Float64(y / Float64(x * Float64(Float64(x * 0.16666666666666666) + Float64(1.0 / x)))); else tmp = Float64(Float64(y / x) / Float64(x * 0.16666666666666666)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 215.0) tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x))); else tmp = (y / x) / (x * 0.16666666666666666); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 215.0], N[(y / N[(x * N[(N[(x * 0.16666666666666666), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y / x), $MachinePrecision] / N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 215:\\
\;\;\;\;\frac{y}{x \cdot \left(x \cdot 0.16666666666666666 + \frac{1}{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x}}{x \cdot 0.16666666666666666}\\
\end{array}
\end{array}
if y < 215Initial program 85.4%
*-commutative85.4%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 53.5%
associate-/l*68.0%
associate-/r/78.0%
Simplified78.0%
associate-/r/68.0%
div-inv67.9%
associate-/r*77.9%
Applied egg-rr77.9%
Taylor expanded in x around 0 58.4%
Taylor expanded in y around 0 48.4%
if 215 < y Initial program 100.0%
*-commutative100.0%
associate-*l/100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 4.2%
associate-/l*4.2%
associate-/r/25.4%
Simplified25.4%
associate-/r/4.2%
div-inv4.2%
associate-/r*25.4%
Applied egg-rr25.4%
Taylor expanded in x around 0 24.6%
Taylor expanded in x around inf 38.4%
*-commutative38.4%
Simplified38.4%
Final simplification45.6%
(FPCore (x y) :precision binary64 (if (<= y 260.0) (* x (/ y x)) (/ (/ y x) (* x 0.16666666666666666))))
double code(double x, double y) {
double tmp;
if (y <= 260.0) {
tmp = x * (y / x);
} else {
tmp = (y / x) / (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 <= 260.0d0) then
tmp = x * (y / x)
else
tmp = (y / x) / (x * 0.16666666666666666d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 260.0) {
tmp = x * (y / x);
} else {
tmp = (y / x) / (x * 0.16666666666666666);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 260.0: tmp = x * (y / x) else: tmp = (y / x) / (x * 0.16666666666666666) return tmp
function code(x, y) tmp = 0.0 if (y <= 260.0) tmp = Float64(x * Float64(y / x)); else tmp = Float64(Float64(y / x) / Float64(x * 0.16666666666666666)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 260.0) tmp = x * (y / x); else tmp = (y / x) / (x * 0.16666666666666666); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 260.0], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], N[(N[(y / x), $MachinePrecision] / N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 260:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x}}{x \cdot 0.16666666666666666}\\
\end{array}
\end{array}
if y < 260Initial program 85.4%
*-commutative85.4%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 53.5%
associate-/l*68.0%
associate-/r/78.0%
Simplified78.0%
associate-/r/68.0%
clear-num66.6%
Applied egg-rr66.6%
Taylor expanded in x around 0 35.5%
clear-num35.6%
lft-mult-inverse35.6%
associate-/l/55.7%
associate-/r/55.7%
/-rgt-identity55.7%
Applied egg-rr55.7%
if 260 < y Initial program 100.0%
*-commutative100.0%
associate-*l/100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 4.2%
associate-/l*4.2%
associate-/r/25.4%
Simplified25.4%
associate-/r/4.2%
div-inv4.2%
associate-/r*25.4%
Applied egg-rr25.4%
Taylor expanded in x around 0 24.6%
Taylor expanded in x around inf 38.4%
*-commutative38.4%
Simplified38.4%
Final simplification50.9%
(FPCore (x y) :precision binary64 (* x (/ y x)))
double code(double x, double y) {
return x * (y / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (y / x)
end function
public static double code(double x, double y) {
return x * (y / x);
}
def code(x, y): return x * (y / x)
function code(x, y) return Float64(x * Float64(y / x)) end
function tmp = code(x, y) tmp = x * (y / x); end
code[x_, y_] := N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{y}{x}
\end{array}
Initial program 89.4%
*-commutative89.4%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 39.8%
associate-/l*50.3%
associate-/r/63.4%
Simplified63.4%
associate-/r/50.3%
clear-num49.3%
Applied egg-rr49.3%
Taylor expanded in x around 0 26.8%
clear-num26.8%
lft-mult-inverse26.8%
associate-/l/47.2%
associate-/r/47.2%
/-rgt-identity47.2%
Applied egg-rr47.2%
Final simplification47.2%
(FPCore (x y) :precision binary64 y)
double code(double x, double y) {
return y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y
end function
public static double code(double x, double y) {
return y;
}
def code(x, y): return y
function code(x, y) return y end
function tmp = code(x, y) tmp = y; end
code[x_, y_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 89.4%
*-commutative89.4%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 39.8%
associate-/l*50.3%
associate-/r/63.4%
Simplified63.4%
Taylor expanded in x around 0 26.8%
Final simplification26.8%
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) x)))
double code(double x, double y) {
return sin(x) * (sinh(y) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / x)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / x);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / x)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / x)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / x); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{x}
\end{array}
herbie shell --seed 2023333
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:herbie-target
(* (sin x) (/ (sinh y) x))
(/ (* (sin x) (sinh y)) x))