Jump to content

Featured Replies

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!

 

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".

  • Author
16 hours ago, Genady said:

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. 

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?

  • Author
1 hour ago, Genady said:

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.

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.

Edited by Genady

  • Author
1 hour ago, Genady said:

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

Do you have a formula? 

  • Author
Just now, Genady said:

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. 

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.