Question: At the end of the post, how do we simplify all cases of Q3[r,1,2] and combine them into one expression?
I provided working examples at the end of this post.
Preliminaries: Suppose, we have the following code (i.e., f[r] and g[r] can be any function, where f[r+c]<V[r]<g[r+d] or g[r+d]<V[r]<f[r+c] and c, d are small constants; e.g., between $-10$ and $10$.)
Clear["Global`*"]
V[r_]:=V[r]=r!+1
f[r]:=f[r]=
g[r_]:=g[r]=
LengthS[r_] := LengthS[r] = {f[r],g[r]}
LengthS1[r_, x_] := LengthS1[r, x] = LengthS[r][[x]]
LengthS2[j_, y_] := LengthS2[j, y] = LengthS[j][[y]]
We approximate the constants, in the code below, using this equation:
If $F:\mathbb{N}\to\mathbb{R}$ and $G:\mathbb{N}\to\mathbb{R}$ are arbitrary functions, we want to calculate this equation with Mathematica:
$$\small{\begin{equation} c=\inf\left\{|1-\mathbf{c_1}|:\forall(\epsilon>0)\exists(\mathbf{c_1}>0)\forall(r\in\mathbb{N})\exists(v\in\mathbb{N})\left(\left|\frac{F(r)}{G(v)}-\mathbf{c_1}\right|<\varepsilon\right)\right\} \tag{1}\label{eq:1} \end{equation}}$$
cV1[r_, 1, 2] := cV1[r, 1, 2] = N[Min[Table[
RealAbs[1 - V[r]/LengthS1[v, x]], {v, 1, 30000}]]]
cV1[r_, 2, 1 ] := cV1[r, 2, 1] = N[Min[Table[
RealAbs[1 - LengthS1[r, x]]/V[v], {v, 1, 30000}]]]
cV2[r_, 1, 2] := cV2[r, 1, 2] = N[Min[Table[
RealAbs[1 - V[r]/LengthS2[v, y]], {v, 1, 30000}]]]
cV2[r_, 2, 1] := cV2[r, 2, 1] = N[Min[Table[
RealAbs[1 - LengthS2[r, y]/V[v]], {v, 1, 30000}]]]
c[r_, 1, 2] := c[r, 1, 2] = N[Min[Table[
RealAbs[1 - LengthS1[r, x]/LengthS2[v, y]], {v, 1, 30000}]]]
c[r_, 2, 1] := c[r, 2, 1] = N[Min[Table[
RealAbs[1 - LengthS2[r, y]/LengthS1[v, x]], {v, 1, 30000}]]]
In case the outputs are incorrect, use Equation \eqref{eq:1} to solve the exact value.
In addition, w.r.t. the inequality f[r+c]<V[r]<g[r+d], we adjust r+c and r+d into r+c1 and r+d1, using P1 in the code below (i.e., c1==c+1||c1==c||c1==c-1 and d1==d+1||d1==d||d1==d-1). If this makes no sense, then attempt to analyze the code.
P1 = 3 (*P1 can be any constant positive integer*)
Min11[r_, x_] :=
Min11[r, x] =
Max[r1 /.
FindInstance[LengthS1[r1, x] <= V[r] < LengthS1[r1 + 1, x], {r1},
PositiveIntegers]]
Min12[r_, x_] :=
Min12[r, x] =
ArgMin[{RealAbs[LengthS1[r2, x] - V[r]], r - P1 <= r2 <= r + P1},
r2, PositiveIntegers]
Min21[r_, y_] :=
Min21[r, y] =
Max[r3 /.
FindInstance[LengthS2[r3, y] <= V[r] < LengthS2[r3 + 1, y], {r3},
PositiveIntegers]]
Min22[r_, y_] :=
Min22[r, y] =
ArgMin[{RealAbs[LengthS1[r4, y] - V[r]], r - P1 <= r4 <= r + P1},
r4, PositiveIntegers]
rMin1[r_, x_] :=
rMin1[r, x] =
Min12[r, x] + Sign[Floor[RealAbs[2 r - Min11[r, x] - Min12[r, x]]/2]]
rMin2[r_, y_] :=
rMin2[r, y] =
Min22[r, y] + Sign[Floor[RealAbs[2 r - Min21[r, y] - Min22[r, y]]/2]]
Putting it together, this is what I want:
For any LengthS1[r,x]=f[r+c1] and LengthS2[r,y]==g[r+d1] such that for any function f and g, where f[r+c1]<V[r]<g[r+d1] or g[r+d1]<V[r]<f[r+c1], consider the following case (we use this case to simplify the other cases):
- Case 3:
V[r] >= LengthS1[rMin1[r, x], x] && LengthS1[rMin1[r, x], x] > LengthS2[rMin2[r, y], y] and extra criteria including cV1, cV2 and c (see Equation \ref{eq:1})
To define Q3, we use Case 3 and define the following:
Sign3[r_, x_, y_] :=
Sign3[r, x,
y] = (Sign[
Sign[cV2[r, x, y] c[r, x, y]] + Sign[cV2[r, x, y] cV2[r, y, x]] +
Sign[1 - cV2[r, y, x] c[r, y, x]]])
Sign3S[r_, x_, y_] :=
Sign3S[r, x, y] =
Sign[c[r, x, y] - cV2[r, y, x]] Sign[
cV1[r, y, x] - cV2[r, y, x]] Sign[cV1[r, x, y] - c[r, y, x]]
Sign3SS[r_, x_, y_] :=
Sign3SS[r, x, y] = Sign[1 + Sign[c[r, y, x] - c[r, x, y]]]
where Q3[r,x,y] is one out of the 16 criteria of the original code (i.e., I'm applying this example to simplify the other cases):
Q3[r_, x_, y_] :=
Q3[r, x, y] =
Sign3[r, x, y] Sign3S[r, x, y] cV2[r, x, y] >=
Sign3SS[r, x, y] c[r, x, y] &&
Sign3SS[r, x, y] c[r, x, y] >=
Sign3[r, x, y] Sign3SS[r, x, y] c[r, y, x] &&
V[r] >= LengthS1[rMin1[r, x], x] &&
LengthS1[rMin1[r, x], x] > LengthS2[rMin2[r, y], y]
Question (Reasked): How do we simplify Q3[r,1,2] in terms of the equations in the previous code?
Here are some examples:
LengthS[r_]:=LengthS[r]={5r!/7, 3r!/11} (it should return {Q3[r,1,2]}=={True})
LengthS[r_]:=LengthS[r]={4r!/5, 2r!/3} (it should return {Q3[r,1,2]}=={True})
LengthS[r_]:=LengthS[r]={r!, (3/(Pi^2))r^2} (it should return {Q3[r,1,2]}=={True})
LengthS[r_]:=LengthS[r]={2^r, (3/(Pi^2))r^2} (it should return {Q3[r,1,2]}=={True})
LengthS[r_]:=LengthS[r]={2^r, (2^r)/3} (it should return {Q3[r,1,2]}=={True})
We wish to simplify examples 1.-6. and every other case satisfying Case 3, then combine them into one expression written in terms of the equations in the previous codes.
Attempt:
For all Cases satisfying Case 3 (e.g., examples 1-6), we want to simplify Q3[r,1,2] into one expression.
FullSimplify[Q3[r, 1, 2], Element[r, PositiveIntegers]]
However, with all the examples (e.g., example 6), I get the following error message:
FindInstance::exvar: The system contains a nonconstant expression r! independent of variables {r1}.
ReplaceAll::reps: {FindInstance[2^r1<=1+r!<2^(1+r1),{r1},Subscript[\[DoubleStruckCapitalZ], >\[ThinSpace]0]]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.
FindInstance::exvar: The system contains a nonconstant expression r! independent of variables {r3}.
ReplaceAll::reps: {FindInstance[2^r3/3<=1+r!<2^(1+r3)/3,{r3},Subscript[\[DoubleStruckCapitalZ], >\[ThinSpace]0]]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.
Sub-Question: How do we fix the attempt to answer the question?