0
$\begingroup$

(Don't consider the context of this problem. Help with what you know and focus on the coding.)

Consider the following:

If $S=\left\{\frac{m}{2n+1}:m,n\in\mathbb{Z}\right\}$, $g:[0,1]\to[0,1]$, and $\lambda$ is the Lebesgue Measure, then I wish to find

$$g(\psi)=\small{\lim\limits_{\left(\epsilon,\omega\right)\to\left(0,\infty\right)}\frac{\left|S\cap\left(\left\{\frac{\left\lfloor s_{1}\left(\epsilon\pm\psi\right) \right\rfloor}{s_{1}}:s_{1}\in\mathbb{Z},s_{1}\neq 0,|s_1|\le\omega\right\}\cup\left\{\frac{ s_{2} }{\left\lfloor s_{2}/\left(\epsilon\pm\psi\right)\right\rfloor}:s_{2}\in\mathbb{Z},s_{2}\neq 0,\left|s_2\right|\le\omega\right\}\right)\right|}{\left|\left\{\frac{\left\lfloor s_{1}\left(\epsilon\pm\psi\right) \right\rfloor}{s_{1}}:s_{1}\in\mathbb{Z},s_{1}\neq 0,|s_1|\le\omega\right\}\cup\left\{\frac{ s_{2} }{\left\lfloor s_{2}/\left(\epsilon\pm\psi\right)\right\rfloor}:s_{2}\in\mathbb{Z},s_{2}\neq 0,\left|s_2\right|\le\omega\right\}\right|}}$$

And

$$\lim\limits_{u\to\infty}\sum_{c=1}^{u}\lambda\left(\left\{\psi:g(\psi)=\left[\frac{c-1}{u},\frac{c}{u}\right]\right\}\right)$$

The code I used is:

\[Psi] = Sqrt[2] - 1.3
r = 1000
\[Omega][r_] := DeleteCases[Table[x, {x, -r, r}], 0];
A1 = Table[Floor[\[Psi] s1]/s1, {s1, {\[Omega][r]}}];
A2 = Table[s2/Floor[s2/\[Psi]], {s2, {\[Omega][r]}}];
A = DeleteDuplicates[Flatten[Union[A1, A2]]];
NS = Table[t, {t, -20 r + 1, 20 r + 1}]; (* Numerator of a simplified S or m/(2n+1) *)
DS = Table[2 t + 1, {t, -10 r, 10 r}];  (* Denominator of a simplified S or m/(2n+1) *)
g = N[Length[Intersection[Denominator[A], NS, Numerator[A], DS]]/Length[A]] 
(* Gives the fastest computation time of intersection of S and A *)

Where for \[psi]=Sqrt[2] - 1.3, g gives 0.208533

I then converted g into function g[\[Psi],r]. (Note g[\[Psi],r] is similar to $g(\psi)$ when r is large).

Unprotect[\[Omega], A1, A2, A, NS, DS, g];
Remove[\[Omega], A1, A2, A, NS, DS, g];
\[Omega][r_] := DeleteCases[Table[x, {x, -r, r}], 0]; (* We replace Omega with R 
to delete 0 from s1 and s2 *)
A1[\[Psi]_, r_] := Table[Floor[\[Psi] s1]/s1, {s1, {\[Omega][r]}}];
A2[\[Psi]_, r_] := Table[s2/Floor[s2/\[Psi]], {s2, {\[Omega][r]}}];
A[\[Psi]_, r_] := 
  DeleteDuplicates[Flatten[Union[A1[\[Psi], r], A2[\[Psi], r]]]];
NS[r_] := 
 Table[t, {t, -20 r + 1, 20 r + 1}]; (* Numerator of a simplified S or m/(2n+1) *)
DS[r_] := Table[2 t + 1, {t, -10 r, 10 r}];  (* Denominator of a simplified S or m/(2n+1) *)
g[\[Psi]_, r_] := 
 N[Length[Intersection[Denominator[A[\[Psi], r]], NS[r], 
Numerator[A[\[Psi], r]], DS[r]]]/Length[A[\[Psi], r]]] 
(* Gives the fastest computation time of intersection of S and A *)

Unfortunately, the computation time of g[\[Psi]_,r_] is slow and I'm unable to define $\lambda$ (the Lebesgue Measure) using Wolfram Mathematica.

Is there a way to approximate the following for large $u$

$$\lim_{u\to\infty}\sum_{c=1}^{u}\lambda\left(\left\{\psi:g(\psi)=\left[\frac{c-1}{u},\frac{c}{u}\right]\right\}\right)$$

Here is an image of $g$:

Plot[g[x, 10000], {x, 0.0001, 1}]

Picture of g

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.