How to Generate Random Mathematical Equations that Equal an Integer

8.1k Views Asked by At

Looking for a way to generate random mathematical equations that equal an integer between 0 and 9, a way to rank the complexity of the equation rendered, and a method to note the mathematical concepts utilized within the equation.

My first guess is that a random integer between 0 and 9 would be selected. After that, your guess is much more likely to be better than mine.

EDIT: To be more clear, solutions should ONLY result in the following: 0,1,2,3,4,5,6,7,8,9.

2

There are 2 best solutions below

3
On BEST ANSWER

I am still not sure what do you want, but I guess you are talking about roots. Ok, lets consider a class of linear equations. They have only two parameters: $ax+b = 0$. Choosing randomly $\hat{x} = 0,1,...,9$ you have a condition on $a$ and $b$: $a\hat{x}+b = 0$. for this class you can only randomly choose one of the variables (preferably, $b$ not to make $a$ equal to zero).

Example. $x = 2$, then $2a+b = 0$. You make $b = rand(0,100)$ and $a = -0.5 b$. then the solution will be $x=2$ as it was desired.

You can also consider another class - but note that you would like to have a unique solution. Say, for quadratic equation you may want to say "find the positive root of an equation". Then algorithm is the following: choose $\hat{x} = 0,1,...,9$ and $x'$ to be a negative number (preferably integer also). Then any equation of the form $a(x-\hat{x})(x-x') = 0$ has desired roots. For this equation you can choose independently $a$ (any) and $x'$ (negative). To make it more tough, open the brackets after the choice of all parameters.

Example. We choose again $\hat{x} = 2$ and $a = rand(0,12)$ and $x' = -rand(0,100)$. then we have an equation $ax^2 - (2+x')x + 2x' = 0$.

1
On

Pick a positive integer n between 0 and 4 and a positive integer p between 1 and 5. Add r instances of (y+(-y)) to n+p, where r indicates a random positive integer, in other words (n+p)+(y_1+(-y)_1)+...+(y_r+(-y)_r). The complexity of the equation compared to other equations of the same type comes as the value equal to r. One could also select 4 positive integers between 0 and 2, or 5 positive integers two of which lie between 0 and 2 and three of which lie between 0 and 1, and many other possibilities exist. The partitions of 9 here work similarly.