How to Create a Function In Two Variables With a Domain Restriction?

GROUPS:
 Hello everybody! I'm a novice Mathematica user, and I have a problem I'd like to get some help plugging into Mathematica. I'm rewriting a function that is in terms of (x, y) coordinates in terms of the angle those coordinates form instead, and I am able to put the function into Mathematica and plug in values one at a time. However, I'd like to be able to view the results of the function when hundreds of values are plugged in, in order to see what value(s) it approaches. The problem is that I don't know how to express in terms Mathematica can understand the fact that, when plugging values into this function, 2y>x and x≥y. For neatness' sake, I'd also like to be able to arrange the values plugged into the function and the resulting output values into a table, if that's not impossible as well. This is what I've come up with so far, but the values of x and y are not restricted as I'd like. Also, the table isn't good at showing what output values correspond to what input values. {Table[ArcTan[(y*Sqrt[3])/(2*x + y)], {x, 10}], {y, 10}}Any help that you can provide would be fantastic. Thank you so much!
2 years ago
4 Replies
 If you can show an example of a couple of your input values, probably best as data={{x1,y1},{x2,y2}}, more if needed to really show the various special cases that need to be handled, and then an example of what you want the output to look like then it might be fairly easy to craft up something to do that. You might also look at the documentation for ArcTan. There is an ArcTan[y/x] form and an ArcTan[y,x] form. The second form can sometimes avoid confusion about angles when one or both of x and y are negative.So, imagine you are writing up a project proposal for someone who doesn't know all the stuff in your head, hasn't been watching you work on this and who can then take that description away, finish the project without needing to bring it back, find it is wrong, start over, ask more questions, etc, etc, etc, do it once and have it be just what you are looking for.
 Bill Simpson 2 Votes Ah, far far more helpful, That Excel sheet was just what was needed to see exactly how you wanted the result presented.I think this does it data = Select[Flatten[Table[{x, y}, {x, 1, 10}, {y, 1, 10}], 1], ({x, y} = #; 2*y > x && x >= y)&]; MatrixForm[ Map[{{x, y} = #; x, y, ArcTan[(y*Sqrt[3])/(2*x+y)], N[ArcTan[(y*Sqrt[3])/(2*x+y)]]}&, data]] If you run that you should see it almost duplicates what you want. It doesn't provide the header across the top. I tried and failed with that.The first line makes up all possible x,y pairs and then selects only those that satisfy your conditions.The second line builds each row of your table and then uses MatrixForm to nicely line them up. Be careful if you use MatrixForm in the future, it makes a nice display, but you can't do any calculations with the result of a MatrixForm.The # and & notation can be confusing, but that is a Mathematica shortcut for defining and using quick little one time functions. Each # in that is going to be an x,y pair. Select and Map go through all the pairs, one at a time.You can "take that apart" to learn how it works. Just do the Table and look carefully at what it does. Then the Flatten[Table... and see how it changes. Then study the stuff at the end of the Select, try changing it a bit at a time and see if you can understand how to use that in the future for other problems. Look up the functions in the help system and try to figure out how that relates to this example.