
(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 87.3%
associate-*l/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) (- INFINITY)) (* (sinh y) (+ 1.0 (* (* x x) -0.16666666666666666))) (if (<= (sinh y) 2e-19) (* (/ (sin x) x) y) (sinh y))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= -((double) INFINITY)) {
tmp = sinh(y) * (1.0 + ((x * x) * -0.16666666666666666));
} else if (sinh(y) <= 2e-19) {
tmp = (sin(x) / x) * y;
} else {
tmp = sinh(y);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= -Double.POSITIVE_INFINITY) {
tmp = Math.sinh(y) * (1.0 + ((x * x) * -0.16666666666666666));
} else if (Math.sinh(y) <= 2e-19) {
tmp = (Math.sin(x) / x) * y;
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= -math.inf: tmp = math.sinh(y) * (1.0 + ((x * x) * -0.16666666666666666)) elif math.sinh(y) <= 2e-19: tmp = (math.sin(x) / x) * y else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= Float64(-Inf)) tmp = Float64(sinh(y) * Float64(1.0 + Float64(Float64(x * x) * -0.16666666666666666))); elseif (sinh(y) <= 2e-19) 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) <= -Inf) tmp = sinh(y) * (1.0 + ((x * x) * -0.16666666666666666)); elseif (sinh(y) <= 2e-19) tmp = (sin(x) / x) * y; else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], (-Infinity)], N[(N[Sinh[y], $MachinePrecision] * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sinh[y], $MachinePrecision], 2e-19], 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 -\infty:\\
\;\;\;\;\sinh y \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right)\\
\mathbf{elif}\;\sinh y \leq 2 \cdot 10^{-19}:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < -inf.0Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 79.4%
*-commutative79.4%
unpow279.4%
Simplified79.4%
if -inf.0 < (sinh.f64 y) < 2e-19Initial program 72.8%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 99.9%
if 2e-19 < (sinh.f64 y) Initial program 100.0%
associate-*r/98.7%
Simplified98.7%
Taylor expanded in x around 0 85.0%
add-log-exp83.9%
*-un-lft-identity83.9%
log-prod83.9%
metadata-eval83.9%
add-log-exp85.0%
Applied egg-rr85.0%
+-lft-identity85.0%
associate-*r/86.3%
associate-*l/86.3%
*-inverses86.3%
*-lft-identity86.3%
Simplified86.3%
Final simplification90.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) -3e-33) (sinh y) (if (<= (sinh y) 1e-74) (/ x (/ x y)) (sinh y))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= -3e-33) {
tmp = sinh(y);
} else if (sinh(y) <= 1e-74) {
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) <= (-3d-33)) then
tmp = sinh(y)
else if (sinh(y) <= 1d-74) 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) <= -3e-33) {
tmp = Math.sinh(y);
} else if (Math.sinh(y) <= 1e-74) {
tmp = x / (x / y);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= -3e-33: tmp = math.sinh(y) elif math.sinh(y) <= 1e-74: tmp = x / (x / y) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= -3e-33) tmp = sinh(y); elseif (sinh(y) <= 1e-74) 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) <= -3e-33) tmp = sinh(y); elseif (sinh(y) <= 1e-74) tmp = x / (x / y); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], -3e-33], N[Sinh[y], $MachinePrecision], If[LessEqual[N[Sinh[y], $MachinePrecision], 1e-74], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -3 \cdot 10^{-33}:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;\sinh y \leq 10^{-74}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < -3.0000000000000002e-33 or 9.99999999999999958e-75 < (sinh.f64 y) Initial program 100.0%
associate-*r/99.3%
Simplified99.3%
Taylor expanded in x around 0 75.9%
add-log-exp73.8%
*-un-lft-identity73.8%
log-prod73.8%
metadata-eval73.8%
add-log-exp75.9%
Applied egg-rr75.9%
+-lft-identity75.9%
associate-*r/76.6%
associate-*l/76.6%
*-inverses76.6%
*-lft-identity76.6%
Simplified76.6%
if -3.0000000000000002e-33 < (sinh.f64 y) < 9.99999999999999958e-75Initial program 69.9%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in y around 0 69.9%
*-commutative69.9%
associate-/l*98.4%
Simplified98.4%
Taylor expanded in x around 0 78.4%
Final simplification77.4%
(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.3%
associate-*r/99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x y) :precision binary64 (if (<= y -1040000000000.0) (sinh y) (if (<= y 1.6e-11) (* (sin x) (/ y x)) (sinh y))))
double code(double x, double y) {
double tmp;
if (y <= -1040000000000.0) {
tmp = sinh(y);
} else if (y <= 1.6e-11) {
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 <= (-1040000000000.0d0)) then
tmp = sinh(y)
else if (y <= 1.6d-11) 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 <= -1040000000000.0) {
tmp = Math.sinh(y);
} else if (y <= 1.6e-11) {
tmp = Math.sin(x) * (y / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1040000000000.0: tmp = math.sinh(y) elif y <= 1.6e-11: tmp = math.sin(x) * (y / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (y <= -1040000000000.0) tmp = sinh(y); elseif (y <= 1.6e-11) 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 <= -1040000000000.0) tmp = sinh(y); elseif (y <= 1.6e-11) tmp = sin(x) * (y / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1040000000000.0], N[Sinh[y], $MachinePrecision], If[LessEqual[y, 1.6e-11], N[(N[Sin[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1040000000000:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{-11}:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if y < -1.04e12 or 1.59999999999999997e-11 < y Initial program 100.0%
associate-*r/99.3%
Simplified99.3%
Taylor expanded in x around 0 80.8%
add-log-exp80.2%
*-un-lft-identity80.2%
log-prod80.2%
metadata-eval80.2%
add-log-exp80.8%
Applied egg-rr80.8%
+-lft-identity80.8%
associate-*r/81.5%
associate-*l/81.5%
*-inverses81.5%
*-lft-identity81.5%
Simplified81.5%
if -1.04e12 < y < 1.59999999999999997e-11Initial program 73.1%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in y around 0 99.0%
Final simplification89.8%
(FPCore (x y) :precision binary64 (if (<= y -1040000000000.0) (sinh y) (if (<= y 1.6e-11) (* (/ (sin x) x) y) (sinh y))))
double code(double x, double y) {
double tmp;
if (y <= -1040000000000.0) {
tmp = sinh(y);
} else if (y <= 1.6e-11) {
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 <= (-1040000000000.0d0)) then
tmp = sinh(y)
else if (y <= 1.6d-11) 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 <= -1040000000000.0) {
tmp = Math.sinh(y);
} else if (y <= 1.6e-11) {
tmp = (Math.sin(x) / x) * y;
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1040000000000.0: tmp = math.sinh(y) elif y <= 1.6e-11: tmp = (math.sin(x) / x) * y else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (y <= -1040000000000.0) tmp = sinh(y); elseif (y <= 1.6e-11) 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 <= -1040000000000.0) tmp = sinh(y); elseif (y <= 1.6e-11) tmp = (sin(x) / x) * y; else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1040000000000.0], N[Sinh[y], $MachinePrecision], If[LessEqual[y, 1.6e-11], N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision], N[Sinh[y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1040000000000:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{-11}:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if y < -1.04e12 or 1.59999999999999997e-11 < y Initial program 100.0%
associate-*r/99.3%
Simplified99.3%
Taylor expanded in x around 0 80.8%
add-log-exp80.2%
*-un-lft-identity80.2%
log-prod80.2%
metadata-eval80.2%
add-log-exp80.8%
Applied egg-rr80.8%
+-lft-identity80.8%
associate-*r/81.5%
associate-*l/81.5%
*-inverses81.5%
*-lft-identity81.5%
Simplified81.5%
if -1.04e12 < y < 1.59999999999999997e-11Initial program 73.1%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 99.0%
Final simplification89.8%
(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 87.3%
associate-*r/99.5%
Simplified99.5%
Taylor expanded in x around 0 76.1%
Final simplification76.1%
(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(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 87.3%
associate-*r/99.5%
Simplified99.5%
Taylor expanded in y around 0 37.3%
*-commutative37.3%
associate-/l*60.3%
Simplified60.3%
Taylor expanded in x around 0 48.4%
frac-2neg48.4%
div-inv50.9%
distribute-neg-frac50.9%
Applied egg-rr50.9%
Final simplification50.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 87.3%
associate-*r/99.5%
Simplified99.5%
Taylor expanded in x around 0 76.1%
Taylor expanded in y around 0 50.2%
Final simplification50.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 87.3%
associate-*r/99.5%
Simplified99.5%
Taylor expanded in x around 0 76.1%
Taylor expanded in y around 0 29.0%
Final simplification29.0%
(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 2023224
(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))