# Rebase algorithm

## Recommended Posts

Hello!

I'm building a rebase algorithm that I need some help with. These are the variables, constants, and constraints (the values themselves are just examples):

Set of variables 1:

• a1 = 1934464428151493937044
• b = 54802476401439357
• c = 1e18
• result1 = ?

Set of variables 2:

• a2 = 1837741206733939183658
• b = 54802476401439357
• c = 1e18
• result2 = ?

Final invariant --> result1 == result2

As you can see b and c are constants and the only variables shared between sets, so you can't use a1 during the operations of Set 2 and vice versa (a1 and a2 might fluctuate in value, but not b and c).

Also, result1 is not known during the operations for result2, and vice versa.

The idea is to have result1 to equal result2. Feel free to add more variables, constants, escalating factors, etc. if you need them in order to achieve the final idea.

Thanks!

##### Share on other sites

Something is missing in this definition. As it is described, the simple solution would be just to have a "result" some constant or, more generally, independent on the variable "a".

##### Share on other sites

Something is missing in this definition. As it is described, the simple solution would be just to have a "result" some constant or, more generally, independent on the variable "a".

Perhaps that something that's missing is the clarification that a1 and a2 are the only actual variables (while b and c are the constants)?

You can also introduce more variables/constants in your end, if that helps to achieve the invariant of result1 === result2.

##### Share on other sites

1 minute ago, dNY said:

Perhaps that something that's missing is the clarification that a1 and a2 are the only actual variables (while b and c are the constants)?

You can also introduce more variables/constants in your end, if that helps to achieve the invariant of result1 === result2.

So, what is wrong with defining, say, result1==result2==5?

##### Share on other sites

So, what is wrong with defining, say, result1==result2==5?

You can't know result1 on the calculation of result2, and vice versa.

Each one happens in their own separate environment at runtime, so to say that result2 is equal to result1 in result2's environment, you'd need to know result1 beforehand, thus breaking this invariant.

##### Share on other sites

57 minutes ago, dNY said:

You can't know result1 on the calculation of result2, and vice versa.

Each one happens in their own separate environment at runtime, so to say that result2 is equal to result1 in result2's environment, you'd need to know result1 beforehand, thus breaking this invariant.

Let "result" to be a b's digit of the number $$\pi$$.

I don't know it beforehand, but they will be equal.

##### Share on other sites

Let "result" to be a b's digit of the number

Do you have a formula?

##### Share on other sites

Just now, dNY said:

Do you have a formula?

There are many formulas and algorithms for calculating $$\pi$$. See, e.g., here: Approximations of π - Wikipedia

##### Share on other sites

There are many formulas and algorithms for calculating π . See, e.g., here: Approximations of π - Wikipedia

Formula for my case, I mean. I don't get how your answer applies to my question, so a formula would show that.

##### Share on other sites

3 minutes ago, dNY said:

Formula for my case, I mean. I don't get how your answer applies to my question, so a formula would show that.

## Create an account

Register a new account