
(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 (/ (sinh y) (/ x (sin x))))
double code(double x, double y) {
return sinh(y) / (x / sin(x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sinh(y) / (x / sin(x))
end function
public static double code(double x, double y) {
return Math.sinh(y) / (x / Math.sin(x));
}
def code(x, y): return math.sinh(y) / (x / math.sin(x))
function code(x, y) return Float64(sinh(y) / Float64(x / sin(x))) end
function tmp = code(x, y) tmp = sinh(y) / (x / sin(x)); end
code[x_, y_] := N[(N[Sinh[y], $MachinePrecision] / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sinh y}{\frac{x}{\sin x}}
\end{array}
Initial program 87.2%
associate-/l*99.5%
Simplified99.5%
add-log-exp63.8%
*-un-lft-identity63.8%
log-prod63.8%
metadata-eval63.8%
add-log-exp99.5%
Applied egg-rr99.5%
+-lft-identity99.5%
associate-*r/87.2%
associate-*l/99.9%
Simplified99.9%
*-commutative99.9%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 4e-8) (/ y (/ x (sin x))) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 4e-8) {
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) <= 4d-8) 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) <= 4e-8) {
tmp = y / (x / Math.sin(x));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 4e-8: tmp = y / (x / math.sin(x)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 4e-8) 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) <= 4e-8) tmp = y / (x / sin(x)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 4e-8], 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 4 \cdot 10^{-8}:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 4.0000000000000001e-8Initial program 82.1%
associate-/l*99.9%
Simplified99.9%
add-log-exp50.1%
*-un-lft-identity50.1%
log-prod50.1%
metadata-eval50.1%
add-log-exp99.9%
Applied egg-rr99.9%
+-lft-identity99.9%
associate-*r/82.1%
associate-*l/99.9%
Simplified99.9%
*-commutative99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 72.5%
if 4.0000000000000001e-8 < (sinh.f64 y) Initial program 100.0%
associate-/l*98.7%
Simplified98.7%
add-log-exp98.2%
*-un-lft-identity98.2%
log-prod98.2%
metadata-eval98.2%
add-log-exp98.7%
Applied egg-rr98.7%
+-lft-identity98.7%
associate-*r/100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 72.6%
Final simplification72.5%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 4e-8) (* y (/ (sin x) x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 4e-8) {
tmp = y * (sin(x) / 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) <= 4d-8) then
tmp = y * (sin(x) / 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) <= 4e-8) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 4e-8: tmp = y * (math.sin(x) / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 4e-8) tmp = Float64(y * Float64(sin(x) / x)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 4e-8) tmp = y * (sin(x) / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 4e-8], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 4 \cdot 10^{-8}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 4.0000000000000001e-8Initial program 82.1%
associate-/l*99.9%
Simplified99.9%
add-log-exp50.1%
*-un-lft-identity50.1%
log-prod50.1%
metadata-eval50.1%
add-log-exp99.9%
Applied egg-rr99.9%
+-lft-identity99.9%
associate-*r/82.1%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 72.5%
if 4.0000000000000001e-8 < (sinh.f64 y) Initial program 100.0%
associate-/l*98.7%
Simplified98.7%
add-log-exp98.2%
*-un-lft-identity98.2%
log-prod98.2%
metadata-eval98.2%
add-log-exp98.7%
Applied egg-rr98.7%
+-lft-identity98.7%
associate-*r/100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 72.6%
Final simplification72.5%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 4e-8) (* (sin x) (/ y x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 4e-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) <= 4d-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) <= 4e-8) {
tmp = Math.sin(x) * (y / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 4e-8: tmp = math.sin(x) * (y / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 4e-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) <= 4e-8) tmp = sin(x) * (y / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 4e-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 4 \cdot 10^{-8}:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 4.0000000000000001e-8Initial program 82.1%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 79.1%
if 4.0000000000000001e-8 < (sinh.f64 y) Initial program 100.0%
associate-/l*98.7%
Simplified98.7%
add-log-exp98.2%
*-un-lft-identity98.2%
log-prod98.2%
metadata-eval98.2%
add-log-exp98.7%
Applied egg-rr98.7%
+-lft-identity98.7%
associate-*r/100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 72.6%
Final simplification77.3%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 4e-23) (* x (/ y x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 4e-23) {
tmp = 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) <= 4d-23) then
tmp = 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) <= 4e-23) {
tmp = x * (y / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 4e-23: tmp = x * (y / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 4e-23) tmp = Float64(x * Float64(y / x)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 4e-23) tmp = x * (y / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 4e-23], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 4 \cdot 10^{-23}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 3.99999999999999984e-23Initial program 82.0%
Taylor expanded in y around 0 54.4%
Taylor expanded in x around 0 28.5%
associate-/l*61.8%
*-commutative61.8%
Applied egg-rr61.8%
if 3.99999999999999984e-23 < (sinh.f64 y) Initial program 100.0%
associate-/l*98.7%
Simplified98.7%
add-log-exp98.2%
*-un-lft-identity98.2%
log-prod98.2%
metadata-eval98.2%
add-log-exp98.7%
Applied egg-rr98.7%
+-lft-identity98.7%
associate-*r/100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 71.7%
Final simplification64.6%
(FPCore (x y) :precision binary64 (* (sinh y) (/ (sin x) x)))
double code(double x, double y) {
return sinh(y) * (sin(x) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sinh(y) * (sin(x) / x)
end function
public static double code(double x, double y) {
return Math.sinh(y) * (Math.sin(x) / x);
}
def code(x, y): return math.sinh(y) * (math.sin(x) / x)
function code(x, y) return Float64(sinh(y) * Float64(sin(x) / x)) end
function tmp = code(x, y) tmp = sinh(y) * (sin(x) / x); end
code[x_, y_] := N[(N[Sinh[y], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sinh y \cdot \frac{\sin x}{x}
\end{array}
Initial program 87.2%
associate-/l*99.5%
Simplified99.5%
add-log-exp63.8%
*-un-lft-identity63.8%
log-prod63.8%
metadata-eval63.8%
add-log-exp99.5%
Applied egg-rr99.5%
+-lft-identity99.5%
associate-*r/87.2%
associate-*l/99.9%
Simplified99.9%
Final simplification99.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 87.2%
associate-/l*99.5%
Simplified99.5%
(FPCore (x y) :precision binary64 (if (or (<= y 6800000.0) (not (<= y 7.5e+79))) (* x (/ y x)) (/ (* x (+ y (* -0.16666666666666666 (* x (* y x))))) x)))
double code(double x, double y) {
double tmp;
if ((y <= 6800000.0) || !(y <= 7.5e+79)) {
tmp = x * (y / x);
} else {
tmp = (x * (y + (-0.16666666666666666 * (x * (y * x))))) / x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= 6800000.0d0) .or. (.not. (y <= 7.5d+79))) then
tmp = x * (y / x)
else
tmp = (x * (y + ((-0.16666666666666666d0) * (x * (y * x))))) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= 6800000.0) || !(y <= 7.5e+79)) {
tmp = x * (y / x);
} else {
tmp = (x * (y + (-0.16666666666666666 * (x * (y * x))))) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= 6800000.0) or not (y <= 7.5e+79): tmp = x * (y / x) else: tmp = (x * (y + (-0.16666666666666666 * (x * (y * x))))) / x return tmp
function code(x, y) tmp = 0.0 if ((y <= 6800000.0) || !(y <= 7.5e+79)) tmp = Float64(x * Float64(y / x)); else tmp = Float64(Float64(x * Float64(y + Float64(-0.16666666666666666 * Float64(x * Float64(y * x))))) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= 6800000.0) || ~((y <= 7.5e+79))) tmp = x * (y / x); else tmp = (x * (y + (-0.16666666666666666 * (x * (y * x))))) / x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, 6800000.0], N[Not[LessEqual[y, 7.5e+79]], $MachinePrecision]], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(y + N[(-0.16666666666666666 * N[(x * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6800000 \lor \neg \left(y \leq 7.5 \cdot 10^{+79}\right):\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y + -0.16666666666666666 \cdot \left(x \cdot \left(y \cdot x\right)\right)\right)}{x}\\
\end{array}
\end{array}
if y < 6.8e6 or 7.49999999999999967e79 < y Initial program 86.3%
Taylor expanded in y around 0 43.5%
Taylor expanded in x around 0 26.1%
associate-/l*55.3%
*-commutative55.3%
Applied egg-rr55.3%
if 6.8e6 < y < 7.49999999999999967e79Initial program 100.0%
Taylor expanded in y around 0 2.8%
Taylor expanded in x around 0 31.8%
*-commutative31.8%
unpow231.8%
associate-*r*31.8%
Applied egg-rr31.8%
Final simplification53.7%
(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.2%
Taylor expanded in y around 0 40.8%
Taylor expanded in x around 0 24.8%
associate-/l*51.7%
*-commutative51.7%
Applied egg-rr51.7%
Final simplification51.7%
(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.2%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around 0 64.5%
Taylor expanded in x around 0 29.5%
(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 2024096
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:alt
(* (sin x) (/ (sinh y) x))
(/ (* (sin x) (sinh y)) x))