
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= y 0.3)
(sin x)
(if (<= y 3.3e+154)
(* x (/ (sinh y) y))
(* (sin x) (* y (* y 0.16666666666666666))))))
double code(double x, double y) {
double tmp;
if (y <= 0.3) {
tmp = sin(x);
} else if (y <= 3.3e+154) {
tmp = x * (sinh(y) / y);
} else {
tmp = sin(x) * (y * (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 (y <= 0.3d0) then
tmp = sin(x)
else if (y <= 3.3d+154) then
tmp = x * (sinh(y) / y)
else
tmp = sin(x) * (y * (y * 0.16666666666666666d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 0.3) {
tmp = Math.sin(x);
} else if (y <= 3.3e+154) {
tmp = x * (Math.sinh(y) / y);
} else {
tmp = Math.sin(x) * (y * (y * 0.16666666666666666));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.3: tmp = math.sin(x) elif y <= 3.3e+154: tmp = x * (math.sinh(y) / y) else: tmp = math.sin(x) * (y * (y * 0.16666666666666666)) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.3) tmp = sin(x); elseif (y <= 3.3e+154) tmp = Float64(x * Float64(sinh(y) / y)); else tmp = Float64(sin(x) * Float64(y * Float64(y * 0.16666666666666666))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.3) tmp = sin(x); elseif (y <= 3.3e+154) tmp = x * (sinh(y) / y); else tmp = sin(x) * (y * (y * 0.16666666666666666)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.3], N[Sin[x], $MachinePrecision], If[LessEqual[y, 3.3e+154], N[(x * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * N[(y * N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.3:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{+154}:\\
\;\;\;\;x \cdot \frac{\sinh y}{y}\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(y \cdot \left(y \cdot 0.16666666666666666\right)\right)\\
\end{array}
\end{array}
if y < 0.299999999999999989Initial program 100.0%
Taylor expanded in y around 0 67.9%
if 0.299999999999999989 < y < 3.3e154Initial program 100.0%
*-commutative100.0%
associate-/r/90.6%
Applied egg-rr90.6%
Taylor expanded in x around 0 56.3%
associate-/r/65.6%
Applied egg-rr65.6%
if 3.3e154 < y Initial program 100.0%
*-commutative100.0%
associate-/r/71.9%
Applied egg-rr71.9%
Taylor expanded in y around 0 100.0%
associate-*r*100.0%
distribute-rgt1-in100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
associate-*r*100.0%
unpow2100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification71.6%
(FPCore (x y)
:precision binary64
(if (<= y 0.31)
(* (sin x) (+ (* 0.16666666666666666 (* y y)) 1.0))
(if (<= y 3.3e+154)
(* x (/ (sinh y) y))
(* (sin x) (* y (* y 0.16666666666666666))))))
double code(double x, double y) {
double tmp;
if (y <= 0.31) {
tmp = sin(x) * ((0.16666666666666666 * (y * y)) + 1.0);
} else if (y <= 3.3e+154) {
tmp = x * (sinh(y) / y);
} else {
tmp = sin(x) * (y * (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 (y <= 0.31d0) then
tmp = sin(x) * ((0.16666666666666666d0 * (y * y)) + 1.0d0)
else if (y <= 3.3d+154) then
tmp = x * (sinh(y) / y)
else
tmp = sin(x) * (y * (y * 0.16666666666666666d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 0.31) {
tmp = Math.sin(x) * ((0.16666666666666666 * (y * y)) + 1.0);
} else if (y <= 3.3e+154) {
tmp = x * (Math.sinh(y) / y);
} else {
tmp = Math.sin(x) * (y * (y * 0.16666666666666666));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.31: tmp = math.sin(x) * ((0.16666666666666666 * (y * y)) + 1.0) elif y <= 3.3e+154: tmp = x * (math.sinh(y) / y) else: tmp = math.sin(x) * (y * (y * 0.16666666666666666)) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.31) tmp = Float64(sin(x) * Float64(Float64(0.16666666666666666 * Float64(y * y)) + 1.0)); elseif (y <= 3.3e+154) tmp = Float64(x * Float64(sinh(y) / y)); else tmp = Float64(sin(x) * Float64(y * Float64(y * 0.16666666666666666))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.31) tmp = sin(x) * ((0.16666666666666666 * (y * y)) + 1.0); elseif (y <= 3.3e+154) tmp = x * (sinh(y) / y); else tmp = sin(x) * (y * (y * 0.16666666666666666)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.31], N[(N[Sin[x], $MachinePrecision] * N[(N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.3e+154], N[(x * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * N[(y * N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.31:\\
\;\;\;\;\sin x \cdot \left(0.16666666666666666 \cdot \left(y \cdot y\right) + 1\right)\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{+154}:\\
\;\;\;\;x \cdot \frac{\sinh y}{y}\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(y \cdot \left(y \cdot 0.16666666666666666\right)\right)\\
\end{array}
\end{array}
if y < 0.309999999999999998Initial program 100.0%
*-commutative100.0%
associate-/r/91.5%
Applied egg-rr91.5%
Taylor expanded in y around 0 86.0%
associate-*r*86.0%
distribute-rgt1-in86.0%
unpow286.0%
Simplified86.0%
if 0.309999999999999998 < y < 3.3e154Initial program 100.0%
*-commutative100.0%
associate-/r/90.6%
Applied egg-rr90.6%
Taylor expanded in x around 0 56.3%
associate-/r/65.6%
Applied egg-rr65.6%
if 3.3e154 < y Initial program 100.0%
*-commutative100.0%
associate-/r/71.9%
Applied egg-rr71.9%
Taylor expanded in y around 0 100.0%
associate-*r*100.0%
distribute-rgt1-in100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
associate-*r*100.0%
unpow2100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification85.2%
(FPCore (x y) :precision binary64 (if (<= y 0.3) (sin x) (* x (/ (sinh y) y))))
double code(double x, double y) {
double tmp;
if (y <= 0.3) {
tmp = sin(x);
} else {
tmp = x * (sinh(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 <= 0.3d0) then
tmp = sin(x)
else
tmp = x * (sinh(y) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 0.3) {
tmp = Math.sin(x);
} else {
tmp = x * (Math.sinh(y) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.3: tmp = math.sin(x) else: tmp = x * (math.sinh(y) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.3) tmp = sin(x); else tmp = Float64(x * Float64(sinh(y) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.3) tmp = sin(x); else tmp = x * (sinh(y) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.3], N[Sin[x], $MachinePrecision], N[(x * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.3:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\sinh y}{y}\\
\end{array}
\end{array}
if y < 0.299999999999999989Initial program 100.0%
Taylor expanded in y around 0 67.9%
if 0.299999999999999989 < y Initial program 100.0%
*-commutative100.0%
associate-/r/81.3%
Applied egg-rr81.3%
Taylor expanded in x around 0 48.4%
associate-/r/67.2%
Applied egg-rr67.2%
Final simplification67.7%
(FPCore (x y) :precision binary64 (if (<= y 8.8e+67) (sin x) (+ x (* 0.16666666666666666 (* x (* y y))))))
double code(double x, double y) {
double tmp;
if (y <= 8.8e+67) {
tmp = sin(x);
} else {
tmp = x + (0.16666666666666666 * (x * (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 <= 8.8d+67) then
tmp = sin(x)
else
tmp = x + (0.16666666666666666d0 * (x * (y * y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 8.8e+67) {
tmp = Math.sin(x);
} else {
tmp = x + (0.16666666666666666 * (x * (y * y)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 8.8e+67: tmp = math.sin(x) else: tmp = x + (0.16666666666666666 * (x * (y * y))) return tmp
function code(x, y) tmp = 0.0 if (y <= 8.8e+67) tmp = sin(x); else tmp = Float64(x + Float64(0.16666666666666666 * Float64(x * Float64(y * y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 8.8e+67) tmp = sin(x); else tmp = x + (0.16666666666666666 * (x * (y * y))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 8.8e+67], N[Sin[x], $MachinePrecision], N[(x + N[(0.16666666666666666 * N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.8 \cdot 10^{+67}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x + 0.16666666666666666 \cdot \left(x \cdot \left(y \cdot y\right)\right)\\
\end{array}
\end{array}
if y < 8.8e67Initial program 100.0%
Taylor expanded in y around 0 64.4%
if 8.8e67 < y Initial program 100.0%
*-commutative100.0%
associate-/r/77.4%
Applied egg-rr77.4%
Taylor expanded in x around 0 47.2%
associate-/r/69.8%
Applied egg-rr69.8%
Taylor expanded in y around 0 53.6%
unpow253.6%
Simplified53.6%
Final simplification62.2%
(FPCore (x y) :precision binary64 (if (<= y 0.2) x (* 0.16666666666666666 (* x (* y y)))))
double code(double x, double y) {
double tmp;
if (y <= 0.2) {
tmp = x;
} else {
tmp = 0.16666666666666666 * (x * (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 <= 0.2d0) then
tmp = x
else
tmp = 0.16666666666666666d0 * (x * (y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 0.2) {
tmp = x;
} else {
tmp = 0.16666666666666666 * (x * (y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.2: tmp = x else: tmp = 0.16666666666666666 * (x * (y * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.2) tmp = x; else tmp = Float64(0.16666666666666666 * Float64(x * Float64(y * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.2) tmp = x; else tmp = 0.16666666666666666 * (x * (y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.2], x, N[(0.16666666666666666 * N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.2:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(x \cdot \left(y \cdot y\right)\right)\\
\end{array}
\end{array}
if y < 0.20000000000000001Initial program 100.0%
*-commutative100.0%
associate-/r/91.5%
Applied egg-rr91.5%
Taylor expanded in x around 0 50.9%
Taylor expanded in y around 0 35.2%
if 0.20000000000000001 < y Initial program 100.0%
*-commutative100.0%
associate-/r/81.5%
Applied egg-rr81.5%
Taylor expanded in y around 0 52.4%
associate-*r*52.4%
distribute-rgt1-in52.4%
unpow252.4%
Simplified52.4%
Taylor expanded in y around inf 52.0%
associate-*r*52.0%
unpow252.0%
*-commutative52.0%
associate-*r*52.0%
*-commutative52.0%
Simplified52.0%
Taylor expanded in x around 0 44.2%
unpow244.2%
Simplified44.2%
Final simplification37.5%
(FPCore (x y) :precision binary64 (+ x (* 0.16666666666666666 (* x (* y y)))))
double code(double x, double y) {
return x + (0.16666666666666666 * (x * (y * y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (0.16666666666666666d0 * (x * (y * y)))
end function
public static double code(double x, double y) {
return x + (0.16666666666666666 * (x * (y * y)));
}
def code(x, y): return x + (0.16666666666666666 * (x * (y * y)))
function code(x, y) return Float64(x + Float64(0.16666666666666666 * Float64(x * Float64(y * y)))) end
function tmp = code(x, y) tmp = x + (0.16666666666666666 * (x * (y * y))); end
code[x_, y_] := N[(x + N[(0.16666666666666666 * N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + 0.16666666666666666 \cdot \left(x \cdot \left(y \cdot y\right)\right)
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-/r/89.0%
Applied egg-rr89.0%
Taylor expanded in x around 0 50.1%
associate-/r/61.1%
Applied egg-rr61.1%
Taylor expanded in y around 0 48.1%
unpow248.1%
Simplified48.1%
Final simplification48.1%
(FPCore (x y) :precision binary64 -8.0)
double code(double x, double y) {
return -8.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -8.0d0
end function
public static double code(double x, double y) {
return -8.0;
}
def code(x, y): return -8.0
function code(x, y) return -8.0 end
function tmp = code(x, y) tmp = -8.0; end
code[x_, y_] := -8.0
\begin{array}{l}
\\
-8
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-/r/89.0%
Applied egg-rr89.0%
Applied egg-rr4.1%
Final simplification4.1%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-/r/89.0%
Applied egg-rr89.0%
Applied egg-rr4.7%
Final simplification4.7%
(FPCore (x y) :precision binary64 0.5)
double code(double x, double y) {
return 0.5;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.5d0
end function
public static double code(double x, double y) {
return 0.5;
}
def code(x, y): return 0.5
function code(x, y) return 0.5 end
function tmp = code(x, y) tmp = 0.5; end
code[x_, y_] := 0.5
\begin{array}{l}
\\
0.5
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-/r/89.0%
Applied egg-rr89.0%
Applied egg-rr4.8%
Final simplification4.8%
(FPCore (x y) :precision binary64 0.75)
double code(double x, double y) {
return 0.75;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.75d0
end function
public static double code(double x, double y) {
return 0.75;
}
def code(x, y): return 0.75
function code(x, y) return 0.75 end
function tmp = code(x, y) tmp = 0.75; end
code[x_, y_] := 0.75
\begin{array}{l}
\\
0.75
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-/r/89.0%
Applied egg-rr89.0%
Applied egg-rr5.0%
Final simplification5.0%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-/r/89.0%
Applied egg-rr89.0%
Applied egg-rr5.1%
Final simplification5.1%
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 100.0%
*-commutative100.0%
associate-/r/89.0%
Applied egg-rr89.0%
Taylor expanded in x around 0 50.1%
Taylor expanded in y around 0 26.9%
Final simplification26.9%
herbie shell --seed 2023297
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))