dNY Posted February 19 Share Posted February 19 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! Link to comment Share on other sites More sharing options...
Genady Posted February 20 Share Posted February 20 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". Link to comment Share on other sites More sharing options...
dNY Posted February 20 Author Share Posted February 20 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. Link to comment Share on other sites More sharing options...
Genady Posted February 20 Share Posted February 20 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? Link to comment Share on other sites More sharing options...
dNY Posted February 20 Author Share Posted February 20 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. Link to comment Share on other sites More sharing options...
Genady Posted February 20 Share Posted February 20 (edited) 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 February 20 by Genady Link to comment Share on other sites More sharing options...
dNY Posted February 20 Author Share Posted February 20 1 hour ago, Genady said: Let "result" to be a b's digit of the number Do you have a formula? Link to comment Share on other sites More sharing options...
Genady Posted February 20 Share Posted February 20 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 Link to comment Share on other sites More sharing options...
dNY Posted February 20 Author Share Posted February 20 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. Link to comment Share on other sites More sharing options...
Genady Posted February 20 Share Posted February 20 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. Pick any: Calculate Pi with Python - GeeksforGeeks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now