
(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) (/ (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%
associate-/l*99.9%
Simplified99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2e-7) (/ y (/ x (sin x))) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2e-7) {
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-7) 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-7) {
tmp = y / (x / Math.sin(x));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2e-7: tmp = y / (x / math.sin(x)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2e-7) 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-7) tmp = y / (x / sin(x)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2e-7], 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^{-7}:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 1.9999999999999999e-7Initial program 84.3%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 47.9%
associate-/l*63.5%
Simplified63.5%
clear-num63.5%
un-div-inv63.6%
Applied egg-rr63.6%
if 1.9999999999999999e-7 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 80.3%
associate-*r/80.3%
clear-num80.3%
*-commutative80.3%
Applied egg-rr80.3%
associate-/r/80.3%
*-commutative80.3%
associate-*r*80.3%
unpow-180.3%
pow-plus80.3%
metadata-eval80.3%
metadata-eval80.3%
*-commutative80.3%
*-rgt-identity80.3%
Simplified80.3%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2e-7) (* y (/ (sin x) x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2e-7) {
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) <= 2d-7) 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) <= 2e-7) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2e-7: tmp = y * (math.sin(x) / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2e-7) 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) <= 2e-7) tmp = y * (sin(x) / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2e-7], 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 2 \cdot 10^{-7}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 1.9999999999999999e-7Initial program 84.3%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 47.9%
associate-/l*63.5%
Simplified63.5%
if 1.9999999999999999e-7 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 80.3%
associate-*r/80.3%
clear-num80.3%
*-commutative80.3%
Applied egg-rr80.3%
associate-/r/80.3%
*-commutative80.3%
associate-*r*80.3%
unpow-180.3%
pow-plus80.3%
metadata-eval80.3%
metadata-eval80.3%
*-commutative80.3%
*-rgt-identity80.3%
Simplified80.3%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2e-7) (/ x (/ x y)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2e-7) {
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) <= 2d-7) 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) <= 2e-7) {
tmp = x / (x / y);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2e-7: tmp = x / (x / y) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2e-7) 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) <= 2e-7) tmp = x / (x / y); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2e-7], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 1.9999999999999999e-7Initial program 84.3%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 76.0%
Taylor expanded in y around 0 57.5%
clear-num57.9%
un-div-inv57.1%
Applied egg-rr57.1%
if 1.9999999999999999e-7 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 80.3%
associate-*r/80.3%
clear-num80.3%
*-commutative80.3%
Applied egg-rr80.3%
associate-/r/80.3%
*-commutative80.3%
associate-*r*80.3%
unpow-180.3%
pow-plus80.3%
metadata-eval80.3%
metadata-eval80.3%
*-commutative80.3%
*-rgt-identity80.3%
Simplified80.3%
(FPCore (x y) :precision binary64 (* x (/ (sinh y) x)))
double code(double x, double y) {
return x * (sinh(y) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (sinh(y) / x)
end function
public static double code(double x, double y) {
return x * (Math.sinh(y) / x);
}
def code(x, y): return x * (math.sinh(y) / x)
function code(x, y) return Float64(x * Float64(sinh(y) / x)) end
function tmp = code(x, y) tmp = x * (sinh(y) / x); end
code[x_, y_] := N[(x * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\sinh y}{x}
\end{array}
Initial program 88.7%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 77.2%
(FPCore (x y) :precision binary64 (if (<= x 4.4e+272) (* x (/ 1.0 (/ x y))) (* (* x x) (* y -0.16666666666666666))))
double code(double x, double y) {
double tmp;
if (x <= 4.4e+272) {
tmp = x * (1.0 / (x / y));
} else {
tmp = (x * x) * (y * -0.16666666666666666);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 4.4d+272) then
tmp = x * (1.0d0 / (x / y))
else
tmp = (x * x) * (y * (-0.16666666666666666d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 4.4e+272) {
tmp = x * (1.0 / (x / y));
} else {
tmp = (x * x) * (y * -0.16666666666666666);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 4.4e+272: tmp = x * (1.0 / (x / y)) else: tmp = (x * x) * (y * -0.16666666666666666) return tmp
function code(x, y) tmp = 0.0 if (x <= 4.4e+272) tmp = Float64(x * Float64(1.0 / Float64(x / y))); else tmp = Float64(Float64(x * x) * Float64(y * -0.16666666666666666)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 4.4e+272) tmp = x * (1.0 / (x / y)); else tmp = (x * x) * (y * -0.16666666666666666); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 4.4e+272], N[(x * N[(1.0 / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(y * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.4 \cdot 10^{+272}:\\
\;\;\;\;x \cdot \frac{1}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot -0.16666666666666666\right)\\
\end{array}
\end{array}
if x < 4.40000000000000017e272Initial program 88.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 59.7%
clear-num59.2%
associate-/r/59.6%
Applied egg-rr59.6%
Taylor expanded in x around 0 49.0%
associate-/r/49.3%
Applied egg-rr49.3%
if 4.40000000000000017e272 < x Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 12.0%
Taylor expanded in x around 0 50.0%
distribute-rgt-in50.0%
*-lft-identity50.0%
associate-*l*50.0%
unpow250.0%
unpow350.0%
Simplified50.0%
Taylor expanded in x around inf 50.2%
*-commutative50.2%
associate-*r*50.2%
Simplified50.2%
unpow250.2%
Applied egg-rr50.2%
(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.7%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 57.8%
clear-num57.4%
associate-/r/57.7%
Applied egg-rr57.7%
Taylor expanded in x around 0 47.5%
associate-/r/47.9%
Applied egg-rr47.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%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 77.2%
Taylor expanded in y around 0 47.6%
(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%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 77.2%
Taylor expanded in y around 0 27.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 2024144
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:alt
(! :herbie-platform default (* (sin x) (/ (sinh y) x)))
(/ (* (sin x) (sinh y)) x))