Iterative Function with Last 10 Values for Any Input Constant K

In summary, you want to iterate a function f(x) = x^7+k 50 times, starting from x0=1, and store the last 10 values in a table.
  • #1
peter.a
21
0
say I have a function f(x)=x^7+k
I want to iterate x(n+1)=f(xn), 50 times
starting with x0=1
and keep the last 10 values
i want to assigh these values to some function''y'' and be able to use y to calculate this iteration for any input constant K. ie say K=0, K=0.5 etc, and then i want to store these values for different values of constants?Is this possible?I can't figure it out

i have tried this far
f:=x^7+k
y:=Take[NestList[f, 0, 50], -10]
 
Physics news on Phys.org
  • #2
In[1]:= f[x_]:=x^7+k;y=Take[NestList[f,x,50],-10]

And then

In[3]:= y/.k->0.5
 
  • #3
Could you explain to me how it works, so i can apply it to other functions, when i try and use thje code for a different function f i get errors?
 
  • #4
Do you have a specific example that does not work?

"I typed some stuff in, some stuff came out, some stuff is wrong, what do I do?" is extremely difficult to provide an answer for.

In[1]:= f[x_]:=Sin[x];y=NestList[f,x,5]

Out[1]= {x, Sin[x], Sin[Sin[x]], Sin[Sin[Sin[x]]], Sin[Sin[Sin[ Sin[x]]]], Sin[Sin[Sin[Sin[Sin[x]]]]]}

In[2]:= f[x_]:=1/(x+1);y=NestList[f,x,5]

Out[3]= {x, (1 + x)^(-1), (1 + (1 + x)^(-1))^(-1), (1 + (1 + (1 + x)^(-1))^(-1))^(-1), (1 + (1 + (1 + (1 + x)^(-1))^(-1))^(-1))^(-1), (1 + (1 + (1 + (1 + (1 + x)^(-1))^(-1))^(-1))^(-1))^(-1)}
 
  • #5
Hi Bill
This is exactly what I am stuck on;

I have a function as follows defined;

f[a_][x_] := x^2 + a;
Then i define
w[a_] := Take[NestList[f[-1.8], 0, 1000], 100]
Similar to what you mentioned in the previous post

Now i want to evaluate this for different values of the constant a from -1.8, to 0.3, store the results in a table, supress the results because they will be very long, and then make a plot of "a" versus x using listplot.

I cannot figure it out.
 
  • #6
To be honest, in a way I think you are torturing the Mathematica code. By that I mean that I think you may be reading the documentation and trying to interpret it in a way to get where you want to go, but I think you are using it in a rather unconventional way. That is often a recipe for problems.

For example, rarely do you see someone write "I have a Mathematica function of 2 variables f[x][y]. The untortured version of that would be f[x,y]. But perhaps you have good reasons, some or even lots of experience and understand the deep reasons why you are writing this the way you are.

You are also using vast deep nestlists and then discarding much of this. Are you sure you understand that nesting something 1000 levels deep may end up with thousand digit coefficients and polynomials to degrees in the thousands?

What do you REALLY want to accomplish? Forget Mathematica for a moment. What are you REALLY trying to get at? Maybe with that information it would be possible to do something much simpler to get you where you want to go.
 
  • #7
Must have been a double mouse click, sorry.
 
  • #8
It is also possible that the forum may go down for a little while about this time of night. If you don't get a quick reply please realize that might be the reason.
 
  • #9
Yeah it wasn't working for a bit and i double posted as well. In answer to your question i am new to mathematica and am just practising working through different things. I am following what i see in the online tutorials for the most part.
 
  • #10
Ah... that explains some things.

If you can get your hands on them then there have been a variety of books published in the past that try to walk the reader through beginning to understand the mental model behind programming in Mathematica. It isn't impossible to learn this using only the help system, but I think that would be more difficult. "Mathematica Navigator" seems like a fairly good book for this. The older editions are for earlier versions of Mathematica and even the latest one hasn't caught up with the last features, but any edition might be a good introduction if you know just enough to watch out for small incompatibilities.
 

1. What is the purpose of Mathematica function help?

The purpose of Mathematica function help is to provide users with information about the various functions available in Mathematica, including their syntax, options, and examples of usage. This can help users understand how to use the functions effectively in their code.

2. How do I access Mathematica function help?

To access Mathematica function help, simply type the name of the function followed by a question mark (?) in the Mathematica input bar. This will open a help window with information about the function.

3. Can I search for specific functions in Mathematica function help?

Yes, you can search for specific functions in Mathematica function help by using the search bar located in the help window. You can also use the search bar in the online version of Mathematica function help.

4. How often is Mathematica function help updated?

Mathematica function help is updated regularly with each new release of Mathematica. This ensures that the information provided is accurate and up-to-date with the latest version of the software.

5. Are there any additional resources for understanding Mathematica function help?

Yes, in addition to the built-in help feature, there are also online resources such as the Wolfram Documentation Center and community forums where users can find tutorials, examples, and discussions about Mathematica functions and their usage.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
119
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
553
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
18
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
247
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
910
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
Back
Top