# How to generate a list of elements from an expresion that has (==)

The problem I'm having is that I can't figure out how to make a list of elements from the following expression:

(x-h)^2 + (y-k)^2 == r^2


What I'm trying to do is generate a list with a definite set of values for h and k with a fixed value of r, to get something like this:

{(-1 + x)^2 + (-1 + y)^2 == 1, (-2 + x)^2 + (-2 + y)^2 == 1, (-3 + x)^2 + (-3 + y)^2 == 1}


The code I'm using is the following:

(-h + x)^2 + (-k + y)^2 == r^2 /. {h :> Range[1, 3], k :> Range[1, 3],r -> 1}


And from that I'm getting this:

   {(-1 + x)^2 + (-1 + y)^2, (-2 + x)^2 + (-2 + y)^2, (-3 + x)^2 + (-3 + y)^2} == 1


I'm looking for any pointers on what I'm doing wrong because I can't figure it out.

Again thanks for any pointers, help or comments that could help me to figure out what to do.

• How about using Table? – mikado Sep 17 '16 at 22:42

Just an example...

Flatten[Table[(x - h)^2 + (y - k)^2 == r^2, {h, 1, 3}, {k, 1, 3}]]


results in...

{(-1 + x)^2 + (-1 + y)^2 == r^2, (-1 + x)^2 + (-2 + y)^2 == r^2, (-1 + x)^2 + (-3 + y)^2 == r^2, (-2 + x)^2 + (-1 + y)^2 == r^2, (-2 + x)^2 + (-2 + y)^2 == r^2, (-2 + x)^2 + (-3 + y)^2 == r^2, (-3 + x)^2 + (-1 + y)^2 == r^2, (-3 + x)^2 + (-2 + y)^2 == r^2, (-3 + x)^2 + (-3 + y)^2 == r^2}

IsnĀ“t that what you are looking for ?

Table[(x - h)^2 + (y - h)^2 == r^2, {h, 1, 3}]