
(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 89.8%
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 89.8%
associate-*r/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= y -500000000000.0) (sinh y) (if (<= y 0.00255) (* (sin x) (/ y x)) (sinh y))))
double code(double x, double y) {
double tmp;
if (y <= -500000000000.0) {
tmp = sinh(y);
} else if (y <= 0.00255) {
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 (y <= (-500000000000.0d0)) then
tmp = sinh(y)
else if (y <= 0.00255d0) 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 (y <= -500000000000.0) {
tmp = Math.sinh(y);
} else if (y <= 0.00255) {
tmp = Math.sin(x) * (y / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -500000000000.0: tmp = math.sinh(y) elif y <= 0.00255: tmp = math.sin(x) * (y / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (y <= -500000000000.0) tmp = sinh(y); elseif (y <= 0.00255) 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 (y <= -500000000000.0) tmp = sinh(y); elseif (y <= 0.00255) tmp = sin(x) * (y / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -500000000000.0], N[Sinh[y], $MachinePrecision], If[LessEqual[y, 0.00255], N[(N[Sin[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -500000000000:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;y \leq 0.00255:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if y < -5e11 or 0.0025500000000000002 < y Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 75.9%
if -5e11 < y < 0.0025500000000000002Initial program 78.8%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in y around 0 77.0%
associate-/l*98.1%
associate-/r/98.1%
Simplified98.1%
Final simplification86.6%
(FPCore (x y) :precision binary64 (if (<= y -500000000000.0) (sinh y) (if (<= y 5.9e-5) (* (/ (sin x) x) y) (sinh y))))
double code(double x, double y) {
double tmp;
if (y <= -500000000000.0) {
tmp = sinh(y);
} else if (y <= 5.9e-5) {
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 (y <= (-500000000000.0d0)) then
tmp = sinh(y)
else if (y <= 5.9d-5) 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 (y <= -500000000000.0) {
tmp = Math.sinh(y);
} else if (y <= 5.9e-5) {
tmp = (Math.sin(x) / x) * y;
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -500000000000.0: tmp = math.sinh(y) elif y <= 5.9e-5: tmp = (math.sin(x) / x) * y else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (y <= -500000000000.0) tmp = sinh(y); elseif (y <= 5.9e-5) 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 (y <= -500000000000.0) tmp = sinh(y); elseif (y <= 5.9e-5) tmp = (sin(x) / x) * y; else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -500000000000.0], N[Sinh[y], $MachinePrecision], If[LessEqual[y, 5.9e-5], N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision], N[Sinh[y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -500000000000:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;y \leq 5.9 \cdot 10^{-5}:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if y < -5e11 or 5.8999999999999998e-5 < y Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 75.9%
if -5e11 < y < 5.8999999999999998e-5Initial program 78.8%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in y around 0 77.0%
associate-/l*98.1%
Simplified98.1%
clear-num96.9%
associate-/r/98.1%
clear-num98.1%
Applied egg-rr98.1%
Final simplification86.6%
(FPCore (x y)
:precision binary64
(if (<= y -500000000000.0)
(sinh y)
(if (<= y 2.9e-8)
(/ y (* x (+ (* x 0.16666666666666666) (/ 1.0 x))))
(sinh y))))
double code(double x, double y) {
double tmp;
if (y <= -500000000000.0) {
tmp = sinh(y);
} else if (y <= 2.9e-8) {
tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / 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 (y <= (-500000000000.0d0)) then
tmp = sinh(y)
else if (y <= 2.9d-8) then
tmp = y / (x * ((x * 0.16666666666666666d0) + (1.0d0 / x)))
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -500000000000.0) {
tmp = Math.sinh(y);
} else if (y <= 2.9e-8) {
tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x)));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -500000000000.0: tmp = math.sinh(y) elif y <= 2.9e-8: tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x))) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (y <= -500000000000.0) tmp = sinh(y); elseif (y <= 2.9e-8) tmp = Float64(y / Float64(x * Float64(Float64(x * 0.16666666666666666) + Float64(1.0 / x)))); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -500000000000.0) tmp = sinh(y); elseif (y <= 2.9e-8) tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x))); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -500000000000.0], N[Sinh[y], $MachinePrecision], If[LessEqual[y, 2.9e-8], N[(y / N[(x * N[(N[(x * 0.16666666666666666), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -500000000000:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{-8}:\\
\;\;\;\;\frac{y}{x \cdot \left(x \cdot 0.16666666666666666 + \frac{1}{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if y < -5e11 or 2.9000000000000002e-8 < y Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 75.9%
if -5e11 < y < 2.9000000000000002e-8Initial program 78.8%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in y around 0 77.0%
associate-/l*98.1%
Simplified98.1%
clear-num98.1%
associate-/r/98.0%
Applied egg-rr98.0%
Taylor expanded in x around 0 76.8%
Final simplification76.4%
(FPCore (x y) :precision binary64 (if (<= y 7.3e+165) (* x (/ 1.0 (/ x y))) (sqrt (* y y))))
double code(double x, double y) {
double tmp;
if (y <= 7.3e+165) {
tmp = x * (1.0 / (x / y));
} else {
tmp = sqrt((y * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 7.3d+165) then
tmp = x * (1.0d0 / (x / y))
else
tmp = sqrt((y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 7.3e+165) {
tmp = x * (1.0 / (x / y));
} else {
tmp = Math.sqrt((y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 7.3e+165: tmp = x * (1.0 / (x / y)) else: tmp = math.sqrt((y * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 7.3e+165) tmp = Float64(x * Float64(1.0 / Float64(x / y))); else tmp = sqrt(Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 7.3e+165) tmp = x * (1.0 / (x / y)); else tmp = sqrt((y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 7.3e+165], N[(x * N[(1.0 / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(y * y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.3 \cdot 10^{+165}:\\
\;\;\;\;x \cdot \frac{1}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{y \cdot y}\\
\end{array}
\end{array}
if y < 7.3000000000000003e165Initial program 88.4%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 43.9%
Taylor expanded in x around 0 22.4%
div-inv22.3%
*-commutative22.3%
associate-*l*48.4%
Applied egg-rr48.4%
div-inv48.5%
clear-num50.3%
Applied egg-rr50.3%
if 7.3000000000000003e165 < y Initial program 100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in y around 0 5.8%
Taylor expanded in x around 0 27.0%
div-inv27.0%
associate-*l*5.9%
div-inv5.9%
*-inverses5.9%
*-commutative5.9%
*-un-lft-identity5.9%
add-sqr-sqrt5.9%
sqrt-unprod80.6%
Applied egg-rr80.6%
Final simplification54.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 89.8%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 39.3%
Taylor expanded in x around 0 22.9%
div-inv22.9%
*-commutative22.9%
associate-*l*47.5%
Applied egg-rr47.5%
div-inv47.6%
clear-num49.2%
Applied egg-rr49.2%
Final simplification49.2%
(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 89.8%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 39.3%
Taylor expanded in x around 0 22.9%
associate-/l*25.8%
associate-/r/47.6%
Applied egg-rr47.6%
Final simplification47.6%
(FPCore (x y) :precision binary64 (/ x (/ x y)))
double code(double x, double y) {
return x / (x / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / (x / y)
end function
public static double code(double x, double y) {
return x / (x / y);
}
def code(x, y): return x / (x / y)
function code(x, y) return Float64(x / Float64(x / y)) end
function tmp = code(x, y) tmp = x / (x / y); end
code[x_, y_] := N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{x}{y}}
\end{array}
Initial program 89.8%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 39.3%
Taylor expanded in x around 0 22.9%
associate-/l*25.8%
associate-/r/47.6%
Applied egg-rr47.6%
clear-num49.2%
associate-*l/48.9%
*-un-lft-identity48.9%
Applied egg-rr48.9%
Final simplification48.9%
(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 89.8%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 39.3%
associate-/l*49.4%
associate-/r/59.9%
Simplified59.9%
Taylor expanded in x around 0 25.8%
Final simplification25.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 2023196
(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))