| Author |
Comment/Response |
Aaron Honecker
|
10/31/00 1:25pm
>Hello, >
>I would like to solve a function of two variables x and y and evaluate it over a range of values of x and y that I already have accumulated in lists. That is, I have separate lists of x and y values, but of equal length, and I want mathematica to substitute them into the function it generated.
>
>For example,
>
>Evaluate[Table[ f(x,y),{x, list of data for x}, {y, list of data for y}]];
>
>I don't know the syntax for {x, list of data for x} <-- I think that is wrong syntax if you want to supply values of x for a function to evaluate. Please let me know how I can specify input in this case. Thank you.
>
>Sincerely,
>Igor Barani
If you want to evaluate the function for all combinations of values for x and y you can use the following:
x = {x1, x2, x3, x4};
y = {y1, y2, y3};
Outer[f, x, y]
produces
{{f[x1, y1], f[x1, y2], f[x1, y3]},
{f[x2, y1], f[x2, y2], f[x2, y3]},
{f[x3, y1], f[x3, y2], f[x3, y3]},
{f[x4, y1], f[x4, y2], f[x4, y3]}}
URL: , |
|