c++ sequence calculator x_{n+1} = f (x_n) = (1/7)∗((x_n^3)+2) [on hold]

example of code

#include <iostream> using namespace std; //whitespace package #include <iomanip> #include <math.h> using std::setw;  int main () {      // n is an array of 101 integers     long double n[ 101 ];     double exponent=3;     double fraction=1.0/7;      // initialize elements of array n to 0     for ( int i = 1; i < 100; i++ ) {         n[ i ] =  0;     }      //what is input 1?     cout << "Enter x_1" << endl;     cin >> n[1];      //jam ni's into function and loop     for ( int i = 1; i < 100; i++ ) {      // set element at location i+1 to f(x)= (fraction)*((x)^exponent + 2)     n[ i + 1 ] =  fraction*(pow( ((n[ i ]) ), exponent ) + 2);     }      //header     cout << "Element" << setw( 13 ) << "Value" << endl;      // output each array element's value     for ( int j = 1; j < 100; j++ ) {         cout << setw( 7 )<< j << setw( 13 ) << n[ j ] << endl;     }      return 0; } 

output

Element        Value       1            1       2            0.42857142857       3            0.29695960016       4            0.2894553405       5            0.28917883433       6            0.28916891514       7            0.28916855966 

background: I’m trying to write a simple program that asks what your $ x_1$ is and reports $ x_1$ to $ x_{100}$ given some series function calculator–like a sequence calculator where $ x_{n+1} = f(x_n)$ . In this example, our function is (1/7)*((x)^3 + 2).

Can you all offer some resources for writing other functions? I have $ x_{n+1}=f(x_n)=(1/7)*((x_n^3)+2)$ right now.

Whenever I look up c++ math functions I get things like how to use the absolute value function, or how to use my cpp file as a function itself, but not information on writing math functions like this.