
(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 7 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) (/ (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.2%
associate-/l*99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 0.01) (* y (/ (sin x) x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 0.01) {
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) <= 0.01d0) 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) <= 0.01) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 0.01: tmp = y * (math.sin(x) / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 0.01) 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) <= 0.01) tmp = y * (sin(x) / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 0.01], 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 0.01:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 0.0100000000000000002Initial program 84.7%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 53.2%
associate-/l*68.4%
Simplified68.4%
if 0.0100000000000000002 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 77.6%
clear-num77.6%
un-div-inv77.6%
Applied egg-rr77.6%
associate-/r/77.6%
*-inverses77.6%
*-lft-identity77.6%
Simplified77.6%
Final simplification70.5%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 1e-56) (/ x (/ x y)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 1e-56) {
tmp = 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-56) then
tmp = 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-56) {
tmp = x / (x / y);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 1e-56: tmp = x / (x / y) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 1e-56) tmp = Float64(x / Float64(x / y)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 1e-56) tmp = x / (x / y); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 1e-56], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 10^{-56}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 1e-56Initial program 83.6%
associate-/l*99.8%
Simplified99.8%
clear-num97.7%
un-div-inv97.9%
Applied egg-rr97.9%
Taylor expanded in y around 0 72.7%
Taylor expanded in x around 0 57.7%
if 1e-56 < (sinh.f64 y) Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 72.2%
clear-num72.2%
un-div-inv72.2%
Applied egg-rr72.2%
associate-/r/72.3%
*-inverses72.3%
*-lft-identity72.3%
Simplified72.3%
Final simplification61.8%
(FPCore (x y) :precision binary64 (if (<= y 4e-105) (/ x (/ x y)) (* x (/ y x))))
double code(double x, double y) {
double tmp;
if (y <= 4e-105) {
tmp = x / (x / y);
} else {
tmp = x * (y / x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4d-105) then
tmp = x / (x / y)
else
tmp = x * (y / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 4e-105) {
tmp = x / (x / y);
} else {
tmp = x * (y / x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4e-105: tmp = x / (x / y) else: tmp = x * (y / x) return tmp
function code(x, y) tmp = 0.0 if (y <= 4e-105) tmp = Float64(x / Float64(x / y)); else tmp = Float64(x * Float64(y / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4e-105) tmp = x / (x / y); else tmp = x * (y / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4e-105], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{-105}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\end{array}
\end{array}
if y < 3.99999999999999986e-105Initial program 82.9%
associate-/l*99.8%
Simplified99.8%
clear-num97.6%
un-div-inv97.7%
Applied egg-rr97.7%
Taylor expanded in y around 0 70.5%
Taylor expanded in x around 0 58.7%
if 3.99999999999999986e-105 < y Initial program 98.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 51.4%
Taylor expanded in x around 0 35.4%
Final simplification51.0%
(FPCore (x y) :precision binary64 (* x (/ 1.0 (/ x y))))
double code(double x, double y) {
return x * (1.0 / (x / y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (1.0d0 / (x / y))
end function
public static double code(double x, double y) {
return x * (1.0 / (x / y));
}
def code(x, y): return x * (1.0 / (x / y))
function code(x, y) return Float64(x * Float64(1.0 / Float64(x / y))) end
function tmp = code(x, y) tmp = x * (1.0 / (x / y)); end
code[x_, y_] := N[(x * N[(1.0 / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{1}{\frac{x}{y}}
\end{array}
Initial program 88.2%
associate-/l*99.8%
Simplified99.8%
clear-num98.3%
un-div-inv98.4%
Applied egg-rr98.4%
Taylor expanded in y around 0 62.3%
Taylor expanded in x around 0 49.1%
frac-2neg49.1%
div-inv51.3%
distribute-neg-frac251.3%
Applied egg-rr51.3%
Final simplification51.3%
(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.2%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 65.9%
Taylor expanded in x around 0 49.5%
Final simplification49.5%
(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.2%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 72.5%
Taylor expanded in y around 0 27.9%
Final simplification27.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}
herbie shell --seed 2024050
(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))