Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a very simple equation 2x + y = 10 I want to know which integer combinations of x and y between -10 & 20 will yield a solution 10. I then want to store the various solutions of x and y and have them as inputs to another equation x^2 + 2y = z and in the end I want a list of all the z values. How do I tell Mathematica to do that?

I tried:

one[x_, y_] = 2 x + y; 
Array[{Solve[one[x_, y_] == 3, {20 > x > -10, 20 > y -10}}, [one, 10]]
share|improve this question
1  
You surely should start following some tutorials, try some code, and post it here when you've a problem you can't solve –  belisarius Nov 26 '13 at 23:41
    
one[x_, y_] = 2 x + y; `Array[{Solve[one[x_, y_] == 3, {20 > x > -10, 20 > y -10}}, [one, 10]]' @belisarius –  Randy Nov 27 '13 at 0:06
    
possible duplicate of How to find lattice points on a line segment? –  Artes Nov 27 '13 at 7:20
add comment

closed as off-topic by belisarius, Kuba, Yves Klett, Artes, Michael E2 Nov 27 '13 at 16:36

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Kuba, Yves Klett
If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers

Here's another way using FindInstance:

z = (x^2 + 2 y) /. 
  FindInstance[2 x + y == 10 && -10 <= x <= 20 && -10 <= y <= 20, {x,y}, Integers, 100]
share|improve this answer
add comment
x^2 + 2 y /.  Solve[{2 x + y == 10 && -10 < x < 20 && -10 < y < 20}, Integers]
share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.