ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 23 Aug 2014 13:47:41 +0200How to get all the solutions possible of the questionhttps://ask.sagemath.org/question/23897/how-to-get-all-the-solutions-possible-of-the-question/ I have 20 variable, and I don't have the twenty relations exactly and few of them are of the form of x1*x2=18 (considering x1 and x2 as variables) and other of the form of x5-x2=3 and so on
Thanks in advance for helping me :)Fri, 22 Aug 2014 19:53:53 +0200https://ask.sagemath.org/question/23897/how-to-get-all-the-solutions-possible-of-the-question/Comment by tmonteil for <p>I have 20 variable, and I don't have the twenty relations exactly and few of them are of the form of x1*x2=18 (considering x1 and x2 as variables) and other of the form of x5-x2=3 and so on </p>
<p>Thanks in advance for helping me :)</p>
https://ask.sagemath.org/question/23897/how-to-get-all-the-solutions-possible-of-the-question/?comment=23900#post-id-23900So, your variables can only take values 0 and 1 ?Fri, 22 Aug 2014 20:18:06 +0200https://ask.sagemath.org/question/23897/how-to-get-all-the-solutions-possible-of-the-question/?comment=23900#post-id-23900Comment by Tummala Dhanvi for <p>I have 20 variable, and I don't have the twenty relations exactly and few of them are of the form of x1*x2=18 (considering x1 and x2 as variables) and other of the form of x5-x2=3 and so on </p>
<p>Thanks in advance for helping me :)</p>
https://ask.sagemath.org/question/23897/how-to-get-all-the-solutions-possible-of-the-question/?comment=23899#post-id-23899I will get my question more clearly i need a 20 digit number which satisfies a set of conditions such as d18 + d19 = 3 ( considering that d18 and d19 are the corresponding digits of the number) it tried making all the digits as variables and find all the solutions possible )Fri, 22 Aug 2014 20:12:43 +0200https://ask.sagemath.org/question/23897/how-to-get-all-the-solutions-possible-of-the-question/?comment=23899#post-id-23899Comment by kcrisman for <p>I have 20 variable, and I don't have the twenty relations exactly and few of them are of the form of x1*x2=18 (considering x1 and x2 as variables) and other of the form of x5-x2=3 and so on </p>
<p>Thanks in advance for helping me :)</p>
https://ask.sagemath.org/question/23897/how-to-get-all-the-solutions-possible-of-the-question/?comment=23898#post-id-23898Hi! In order for this question to be answered, you need to provide a lot more information - such as what you have tried specifically. Have you used any Sage for this? Usually a linear system or the `solve` command will be helpful, based on your very vague question.Fri, 22 Aug 2014 20:05:40 +0200https://ask.sagemath.org/question/23897/how-to-get-all-the-solutions-possible-of-the-question/?comment=23898#post-id-23898Comment by Tummala Dhanvi for <p>I have 20 variable, and I don't have the twenty relations exactly and few of them are of the form of x1*x2=18 (considering x1 and x2 as variables) and other of the form of x5-x2=3 and so on </p>
<p>Thanks in advance for helping me :)</p>
https://ask.sagemath.org/question/23897/how-to-get-all-the-solutions-possible-of-the-question/?comment=23901#post-id-23901no way my variable are digits which can have the value 0-9
I will say you the question once more I need to get a 20 digit number of which the relation between the digits are defined :)Fri, 22 Aug 2014 20:27:06 +0200https://ask.sagemath.org/question/23897/how-to-get-all-the-solutions-possible-of-the-question/?comment=23901#post-id-23901Answer by tmonteil for <p>I have 20 variable, and I don't have the twenty relations exactly and few of them are of the form of x1*x2=18 (considering x1 and x2 as variables) and other of the form of x5-x2=3 and so on </p>
<p>Thanks in advance for helping me :)</p>
https://ask.sagemath.org/question/23897/how-to-get-all-the-solutions-possible-of-the-question/?answer=23902#post-id-23902It is not really a Sage question but a programming question. If your numbers were only 0 and 1, you could have tried an exhaustive search (using for example ``itertools.product([0,1], repeat=20)``. But testing 10^20 cases is impossible, so you need to inspect your equations to reduce the set of possiblities. For example, ``x5-x2=3`` tells you that ``x5`` can be deduced from ``x2`` (so you will not have to iterate over it) and that ``x2`` is between 0 and 6 ; ``x1*x2=18`` tells you that ``x2`` can be deduced from ``x1`` (so you will not have to iterate over it either) and ``x1`` can only take the values 2, 3, 6, 9.
You can also try to solve your system symbolically and see how many parameters are free, but you should be aware that it is not very reliable:
sage: var('x1 x2 x3 x4')
(x1, x2, x3, x4)
sage: solve([x1*x2==18, x4-x2==4], x1,x2,x3,x4)
[[x1 == 18/r1, x2 == r1, x3 == r2, x4 == r1 + 4]]
Fri, 22 Aug 2014 21:02:41 +0200https://ask.sagemath.org/question/23897/how-to-get-all-the-solutions-possible-of-the-question/?answer=23902#post-id-23902Comment by Tummala Dhanvi for <p>It is not really a Sage question but a programming question. If your numbers were only 0 and 1, you could have tried an exhaustive search (using for example <code>itertools.product([0,1], repeat=20)</code>. But testing 10^20 cases is impossible, so you need to inspect your equations to reduce the set of possiblities. For example, <code>x5-x2=3</code> tells you that <code>x5</code> can be deduced from <code>x2</code> (so you will not have to iterate over it) and that <code>x2</code> is between 0 and 6 ; <code>x1*x2=18</code> tells you that <code>x2</code> can be deduced from <code>x1</code> (so you will not have to iterate over it either) and <code>x1</code> can only take the values 2, 3, 6, 9.</p>
<p>You can also try to solve your system symbolically and see how many parameters are free, but you should be aware that it is not very reliable:</p>
<pre><code>sage: var('x1 x2 x3 x4')
(x1, x2, x3, x4)
sage: solve([x1*x2==18, x4-x2==4], x1,x2,x3,x4)
[[x1 == 18/r1, x2 == r1, x3 == r2, x4 == r1 + 4]]
</code></pre>
https://ask.sagemath.org/question/23897/how-to-get-all-the-solutions-possible-of-the-question/?comment=23903#post-id-23903ya your are correct it is a programming question :)(as the equations also contain % modulus which i can't solve it using sage)
I have to break my head for the solution :PFri, 22 Aug 2014 21:32:23 +0200https://ask.sagemath.org/question/23897/how-to-get-all-the-solutions-possible-of-the-question/?comment=23903#post-id-23903Comment by tmonteil for <p>It is not really a Sage question but a programming question. If your numbers were only 0 and 1, you could have tried an exhaustive search (using for example <code>itertools.product([0,1], repeat=20)</code>. But testing 10^20 cases is impossible, so you need to inspect your equations to reduce the set of possiblities. For example, <code>x5-x2=3</code> tells you that <code>x5</code> can be deduced from <code>x2</code> (so you will not have to iterate over it) and that <code>x2</code> is between 0 and 6 ; <code>x1*x2=18</code> tells you that <code>x2</code> can be deduced from <code>x1</code> (so you will not have to iterate over it either) and <code>x1</code> can only take the values 2, 3, 6, 9.</p>
<p>You can also try to solve your system symbolically and see how many parameters are free, but you should be aware that it is not very reliable:</p>
<pre><code>sage: var('x1 x2 x3 x4')
(x1, x2, x3, x4)
sage: solve([x1*x2==18, x4-x2==4], x1,x2,x3,x4)
[[x1 == 18/r1, x2 == r1, x3 == r2, x4 == r1 + 4]]
</code></pre>
https://ask.sagemath.org/question/23897/how-to-get-all-the-solutions-possible-of-the-question/?comment=23904#post-id-23904Yup. For ``%`` equations, they are also strongly reducing the set of possibilities. Good luck, do not hesitate to post your progress here.Fri, 22 Aug 2014 21:55:11 +0200https://ask.sagemath.org/question/23897/how-to-get-all-the-solutions-possible-of-the-question/?comment=23904#post-id-23904Comment by Tummala Dhanvi for <p>It is not really a Sage question but a programming question. If your numbers were only 0 and 1, you could have tried an exhaustive search (using for example <code>itertools.product([0,1], repeat=20)</code>. But testing 10^20 cases is impossible, so you need to inspect your equations to reduce the set of possiblities. For example, <code>x5-x2=3</code> tells you that <code>x5</code> can be deduced from <code>x2</code> (so you will not have to iterate over it) and that <code>x2</code> is between 0 and 6 ; <code>x1*x2=18</code> tells you that <code>x2</code> can be deduced from <code>x1</code> (so you will not have to iterate over it either) and <code>x1</code> can only take the values 2, 3, 6, 9.</p>
<p>You can also try to solve your system symbolically and see how many parameters are free, but you should be aware that it is not very reliable:</p>
<pre><code>sage: var('x1 x2 x3 x4')
(x1, x2, x3, x4)
sage: solve([x1*x2==18, x4-x2==4], x1,x2,x3,x4)
[[x1 == 18/r1, x2 == r1, x3 == r2, x4 == r1 + 4]]
</code></pre>
https://ask.sagemath.org/question/23897/how-to-get-all-the-solutions-possible-of-the-question/?comment=23908#post-id-23908No the thing becomes more complicated because the equations are of the form x16%x9 =2 which is more difficult to solve :)Sat, 23 Aug 2014 13:47:41 +0200https://ask.sagemath.org/question/23897/how-to-get-all-the-solutions-possible-of-the-question/?comment=23908#post-id-23908