
(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 88.7%
associate-*l/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 1e+15) (* (sin x) (/ y x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 1e+15) {
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+15) 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+15) {
tmp = Math.sin(x) * (y / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 1e+15: tmp = math.sin(x) * (y / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 1e+15) 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+15) tmp = sin(x) * (y / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 1e+15], 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^{+15}:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 1e15Initial program 83.8%
*-commutative83.8%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 50.1%
associate-/l*66.2%
associate-/r/74.0%
Simplified74.0%
if 1e15 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 71.8%
Final simplification73.3%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 1e+15) (* (/ (sin x) x) y) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 1e+15) {
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+15) 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+15) {
tmp = (Math.sin(x) / x) * y;
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 1e+15: tmp = (math.sin(x) / x) * y else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 1e+15) 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+15) tmp = (sin(x) / x) * y; else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 1e+15], 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^{+15}:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 1e15Initial program 83.8%
*-commutative83.8%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 50.1%
associate-/l*66.2%
Simplified66.2%
clear-num66.0%
associate-/r/66.2%
clear-num66.2%
Applied egg-rr66.2%
if 1e15 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 71.8%
Final simplification67.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 88.7%
*-commutative88.7%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 1e-8) (/ y (+ 1.0 (* x (* x 0.16666666666666666)))) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 1e-8) {
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) <= 1d-8) 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) <= 1e-8) {
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) <= 1e-8: 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) <= 1e-8) 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) <= 1e-8) 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], 1e-8], 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 10^{-8}:\\
\;\;\;\;\frac{y}{1 + x \cdot \left(x \cdot 0.16666666666666666\right)}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 1e-8Initial program 83.6%
*-commutative83.6%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 50.3%
associate-/l*66.7%
Simplified66.7%
clear-num66.7%
associate-/r/66.6%
Applied egg-rr66.6%
Taylor expanded in x around 0 55.2%
*-commutative55.2%
distribute-rgt-in55.2%
*-commutative55.2%
lft-mult-inverse55.2%
Applied egg-rr55.2%
if 1e-8 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 70.1%
Final simplification59.9%
(FPCore (x y) :precision binary64 (let* ((t_0 (* x (* x 0.16666666666666666)))) (if (<= y 0.0096) (/ y (+ 1.0 t_0)) (/ y t_0))))
double code(double x, double y) {
double t_0 = x * (x * 0.16666666666666666);
double tmp;
if (y <= 0.0096) {
tmp = y / (1.0 + t_0);
} else {
tmp = y / t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x * (x * 0.16666666666666666d0)
if (y <= 0.0096d0) then
tmp = y / (1.0d0 + t_0)
else
tmp = y / t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x * (x * 0.16666666666666666);
double tmp;
if (y <= 0.0096) {
tmp = y / (1.0 + t_0);
} else {
tmp = y / t_0;
}
return tmp;
}
def code(x, y): t_0 = x * (x * 0.16666666666666666) tmp = 0 if y <= 0.0096: tmp = y / (1.0 + t_0) else: tmp = y / t_0 return tmp
function code(x, y) t_0 = Float64(x * Float64(x * 0.16666666666666666)) tmp = 0.0 if (y <= 0.0096) tmp = Float64(y / Float64(1.0 + t_0)); else tmp = Float64(y / t_0); end return tmp end
function tmp_2 = code(x, y) t_0 = x * (x * 0.16666666666666666); tmp = 0.0; if (y <= 0.0096) tmp = y / (1.0 + t_0); else tmp = y / t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 0.0096], N[(y / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision], N[(y / t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot 0.16666666666666666\right)\\
\mathbf{if}\;y \leq 0.0096:\\
\;\;\;\;\frac{y}{1 + t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{t_0}\\
\end{array}
\end{array}
if y < 0.00959999999999999916Initial program 83.6%
*-commutative83.6%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 50.3%
associate-/l*66.7%
Simplified66.7%
clear-num66.7%
associate-/r/66.6%
Applied egg-rr66.6%
Taylor expanded in x around 0 55.2%
*-commutative55.2%
distribute-rgt-in55.2%
*-commutative55.2%
lft-mult-inverse55.2%
Applied egg-rr55.2%
if 0.00959999999999999916 < y Initial program 100.0%
*-commutative100.0%
associate-*l/100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 4.7%
associate-/l*4.7%
Simplified4.7%
clear-num4.7%
associate-/r/4.7%
Applied egg-rr4.7%
Taylor expanded in x around 0 3.2%
Taylor expanded in x around inf 32.1%
*-commutative32.1%
Simplified32.1%
Final simplification48.0%
(FPCore (x y) :precision binary64 (if (<= y 0.0096) (/ x (/ x y)) (/ y (* x (* x 0.16666666666666666)))))
double code(double x, double y) {
double tmp;
if (y <= 0.0096) {
tmp = x / (x / y);
} 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 <= 0.0096d0) then
tmp = x / (x / y)
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 <= 0.0096) {
tmp = x / (x / y);
} else {
tmp = y / (x * (x * 0.16666666666666666));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.0096: tmp = x / (x / y) else: tmp = y / (x * (x * 0.16666666666666666)) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.0096) tmp = Float64(x / Float64(x / y)); else tmp = Float64(y / Float64(x * Float64(x * 0.16666666666666666))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.0096) tmp = x / (x / y); else tmp = y / (x * (x * 0.16666666666666666)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.0096], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], N[(y / N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.0096:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x \cdot \left(x \cdot 0.16666666666666666\right)}\\
\end{array}
\end{array}
if y < 0.00959999999999999916Initial program 83.6%
*-commutative83.6%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 50.3%
Taylor expanded in x around 0 26.0%
*-commutative26.0%
Simplified26.0%
associate-/l*38.5%
associate-/r/61.7%
Applied egg-rr61.7%
*-commutative61.7%
clear-num62.4%
un-div-inv61.0%
Applied egg-rr61.0%
if 0.00959999999999999916 < y Initial program 100.0%
*-commutative100.0%
associate-*l/100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 4.7%
associate-/l*4.7%
Simplified4.7%
clear-num4.7%
associate-/r/4.7%
Applied egg-rr4.7%
Taylor expanded in x around 0 3.2%
Taylor expanded in x around inf 32.1%
*-commutative32.1%
Simplified32.1%
Final simplification51.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 88.7%
*-commutative88.7%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 36.1%
Taylor expanded in x around 0 23.4%
*-commutative23.4%
Simplified23.4%
associate-/l*27.8%
associate-/r/49.2%
Applied egg-rr49.2%
Final simplification49.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 88.7%
*-commutative88.7%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 36.1%
associate-/l*47.3%
associate-/r/58.2%
Simplified58.2%
Taylor expanded in x around 0 27.8%
Final simplification27.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 2024010
(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))