
(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 10 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 87.7%
associate-*l/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2e+289) (* (sin x) (/ y x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2e+289) {
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) <= 2d+289) 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) <= 2e+289) {
tmp = Math.sin(x) * (y / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2e+289: tmp = math.sin(x) * (y / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2e+289) 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) <= 2e+289) tmp = sin(x) * (y / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2e+289], 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 2 \cdot 10^{+289}:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 2.0000000000000001e289Initial program 82.8%
*-commutative82.8%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 50.5%
associate-/l*67.6%
associate-/r/78.3%
Simplified78.3%
if 2.0000000000000001e289 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 72.6%
Final simplification76.7%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2e+289) (* (/ (sin x) x) y) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2e+289) {
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) <= 2d+289) 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) <= 2e+289) {
tmp = (Math.sin(x) / x) * y;
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2e+289: tmp = (math.sin(x) / x) * y else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2e+289) 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) <= 2e+289) tmp = (sin(x) / x) * y; else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2e+289], 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 2 \cdot 10^{+289}:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 2.0000000000000001e289Initial program 82.8%
*-commutative82.8%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 50.5%
associate-/l*67.6%
Simplified67.6%
div-inv67.6%
*-commutative67.6%
clear-num67.6%
Applied egg-rr67.6%
if 2.0000000000000001e289 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 72.6%
Final simplification69.0%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2e+289) (/ y (/ x (sin x))) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2e+289) {
tmp = y / (x / sin(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+289) then
tmp = y / (x / sin(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+289) {
tmp = y / (x / Math.sin(x));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2e+289: tmp = y / (x / math.sin(x)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2e+289) tmp = Float64(y / Float64(x / sin(x))); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 2e+289) tmp = y / (x / sin(x)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2e+289], N[(y / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 2 \cdot 10^{+289}:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 2.0000000000000001e289Initial program 82.8%
*-commutative82.8%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 50.5%
associate-/l*67.6%
Simplified67.6%
if 2.0000000000000001e289 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 72.6%
Final simplification69.0%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2e+289) (/ y (+ 1.0 (* x (* x 0.16666666666666666)))) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2e+289) {
tmp = y / (1.0 + (x * (x * 0.16666666666666666)));
} 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+289) then
tmp = y / (1.0d0 + (x * (x * 0.16666666666666666d0)))
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+289) {
tmp = y / (1.0 + (x * (x * 0.16666666666666666)));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2e+289: tmp = y / (1.0 + (x * (x * 0.16666666666666666))) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2e+289) tmp = Float64(y / Float64(1.0 + Float64(x * Float64(x * 0.16666666666666666)))); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 2e+289) tmp = y / (1.0 + (x * (x * 0.16666666666666666))); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2e+289], N[(y / N[(1.0 + N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 2 \cdot 10^{+289}:\\
\;\;\;\;\frac{y}{1 + x \cdot \left(x \cdot 0.16666666666666666\right)}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 2.0000000000000001e289Initial program 82.8%
*-commutative82.8%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 50.5%
associate-/l*67.6%
associate-/r/78.3%
Simplified78.3%
associate-/r/67.6%
div-inv67.5%
associate-/r*78.2%
Applied egg-rr78.2%
Taylor expanded in x around 0 65.3%
Taylor expanded in y around 0 54.6%
*-commutative54.6%
fma-udef54.6%
fma-udef54.6%
distribute-lft-in54.6%
*-commutative54.6%
+-commutative54.6%
rgt-mult-inverse54.7%
*-commutative54.7%
Simplified54.7%
if 2.0000000000000001e289 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 72.6%
Final simplification59.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}
Initial program 87.7%
*-commutative87.7%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= y 38.0) (/ y (+ 1.0 (* x (* x 0.16666666666666666)))) (/ (* (/ y x) 6.0) x)))
double code(double x, double y) {
double tmp;
if (y <= 38.0) {
tmp = y / (1.0 + (x * (x * 0.16666666666666666)));
} else {
tmp = ((y / x) * 6.0) / x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 38.0d0) then
tmp = y / (1.0d0 + (x * (x * 0.16666666666666666d0)))
else
tmp = ((y / x) * 6.0d0) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 38.0) {
tmp = y / (1.0 + (x * (x * 0.16666666666666666)));
} else {
tmp = ((y / x) * 6.0) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 38.0: tmp = y / (1.0 + (x * (x * 0.16666666666666666))) else: tmp = ((y / x) * 6.0) / x return tmp
function code(x, y) tmp = 0.0 if (y <= 38.0) tmp = Float64(y / Float64(1.0 + Float64(x * Float64(x * 0.16666666666666666)))); else tmp = Float64(Float64(Float64(y / x) * 6.0) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 38.0) tmp = y / (1.0 + (x * (x * 0.16666666666666666))); else tmp = ((y / x) * 6.0) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 38.0], N[(y / N[(1.0 + N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y / x), $MachinePrecision] * 6.0), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 38:\\
\;\;\;\;\frac{y}{1 + x \cdot \left(x \cdot 0.16666666666666666\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x} \cdot 6}{x}\\
\end{array}
\end{array}
if y < 38Initial program 82.8%
*-commutative82.8%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 50.8%
associate-/l*67.9%
associate-/r/78.7%
Simplified78.7%
associate-/r/67.9%
div-inv67.8%
associate-/r*78.6%
Applied egg-rr78.6%
Taylor expanded in x around 0 65.6%
Taylor expanded in y around 0 54.9%
*-commutative54.9%
fma-udef54.9%
fma-udef54.9%
distribute-lft-in54.9%
*-commutative54.9%
+-commutative54.9%
rgt-mult-inverse55.0%
*-commutative55.0%
Simplified55.0%
if 38 < y Initial program 100.0%
*-commutative100.0%
associate-*l/100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 4.8%
/-rgt-identity4.8%
associate-/r/4.8%
Applied egg-rr4.8%
Taylor expanded in x around 0 3.9%
Taylor expanded in x around inf 42.2%
Final simplification51.3%
(FPCore (x y) :precision binary64 (if (<= y 38.0) (/ x (/ x y)) (/ (* (/ y x) 6.0) x)))
double code(double x, double y) {
double tmp;
if (y <= 38.0) {
tmp = x / (x / y);
} else {
tmp = ((y / x) * 6.0) / x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 38.0d0) then
tmp = x / (x / y)
else
tmp = ((y / x) * 6.0d0) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 38.0) {
tmp = x / (x / y);
} else {
tmp = ((y / x) * 6.0) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 38.0: tmp = x / (x / y) else: tmp = ((y / x) * 6.0) / x return tmp
function code(x, y) tmp = 0.0 if (y <= 38.0) tmp = Float64(x / Float64(x / y)); else tmp = Float64(Float64(Float64(y / x) * 6.0) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 38.0) tmp = x / (x / y); else tmp = ((y / x) * 6.0) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 38.0], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y / x), $MachinePrecision] * 6.0), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 38:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x} \cdot 6}{x}\\
\end{array}
\end{array}
if y < 38Initial program 82.8%
*-commutative82.8%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 50.8%
Taylor expanded in x around 0 24.4%
*-commutative24.4%
Simplified24.4%
associate-/l*37.9%
associate-/r/64.1%
Applied egg-rr64.1%
*-commutative64.1%
clear-num65.5%
un-div-inv64.6%
Applied egg-rr64.6%
if 38 < y Initial program 100.0%
*-commutative100.0%
associate-*l/100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 4.8%
/-rgt-identity4.8%
associate-/r/4.8%
Applied egg-rr4.8%
Taylor expanded in x around 0 3.9%
Taylor expanded in x around inf 42.2%
Final simplification58.1%
(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 87.7%
*-commutative87.7%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 37.5%
Taylor expanded in x around 0 20.3%
*-commutative20.3%
Simplified20.3%
associate-/l*28.1%
associate-/r/55.1%
Applied egg-rr55.1%
Final simplification55.1%
(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 87.7%
*-commutative87.7%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 37.5%
associate-/l*49.7%
associate-/r/65.7%
Simplified65.7%
Taylor expanded in x around 0 28.1%
Final simplification28.1%
(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 2023336
(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))