Skip to main content
Fixed code
Source Link
Arbuja
  • 121
  • 4
  • 18

(Edit 1: Below, I made changes to the code.)

(Edit 3: I made $1/2^{2+1}$ and $1/2^{2}$, $1/2^{1+1}$ and $1/2^{1}$. I apologize for my stupidity.)

A[2] = Reduce[a[1, 1] <= x <= (a[1, 1] + a[1, 2])/2 - 1/2 (1/2^(21 + 1)) (a[1, 2] - a[1, 1]) || 
       (a[1, 1] + a[1, 2])/2 + 1/2 (1/2^(21 + 1)) (a[1, 2] - a[1, 1]) <= x < a[1, 2] || 
       (b[1, 1] + b[1, 2])/2 - 1/2 (1/2^(21)) (b[1, 2] - b[1, 1]) <= x < (b[1, 1] + b[1, 2])/2+
       1/2 (1/2^(21)) (b[1, 2] - b[1, 1]), {x}] (*A2*)

B[2] = Reduce[b[1, 1] <= x <= (b[1, 1] + b[1, 2])/2 - 1/2 (1/2^(21)) (b[1, 2] - b[1, 1]) || 
       (b[1, 1] + b[1, 2])/2 + 1/2 (1/2^(21)) (b[1, 2] - b[1, 1]) <= x < b[1, 2] ||
       (a[1, 1] + a[1, 2])/2 - 1/2 (1/2^(21 + 1)) (a[1, 2] - a[1, 1]) <= x < (a[1, 1] + a[1, 2])/2 + 
     1/2 (1/2^(21 + 1)) (a[1, 2] - a[1, 1]), {x}] (*B2*)
a[x_, 1, i_] := A[x][[3^(i - 1)]][[1]] 
(*If i is a number in [1,3^(x-1)], then a[x,1,i] is the Lowerbound of the 3^(i-1)th interval of A_n*)
a[x_, 2, i_] := A[x][[3^(i - 1)]][[5]] 
(*If i is a number in [1,3^(x-1)], then a[x,1,i] is the Upperbound of the 3^(i-1)th interval of A_n*)
b[x_, 1, i_] := B[x][[3^(i - 1)]][[1]] 
(*If i is a number in [1,3^(x-1)], then b[x,1,i] is the Lowerbound of the 3^(i-1)th interval of B_n*)
b[x_, 2, i_] := B[x][[3^(i - 1)]][[5]] 
(*If i is a number in [1,3^(x-1)], then b[x,1,i] is the Upperbound of the 3^(i-1)th interval of B_n*)

A[s_, i_] := Reduce[a[s, 1, i] <= x <= (a[s, 1, i] + a[s, 2, i])/2 - 1/2 (1/2^(2 + 1s)) 
             (a[s, 2, i] - a[s, 1, i]) || (a[s, 1, i] + a[s, 2, i])/2 + 1/2 (1/2^(2 + 1s)) 
             (a[s, 2, i] - a[s, 1, i]) <=x < a[s, 2, i] || (b[s, 1, i] + b[s, 2, i])/2 - 
             1/2 (1/2^(2s-1)) (b[s, 2, i] - b[s, 1, i]) <= x < (b[s, 1, i] + b[s, 2, i])/2 
             + 1/2 (1/2^(2s-1)) (b[s, 2, i] - b[s, 1, i]), {x}] 
(*Changes the 3^(i-1)th interval of A_n using the description in above the attempt.*)

 B[s_, i_] := Reduce[b[s, 1, i] <= x <= (b[s, 1, i] + b[s, 2, i])/2 - 1/2 (1/2^(2s-1)) 
              (b[s, 2, i] - b[s, 1, i]) || (b[s, 1, i] + b[s, 2, i])/2 + 1/2 (1/2^(2s-1)) 
              (b[s, 2, i] - b[s, 1, i]) <= x <b[s, 2, i] || (a[s, 1, i] + a[s, 2, i])/2 - 
              1/2 (1/2^(2 + 1s)) (a[s, 2, i] - a[s, 1, i]) <= x < (a[s, 1, i] + a[s, 2, i])/2
              + 1/2 (1/2^(2 + 1s)) (a[s, 2, i] - a[s, 1, i]), {x}]
(*Changes 3^(i-1)th interval of A_n into three intervals using the description above the attempt.*)

(Edit 1: Below, I made changes to the code)

A[2] = Reduce[a[1, 1] <= x <= (a[1, 1] + a[1, 2])/2 - 1/2 (1/2^(2 + 1)) (a[1, 2] - a[1, 1]) || 
       (a[1, 1] + a[1, 2])/2 + 1/2 (1/2^(2 + 1)) (a[1, 2] - a[1, 1]) <= x < a[1, 2] || 
       (b[1, 1] + b[1, 2])/2 - 1/2 (1/2^(2)) (b[1, 2] - b[1, 1]) <= x < (b[1, 1] + b[1, 2])/2+
       1/2 (1/2^(2)) (b[1, 2] - b[1, 1]), {x}] (*A2*)

B[2] = Reduce[b[1, 1] <= x <= (b[1, 1] + b[1, 2])/2 - 1/2 (1/2^(2)) (b[1, 2] - b[1, 1]) || 
       (b[1, 1] + b[1, 2])/2 + 1/2 (1/2^(2)) (b[1, 2] - b[1, 1]) <= x < b[1, 2] ||
       (a[1, 1] + a[1, 2])/2 - 1/2 (1/2^(2 + 1)) (a[1, 2] - a[1, 1]) <= x < (a[1, 1] + a[1, 2])/2 + 
     1/2 (1/2^(2 + 1)) (a[1, 2] - a[1, 1]), {x}] (*B2*)
a[x_, 1, i_] := A[x][[3^(i - 1)]][[1]] 
(*If i is a number in [1,3^(x-1)], then a[x,1,i] is the Lowerbound of the 3^(i-1)th interval of A_n*)
a[x_, 2, i_] := A[x][[3^(i - 1)]][[5]] 
(*If i is a number in [1,3^(x-1)], then a[x,1,i] is the Upperbound of the 3^(i-1)th interval of A_n*)
b[x_, 1, i_] := B[x][[3^(i - 1)]][[1]] 
(*If i is a number in [1,3^(x-1)], then b[x,1,i] is the Lowerbound of the 3^(i-1)th interval of B_n*)
b[x_, 2, i_] := B[x][[3^(i - 1)]][[5]] 
(*If i is a number in [1,3^(x-1)], then b[x,1,i] is the Upperbound of the 3^(i-1)th interval of B_n*)

A[s_, i_] := Reduce[a[s, 1, i] <= x <= (a[s, 1, i] + a[s, 2, i])/2 - 1/2 (1/2^(2 + 1)) 
             (a[s, 2, i] - a[s, 1, i]) || (a[s, 1, i] + a[s, 2, i])/2 + 1/2 (1/2^(2 + 1)) 
             (a[s, 2, i] - a[s, 1, i]) <=x < a[s, 2, i] || (b[s, 1, i] + b[s, 2, i])/2 - 
             1/2 (1/2^(2)) (b[s, 2, i] - b[s, 1, i]) <= x < (b[s, 1, i] + b[s, 2, i])/2 
             + 1/2 (1/2^(2)) (b[s, 2, i] - b[s, 1, i]), {x}] 
(*Changes the 3^(i-1)th interval of A_n using the description in above the attempt.*)

 B[s_, i_] := Reduce[b[s, 1, i] <= x <= (b[s, 1, i] + b[s, 2, i])/2 - 1/2 (1/2^(2)) 
              (b[s, 2, i] - b[s, 1, i]) || (b[s, 1, i] + b[s, 2, i])/2 + 1/2 (1/2^(2)) 
              (b[s, 2, i] - b[s, 1, i]) <= x <b[s, 2, i] || (a[s, 1, i] + a[s, 2, i])/2 - 
              1/2 (1/2^(2 + 1)) (a[s, 2, i] - a[s, 1, i]) <= x < (a[s, 1, i] + a[s, 2, i])/2
              + 1/2 (1/2^(2 + 1)) (a[s, 2, i] - a[s, 1, i]), {x}]
(*Changes 3^(i-1)th interval of A_n into three intervals using the description above the attempt.*)

(Edit 1: Below, I made changes to the code.)

(Edit 3: I made $1/2^{2+1}$ and $1/2^{2}$, $1/2^{1+1}$ and $1/2^{1}$. I apologize for my stupidity.)

A[2] = Reduce[a[1, 1] <= x <= (a[1, 1] + a[1, 2])/2 - 1/2 (1/2^(1 + 1)) (a[1, 2] - a[1, 1]) || 
       (a[1, 1] + a[1, 2])/2 + 1/2 (1/2^(1 + 1)) (a[1, 2] - a[1, 1]) <= x < a[1, 2] || 
       (b[1, 1] + b[1, 2])/2 - 1/2 (1/2^(1)) (b[1, 2] - b[1, 1]) <= x < (b[1, 1] + b[1, 2])/2+
       1/2 (1/2^(1)) (b[1, 2] - b[1, 1]), {x}] (*A2*)

B[2] = Reduce[b[1, 1] <= x <= (b[1, 1] + b[1, 2])/2 - 1/2 (1/2^(1)) (b[1, 2] - b[1, 1]) || 
       (b[1, 1] + b[1, 2])/2 + 1/2 (1/2^(1)) (b[1, 2] - b[1, 1]) <= x < b[1, 2] ||
       (a[1, 1] + a[1, 2])/2 - 1/2 (1/2^(1 + 1)) (a[1, 2] - a[1, 1]) <= x < (a[1, 1] + a[1, 2])/2 + 
     1/2 (1/2^(1 + 1)) (a[1, 2] - a[1, 1]), {x}] (*B2*)
a[x_, 1, i_] := A[x][[3^(i - 1)]][[1]] 
(*If i is a number in [1,3^(x-1)], then a[x,1,i] is the Lowerbound of the 3^(i-1)th interval of A_n*)
a[x_, 2, i_] := A[x][[3^(i - 1)]][[5]] 
(*If i is a number in [1,3^(x-1)], then a[x,1,i] is the Upperbound of the 3^(i-1)th interval of A_n*)
b[x_, 1, i_] := B[x][[3^(i - 1)]][[1]] 
(*If i is a number in [1,3^(x-1)], then b[x,1,i] is the Lowerbound of the 3^(i-1)th interval of B_n*)
b[x_, 2, i_] := B[x][[3^(i - 1)]][[5]] 
(*If i is a number in [1,3^(x-1)], then b[x,1,i] is the Upperbound of the 3^(i-1)th interval of B_n*)

A[s_, i_] := Reduce[a[s, 1, i] <= x <= (a[s, 1, i] + a[s, 2, i])/2 - 1/2 (1/2^(s)) 
             (a[s, 2, i] - a[s, 1, i]) || (a[s, 1, i] + a[s, 2, i])/2 + 1/2 (1/2^(s)) 
             (a[s, 2, i] - a[s, 1, i]) <=x < a[s, 2, i] || (b[s, 1, i] + b[s, 2, i])/2 - 
             1/2 (1/2^(s-1)) (b[s, 2, i] - b[s, 1, i]) <= x < (b[s, 1, i] + b[s, 2, i])/2 
             + 1/2 (1/2^(s-1)) (b[s, 2, i] - b[s, 1, i]), {x}] 
(*Changes the 3^(i-1)th interval of A_n using the description in above the attempt.*)

 B[s_, i_] := Reduce[b[s, 1, i] <= x <= (b[s, 1, i] + b[s, 2, i])/2 - 1/2 (1/2^(s-1)) 
              (b[s, 2, i] - b[s, 1, i]) || (b[s, 1, i] + b[s, 2, i])/2 + 1/2 (1/2^(s-1)) 
              (b[s, 2, i] - b[s, 1, i]) <= x <b[s, 2, i] || (a[s, 1, i] + a[s, 2, i])/2 - 
              1/2 (1/2^(s)) (a[s, 2, i] - a[s, 1, i]) <= x < (a[s, 1, i] + a[s, 2, i])/2
              + 1/2 (1/2^(s)) (a[s, 2, i] - a[s, 1, i]), {x}]
(*Changes 3^(i-1)th interval of A_n into three intervals using the description above the attempt.*)
added 582 characters in body
Source Link
Arbuja
  • 121
  • 4
  • 18

Edit: Made changes to the code

(Edit 2: Note I define $A_n$ and $B_n$ as half-open intervals since I want to partition the reals into sets $A$ and $B$ that are dense (with positive measure) in every sub-interval of $(a,b)$ of $\mathbb{R}$. For more info see this and this post. Thus, it wouldn't be mathematically appropriate if we have that all intervals in $A_n$ and $B_n$ are closed.)


(Edit 1: Below, I made changes to the code)

Edit: Made changes to the code

(Edit 2: Note I define $A_n$ and $B_n$ as half-open intervals since I want to partition the reals into sets $A$ and $B$ that are dense (with positive measure) in every sub-interval of $(a,b)$ of $\mathbb{R}$. For more info see this and this post. Thus, it wouldn't be mathematically appropriate if we have that all intervals in $A_n$ and $B_n$ are closed.)


(Edit 1: Below, I made changes to the code)

Made changes to the code
Source Link
Arbuja
  • 121
  • 4
  • 18

Edit: Made changes to the code

Clear["Global`*"]
A[1] = {0 <= x < 2/3} (*A1=[0,2/3)*)
B[1] = {2/3 <= x < 1} (*B1=[2/3,1)*)
a[1, 1] = Part[List @@ A[1], {1, -1}][[1]]A[1][[1]] (*Lowerbound of A1*)
a[1, 2] = Part[List @@ A[1], {1, -1}][[2]]A[1][[5]] (*Upperbound of A1*)
b[1, 1] = Part[List @@ B[1], {1, -1}][[1]]B[1][[1]] (*Lowerbound of B1*)
b[1, 2] = Part[List @@ B[1], {1, -1}][[2]]B[1][[5]] (*Upperbound of B1*)
a[x_, 1, i_] := Part[List @@ A[x][[3^(i - 1)]], {1, -1}][[1]]]][[1]] 
(*If i is a number in [1,3^(x-1)], then a[x,1,i] is the Lowerbound of the 3^(i-1)th interval of A_n*)
a[x_, 2, i_] := Part[List @@ A[x][[3^(i - 1)]], {1, -1}][[2]]]][[5]] 
(*If i is a number in [1,3^(x-1)], then a[x,1,i] is the Upperbound of the 3^(i-1)th interval of A_n*)
b[x_, 1, i_] := Part[List @@ B[x][[3^(i - 1)]], {1, -1}][[1]]]][[1]] 
(*If i is a number in [1,3^(x-1)], then b[x,1,i] is the Lowerbound of the 3^(i-1)th interval of B_n*)
b[x_, 2, i_] := Part[List @@ B[x][[3^(i - 1)]], {1, -1}][[2]]]][[5]] 
(*If i is a number in [1,3^(x-1)], then b[x,1,i] is the Upperbound of the 3^(i-1)th interval of B_n*)

A[s_, i_] := Reduce[a[s, 1, i] <= x <= (a[s, 1, i] + a[s, 2, i])/2 - 1/2 (1/2^(2 + 1)) 
             (a[s, 2, i] - a[s, 1, i]) || (a[s, 1, i] + a[s, 2, i])/2 + 1/2 (1/2^(2 + 1)) 
             (a[s, 2, i] - a[s, 1, i]) <=x < a[s, 2, i] || (b[s, 1, i] + b[s, 2, i])/2 - 
             1/2 (1/2^(2)) (b[s, 2, i] - b[s, 1, i]) <= x < (b[s, 1, i] + b[s, 2, i])/2 
             + 1/2 (1/2^(2)) (b[s, 2, i] - b[s, 1, i]), {x}] 
(*Changes the 3^(i-1)th interval of A_n using the description in above the attempt.*)

 B[s_, i_] := Reduce[b[s, 1, i] <= x <= (b[s, 1, i] + b[s, 2, i])/2 - 1/2 (1/2^(2)) 
              (b[s, 2, i] - b[s, 1, i]) || (b[s, 1, i] + b[s, 2, i])/2 + 1/2 (1/2^(2)) 
              (b[s, 2, i] - b[s, 1, i]) <= x <b[s, 2, i] || (a[s, 1, i] + a[s, 2, i])/2 - 
              1/2 (1/2^(2 + 1)) (a[s, 2, i] - a[s, 1, i]) <= x < (a[s, 1, i] + a[s, 2, i])/2
              + 1/2 (1/2^(2 + 1)) (a[s, 2, i] - a[s, 1, i]), {x}]
(*Changes 3^(i-1)th interval of A_n into three intervals using the description above the attempt.*)
A[s_] := Reduce[Table[A[sReduce[Flatten[Table[A[s, i], {i, 1, 3^(s - 1)}]]], {s}]
(*Combines all 3^(i-1)th intervals for all i-values*)
B[s_] := Reduce[Table[B[sReduce[Flatten[Table[B[s, i], {i, 1, 3^(s - 1)}]]], {s}]
(*Combines all 3^(i-1)th intervals for all i-values*)
A[3] (*A3*)
B[3](*B3*)
Clear["Global`*"]
A[1] = {0 <= x < 2/3} (*A1=[0,2/3)*)
B[1] = {2/3 <= x < 1} (*B1=[2/3,1)*)
a[1, 1] = Part[List @@ A[1], {1, -1}][[1]] (*Lowerbound of A1*)
a[1, 2] = Part[List @@ A[1], {1, -1}][[2]] (*Upperbound of A1*)
b[1, 1] = Part[List @@ B[1], {1, -1}][[1]] (*Lowerbound of B1*)
b[1, 2] = Part[List @@ B[1], {1, -1}][[2]] (*Upperbound of B1*)
a[x_, 1, i_] := Part[List @@ A[x][[3^(i - 1)]], {1, -1}][[1]] 
(*If i is a number in [1,3^(x-1)], then a[x,1,i] is the Lowerbound of the 3^(i-1)th interval of A_n*)
a[x_, 2, i_] := Part[List @@ A[x][[3^(i - 1)]], {1, -1}][[2]] 
(*If i is a number in [1,3^(x-1)], then a[x,1,i] is the Upperbound of the 3^(i-1)th interval of A_n*)
b[x_, 1, i_] := Part[List @@ B[x][[3^(i - 1)]], {1, -1}][[1]] 
(*If i is a number in [1,3^(x-1)], then b[x,1,i] is the Lowerbound of the 3^(i-1)th interval of B_n*)
b[x_, 2, i_] := Part[List @@ B[x][[3^(i - 1)]], {1, -1}][[2]] 
(*If i is a number in [1,3^(x-1)], then b[x,1,i] is the Upperbound of the 3^(i-1)th interval of B_n*)

A[s_, i_] := Reduce[a[s, 1, i] <= x <= (a[s, 1, i] + a[s, 2, i])/2 - 1/2 (1/2^(2 + 1)) 
             (a[s, 2, i] - a[s, 1, i]) || (a[s, 1, i] + a[s, 2, i])/2 + 1/2 (1/2^(2 + 1)) 
             (a[s, 2, i] - a[s, 1, i]) <=x < a[s, 2, i] || (b[s, 1, i] + b[s, 2, i])/2 - 
             1/2 (1/2^(2)) (b[s, 2, i] - b[s, 1, i]) <= x < (b[s, 1, i] + b[s, 2, i])/2 
             + 1/2 (1/2^(2)) (b[s, 2, i] - b[s, 1, i]), {x}] 
(*Changes the 3^(i-1)th interval of A_n using the description in above the attempt.*)

 B[s_, i_] := Reduce[b[s, 1, i] <= x <= (b[s, 1, i] + b[s, 2, i])/2 - 1/2 (1/2^(2)) 
              (b[s, 2, i] - b[s, 1, i]) || (b[s, 1, i] + b[s, 2, i])/2 + 1/2 (1/2^(2)) 
              (b[s, 2, i] - b[s, 1, i]) <= x <b[s, 2, i] || (a[s, 1, i] + a[s, 2, i])/2 - 
              1/2 (1/2^(2 + 1)) (a[s, 2, i] - a[s, 1, i]) <= x < (a[s, 1, i] + a[s, 2, i])/2
              + 1/2 (1/2^(2 + 1)) (a[s, 2, i] - a[s, 1, i]), {x}]
(*Changes 3^(i-1)th interval of A_n into three intervals using the description above the attempt.*)
A[s_] := Reduce[Table[A[s, i], {i, 1, 3^(s - 1)}], {s}]
(*Combines all 3^(i-1)th intervals for all i-values*)
B[s_] := Reduce[Table[B[s, i], {i, 1, 3^(s - 1)}], {s}]
(*Combines all 3^(i-1)th intervals for all i-values*)
A[3] (*A3*)
B[3](*B3*)

Edit: Made changes to the code

Clear["Global`*"]
A[1] = 0 <= x < 2/3 (*A1=[0,2/3)*)
B[1] = 2/3 <= x < 1 (*B1=[2/3,1)*)
a[1, 1] = A[1][[1]] (*Lowerbound of A1*)
a[1, 2] = A[1][[5]] (*Upperbound of A1*)
b[1, 1] = B[1][[1]] (*Lowerbound of B1*)
b[1, 2] = B[1][[5]] (*Upperbound of B1*)
a[x_, 1, i_] := A[x][[3^(i - 1)]][[1]] 
(*If i is a number in [1,3^(x-1)], then a[x,1,i] is the Lowerbound of the 3^(i-1)th interval of A_n*)
a[x_, 2, i_] := A[x][[3^(i - 1)]][[5]] 
(*If i is a number in [1,3^(x-1)], then a[x,1,i] is the Upperbound of the 3^(i-1)th interval of A_n*)
b[x_, 1, i_] := B[x][[3^(i - 1)]][[1]] 
(*If i is a number in [1,3^(x-1)], then b[x,1,i] is the Lowerbound of the 3^(i-1)th interval of B_n*)
b[x_, 2, i_] := B[x][[3^(i - 1)]][[5]] 
(*If i is a number in [1,3^(x-1)], then b[x,1,i] is the Upperbound of the 3^(i-1)th interval of B_n*)

A[s_, i_] := Reduce[a[s, 1, i] <= x <= (a[s, 1, i] + a[s, 2, i])/2 - 1/2 (1/2^(2 + 1)) 
             (a[s, 2, i] - a[s, 1, i]) || (a[s, 1, i] + a[s, 2, i])/2 + 1/2 (1/2^(2 + 1)) 
             (a[s, 2, i] - a[s, 1, i]) <=x < a[s, 2, i] || (b[s, 1, i] + b[s, 2, i])/2 - 
             1/2 (1/2^(2)) (b[s, 2, i] - b[s, 1, i]) <= x < (b[s, 1, i] + b[s, 2, i])/2 
             + 1/2 (1/2^(2)) (b[s, 2, i] - b[s, 1, i]), {x}] 
(*Changes the 3^(i-1)th interval of A_n using the description in above the attempt.*)

 B[s_, i_] := Reduce[b[s, 1, i] <= x <= (b[s, 1, i] + b[s, 2, i])/2 - 1/2 (1/2^(2)) 
              (b[s, 2, i] - b[s, 1, i]) || (b[s, 1, i] + b[s, 2, i])/2 + 1/2 (1/2^(2)) 
              (b[s, 2, i] - b[s, 1, i]) <= x <b[s, 2, i] || (a[s, 1, i] + a[s, 2, i])/2 - 
              1/2 (1/2^(2 + 1)) (a[s, 2, i] - a[s, 1, i]) <= x < (a[s, 1, i] + a[s, 2, i])/2
              + 1/2 (1/2^(2 + 1)) (a[s, 2, i] - a[s, 1, i]), {x}]
(*Changes 3^(i-1)th interval of A_n into three intervals using the description above the attempt.*)
A[s_] := Reduce[Flatten[Table[A[s, i], {i, 1, 3^(s - 1)}]], {s}]
(*Combines all 3^(i-1)th intervals for all i-values*)
B[s_] := Reduce[Flatten[Table[B[s, i], {i, 1, 3^(s - 1)}]], {s}]
(*Combines all 3^(i-1)th intervals for all i-values*)
A[3] (*A3*)
B[3](*B3*)
Source Link
Arbuja
  • 121
  • 4
  • 18
Loading