Solving a Mathematica Function of 2 Variables w/ Nestlist

  • Mathematica
  • Thread starter peter.a
  • Start date
  • Tags
    Mathematica
In summary, a user is trying to repeat a process with different values and store the results in a table for later plotting. The expert suggests using the Table function in Mathematica and using ListPlot to visualize the relationship between the x and y values.
  • #1
peter.a
21
0
I have a function of two variables

f[x_][y_]=x^2+y;

d=Take[NestList[f[-2],0,10],-2];

now i want to repeat this process by changing -2 to -1.99, then -1.98 all the way up to 0
and storing values in a table, so i can later make a plot. I can't figure out how to repeat this process.
 
Physics news on Phys.org
  • #2
data = Table[Take[NestList[f, 0, 10], -2], {i, -2, 0, 0.01}]
 
  • #3
Thts amazing! I am a bit intimidated by the fact you did in 2 seconds what i have been working on for the better part of an hour.
Thanks.
can you tell me how i can plot this stored data using ListPlot ? to see what the relationship is between x and the y values
 
  • #4
Whoops hit post 2 times!
 
  • #5
Is "ListPlot[data]" not what you're looking for?

And don't be intimidated, if you start using Mathematica a lot, Tables are a MAJOR component to using it well.
 

1. How do I use the Nestlist function in Mathematica to solve a function of 2 variables?

To use the Nestlist function in Mathematica, you need to first define your function and its initial values for each variable. Then, you can use the Nestlist command with the function and the initial values as arguments. This will generate a list of values as the function is iteratively applied to the initial values.

2. Can I nest multiple functions in Nestlist to solve a more complex problem?

Yes, you can nest multiple functions in the Nestlist command to solve a more complex problem. Simply define each function and its initial values, and then use them as arguments in the Nestlist command. The result will be a nested list of values that reflects the application of each function in sequence.

3. Is it possible to specify a range of values for each variable in Nestlist?

Yes, you can specify a range of values for each variable by using the Range command within the Nestlist function. This will generate a list of values for each variable, which can then be used as the initial values for the Nestlist command.

4. How do I plot the results of a Nestlist function in Mathematica?

To plot the results of a Nestlist function in Mathematica, you can use the ListPlot command with the output of the Nestlist function as the argument. This will generate a graph of the values over the iterations. You can also use the Plot command to visualize the function itself.

5. Can I use Nestlist to solve differential equations with 2 variables?

Yes, you can use the Nestlist function to solve differential equations with 2 variables. Simply define your differential equation as a function, specify the initial values for each variable, and then use the Nestlist command to generate a list of values that approximate the solution to the differential equation.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
238
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
203
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
110
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
925
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
Back
Top