1
$\begingroup$

I want to evaluate a function of "two" variables using some data points (x,y(x)) (but one of them is related to the other) that I have made with the function Table.

My table of data (x,y(x)) that I have build in Mathematica using Table with a given complicated implicit equation is something like:

data = {{1.35, 3.56}, {1.55, 4.78}, {1.76, 8.89},...}

And imagine that I have the following function:

f[x_, y_] := x*y / (x^2 + y^2)

Now I want to evaluate my list of data points $(x,y(x))$ using my function, and make a plot of that, so plotting actually $f(x)$, because $y(x)$ is not an independent variable. How can that be done?

EXAMPLE:

If I evaluate the list data under the previous function, I will obtain something like

evaluation = {{1.35, 0.331}, {1.55, 0.293}, {1.76, 0.191}}

So precisely I want to do a plot of these points, but in a systematic way of course.

$\endgroup$
  • $\begingroup$ very closely related: 2688. Is ListPlot3D[ {##, f[##]}& @@@ data] what you want? $\endgroup$ – Kuba May 9 '18 at 14:02
  • $\begingroup$ okay, so I have eddited my post. Actually it's not a function f(x,y), it's given by y(x), so at the end the function is only for a given variable x, because the other is related like y(x) by the table of points $\endgroup$ – Joe May 9 '18 at 14:13
  • $\begingroup$ Then isn't data already the table of {x,y}? Use ListLinePlot[data]? $\endgroup$ – eyorble May 9 '18 at 14:17
  • $\begingroup$ no, I have edited the post again for clarify $\endgroup$ – Joe May 9 '18 at 14:28
  • 4
    $\begingroup$ Generate the processed data using {#1, f[#1, #2]} & @@@ data then use ListPlot. $\endgroup$ – MarcoB May 9 '18 at 15:15
1
$\begingroup$

A simple solution is define f a little different than the way you show.

f[{x_, y_}] := {x, x y/(x^2 + y^2)}

With this definition,

data = {{1.35, 3.56}, {1.55, 4.78}, {1.76, 8.89}};
f /@ data

gives

{{1.35, 0.331537}, {1.55, 0.293415}, {1.76, 0.190508}}

$\endgroup$

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