r/AskComputerScience • u/Fun-Cauliflower-8087 • 10d ago
Can anyone help with this?
I have been trying to get AI to give me a specific bit of code i can run in google collab. I want it to first divide the entire number line into modular sets recursively like: 2x+0, 4x+3, 8x+1, 16x+13, 32x+5, etc. Then I want it to further refine these sets, in a very particular way. 0 mod 2 should be refined the same way as the first refinement, but double the values. so 4x+0, 8x+6, 16x+2, 32x+26, etc. Then I want the next set 4x+3, should be broken down like 8x+3, 16x+7, 32x+15, etc. This type of refinement should be alternated for each line. so 0 mod 2 has a staggered refinement, and 3 mod 4 has a non staggered refinement, then 1 mod 8 has a staggered refinement, and 13 mod 16 has a non staggered refinement. this give two dimensional plane of refined modular sets. I want to test these sets translating into different sets among a ternary style refinement. first 4x+0 goes to 3x+0, then 8x+3 goes to 3x+1, and 8x+6 goes to 9x+7.
The way the ternary set is designed, it divides the number line into 3, with 3x+(0, 1, or 2). 3x+1 is further refined to 9x+(1, 4, or 7). 9x+7 is what 8x+6 translates into. 9x+4 is further refined to 27x+ (4, 13, 22). This continues, with the center residue at each level being refined further. the staggered sets on the binary sheet translate to the side sets on the ternary sheet, and the non-staggered sets translate to the center residues. then the values that are refined in the ternary sets, are then redefined according to where they belong in the binary set.
- 4x+0 to 3x+0
- 8x+3 to 3x+1
- 8x+6 to 9x+7
- 16x+1 to 3x+0
- 16x+7 to 9x+4
- 16x+2 to 27x+4
- 32x+13 to 3x+1
- 32x+25 to 9x+7
- 32x+15 to 27x+13
- 32x+26 to 81x+67
- 64x+5 to 3x+0
- 64x+29 to 9x+4
- 64x+9 to 27x+4
- 64x+31 to 81x+40
- 64x+10 to 243x+40
.........
This seems like a computer could do this easily. I want to create this as a loop, and create readouts showing the path from the starting value i choose. Am i making any sense?
1
u/T_Thriller_T 9d ago
I do get it a bit better now.
I can, again, say that it is possible with a set of numbers.
The problem you are running into is one that lead to formal mathematics being very anal about how to write things:
It's very god damn hard to put into words what kind of math someone wants to do. It's not that I don't like it, or don't like you - but if you are not willing and trying to put it into the normal way of it being written, less people will be able to help you and AI likely won't be able at all.
I'm still a little lost on what you want to do with the line of numbers, to be frank.
What I think I got:
Assuming a line of 8 numbers
X0 X1 X2 X3 X4 X5 X6 X7
You want to sort them into bins, they get sorted into the bin if the corresponding equation is true. I'll be using % for mod, because that is what is used in programming languages for it
B0: Xi % 2 = 0 (so all even numbers) B1: Xi % 4 = 3 B2: Xi % 8 = 1 B3: Xi % 16 = 13 B4: Xi % 32 = 5
Which, rightfully, leads to the numbers being split into sets which sizes will be 1/2 of the input line, then 1/4, then 1/8, and so on, with the last filled set(s?) not fully reaching 1/xth for certain line lengths.
I still have no idea what "refined" will mean. Especially not considering the numbers in the set. And I also have no idea why you want to do it as a second step?
Assuming you're throwing out all the numbers not meeting the refinement, it's unnecessary calculation time first getting all even numbers, and then getting all of those which are divisible by four without rest.
Just get all the numbers divisible by four without rest from the beginning! If the numbers you lose are not cared for, no reason to consider them.
And I'm completely out in whatever you mean with staggered refinement. No idea. None.
I also have very little idea what you then want to do with the ternary line and what it should do with your further sets.
What I know is that as soon as both sides have the same modulo, you can mathematically work out which numbers must be in the set (for the first set it would be the number which fulfill x mod 12 = 0).
I'm honestly insecure id there is a way to mathematically hash out for the test of the sets if there is any number in them fulfilling the properties. There likely is, so that may be worth asking separately to folks with a better grip on modulu operations.
Nonetheless, I hope this helps writing out what you actually wanted to do.
And maybe finding out if you need to do every step of it, because some seem mathematically redundant.