I have a set of points {x,y} given by the following:
LIST1 = {{2, 10}, {4, 12}, {6, 17}, {8, 20}, {10, 25}, {12, 23}, {14,
32}, {16, 34}, {16, 33}, {18, 56}, {20, 43}, {22, 67}, {24, 55}};
I have a function defined as MYFUN[x_,y_]=2y^2 - 4x +1
. I want to compute the value of this fucntion for every pair of (x,y) given in LIST1 and form the LIST2 = {x,MYFUN[x,y]}
. Is there a quick way of doing this? I tried by putting each point in the function, but it takes lot of time.
MYFUN = 2 (12 )^2 - 4 (4) + 1
LIST2 = {{2, 193}, {4,
273}, {6,}, {8,}, {10,}, {12,}, {14,}, {16,}, {18,}, {20,}, \
{22,}, {24,}};
I don't know why I gave this question a horrible title before " Parameter as a variable".
myFun[x_, y_] := 2 y^2 - 4 x + 1; Transpose@{list1[[;; , 1]], myFun @@@ list1}
. Usually, user defined functions and variables start with a lower-case letter to differentiate from the built-in functions. $\endgroup${x, y}
tuple as inmyFun[{x_, y_}] := 2 y^2 - 4 x + 1
and then map this function to your list of tuples viaMap[myFun]@LIST1
. If you also want everyx
together with the result you can wrap this in another function and map the resulting function:Map[Function[p, {First[p], myFun[p]}]]@LIST1
$\endgroup$