Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Evaluating functions at several points

I want to evaluate f[x,y]=-4 x + x^2 - 4 y - y^2 at points (1,-2); (2,-3); (3,-2); (2,-1).

I tried using Outer but for some reason it does not give me actual values. Help.

like image 671
Koba Avatar asked Apr 26 '12 01:04

Koba


2 Answers

Remember that Mathematica has a specific way of defining functions. In your case it would be f[x_,y_]:=-4 x + x^2 - 4 y - y^2. Then you could simply use f[1,-2] etc.

like image 182
arshajii Avatar answered Oct 15 '22 00:10

arshajii


Perhaps consider using a 'pure' function. For example:

-4 #1 + #1^2 - 4*#2 - #2^2 & @@@ {{1, -2}, {2, -3}, {3, -2}, {2, -1}}

gives

{1, -1, 1, -1}

like image 25
681234 Avatar answered Oct 15 '22 00:10

681234