c++ sequence calculator x_n+1 = f (x_n) = (1/7)∗((x_n^3)+2)Fibonacci sequence implementationGrade point average (GPA) calculatorCourse Grade CalculatorAlgebraic calculatorChange calculatorHackerRank: XOR-sequenceTerminal ESC Sequence DecoderSimple Calculator AppsBetter Fibonacci sequence calculationSigma calculator

What should you do if you miss a job interview (deliberately)?

Is it safe to use olive oil to clean the ear wax?

Why Shazam when there is already Superman?

Why should universal income be universal?

What are the purposes of autoencoders?

What does chmod -u do?

Must Legal Documents Be Siged In Standard Pen Colors?

How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?

On a tidally locked planet, would time be quantized?

Electoral considerations aside, what are potential benefits, for the US, of policy changes proposed by the tweet recognizing Golan annexation?

Where does the bonus feat in the cleric starting package come from?

Why is so much work done on numerical verification of the Riemann Hypothesis?

Is it better practice to read straight from sheet music rather than memorize it?

Not using 's' for he/she/it

C++ debug/print custom type with GDB : the case of nlohmann json library

The screen of my macbook suddenly broken down how can I do to recover

Reverse int within the 32-bit signed integer range: [−2^31, 2^31 − 1]

Offered money to buy a house, seller is asking for more to cover gap between their listing and mortgage owed

Fear of getting stuck on one programming language / technology that is not used in my country

Why is it that I can sometimes guess the next note?

Creepy dinosaur pc game identification

What prevents the use of a multi-segment ILS for non-straight approaches?

What was this official D&D 3.5e Lovecraft-flavored rulebook?

Non-trope happy ending?



c++ sequence calculator x_n+1 = f (x_n) = (1/7)∗((x_n^3)+2)


Fibonacci sequence implementationGrade point average (GPA) calculatorCourse Grade CalculatorAlgebraic calculatorChange calculatorHackerRank: XOR-sequenceTerminal ESC Sequence DecoderSimple Calculator AppsBetter Fibonacci sequence calculationSigma calculator













-1












$begingroup$


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.










share|improve this question









New contributor




ness is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$











  • $begingroup$
    ((n[i]) + 2)^2 does a bitwise XOR of ((n[i]+2) with 2, not exponentiation. However, this question is off-topic for Code Review because the code does not work as you intend.
    $endgroup$
    – esote
    2 hours ago











  • $begingroup$
    okay sorry about that. Tahnkyou so much for pointing out my error. Could you refer me to a site/stack exchange where I can get help with my code?
    $endgroup$
    – ness
    2 hours ago










  • $begingroup$
    editted to working code.
    $endgroup$
    – ness
    2 hours ago















-1












$begingroup$


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.










share|improve this question









New contributor




ness is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$











  • $begingroup$
    ((n[i]) + 2)^2 does a bitwise XOR of ((n[i]+2) with 2, not exponentiation. However, this question is off-topic for Code Review because the code does not work as you intend.
    $endgroup$
    – esote
    2 hours ago











  • $begingroup$
    okay sorry about that. Tahnkyou so much for pointing out my error. Could you refer me to a site/stack exchange where I can get help with my code?
    $endgroup$
    – ness
    2 hours ago










  • $begingroup$
    editted to working code.
    $endgroup$
    – ness
    2 hours ago













-1












-1








-1





$begingroup$


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.










share|improve this question









New contributor




ness is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




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.







c++






share|improve this question









New contributor




ness is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




ness is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 11 mins ago







ness













New contributor




ness is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 3 hours ago









nessness

11




11




New contributor




ness is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





ness is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






ness is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • $begingroup$
    ((n[i]) + 2)^2 does a bitwise XOR of ((n[i]+2) with 2, not exponentiation. However, this question is off-topic for Code Review because the code does not work as you intend.
    $endgroup$
    – esote
    2 hours ago











  • $begingroup$
    okay sorry about that. Tahnkyou so much for pointing out my error. Could you refer me to a site/stack exchange where I can get help with my code?
    $endgroup$
    – ness
    2 hours ago










  • $begingroup$
    editted to working code.
    $endgroup$
    – ness
    2 hours ago
















  • $begingroup$
    ((n[i]) + 2)^2 does a bitwise XOR of ((n[i]+2) with 2, not exponentiation. However, this question is off-topic for Code Review because the code does not work as you intend.
    $endgroup$
    – esote
    2 hours ago











  • $begingroup$
    okay sorry about that. Tahnkyou so much for pointing out my error. Could you refer me to a site/stack exchange where I can get help with my code?
    $endgroup$
    – ness
    2 hours ago










  • $begingroup$
    editted to working code.
    $endgroup$
    – ness
    2 hours ago















$begingroup$
((n[i]) + 2)^2 does a bitwise XOR of ((n[i]+2) with 2, not exponentiation. However, this question is off-topic for Code Review because the code does not work as you intend.
$endgroup$
– esote
2 hours ago





$begingroup$
((n[i]) + 2)^2 does a bitwise XOR of ((n[i]+2) with 2, not exponentiation. However, this question is off-topic for Code Review because the code does not work as you intend.
$endgroup$
– esote
2 hours ago













$begingroup$
okay sorry about that. Tahnkyou so much for pointing out my error. Could you refer me to a site/stack exchange where I can get help with my code?
$endgroup$
– ness
2 hours ago




$begingroup$
okay sorry about that. Tahnkyou so much for pointing out my error. Could you refer me to a site/stack exchange where I can get help with my code?
$endgroup$
– ness
2 hours ago












$begingroup$
editted to working code.
$endgroup$
– ness
2 hours ago




$begingroup$
editted to working code.
$endgroup$
– ness
2 hours ago










0






active

oldest

votes











Your Answer





StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
);
);
, "mathjax-editing");

StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "196"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






ness is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216078%2fc-sequence-calculator-x-n1-f-x-n-1-7%25e2%2588%2597x-n32%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes








ness is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















ness is a new contributor. Be nice, and check out our Code of Conduct.












ness is a new contributor. Be nice, and check out our Code of Conduct.











ness is a new contributor. Be nice, and check out our Code of Conduct.














Thanks for contributing an answer to Code Review Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216078%2fc-sequence-calculator-x-n1-f-x-n-1-7%25e2%2588%2597x-n32%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

瀋陽號驅逐艦 目录 接收與服役 配置反潛直升機 武進三型性能升級 歷史 除役 參考資料 外部連結 导航菜单Taiwan Air Power海疆老兵-陽字號驅逐艦沿革World Navies Today: Taiwan (Republic of China)DD-839 USS POWER

波兰旗帜列表 目录 国旗 军旗 其他制服部门旗帜 特别国家机构船只 参考文献 外部链接 导航菜单Polskie flagi, chorągwie, bandery... [波兰旗帜、条幅、船旗等]原始内容Ustawa z dnia 31 stycznia 1980 r. o godle, barwach i hymnie Rzeczypospolitej Polskiej oraz o pieczęciach państwowychZarządzenie Ministra Obrony Narodowej z dnia 14 grudnia 2005 r. zmieniające zarządzenie w sprawie szczegółowych zasad używania znaków Sił Zbrojnych Rzeczypospolitej Polskiej oraz ustalenia innych znaków używanych w Siłach Zbrojnych Rzeczypospolitej PolskiejZarządzenie Ministra Obrony Narodowej z dnia 29 stycznia 1996 r. w sprawie szczegółowych zasad używania znaków Sił Zbrojnych Rzeczypospolitej Polskiej oraz ustalenia innych znaków używanych w Siłach Zbrojnych Rzeczypospolitej PolskiejUstawa z dnia 19 lutego 1993 r. o znakach Sił Zbrojnych Rzeczypospolitej PolskiejHistoria Marynarki Wojennej RP [波兰海军史]Rozporządzenie Ministra Spraw Wewnętrznych i Administracji z dnia 12 kwietnia 2002 r. w sprawie wzoru flagi oraz oznakowania jednostek pływających i statków powietrznych Straży GranicznejRozporządzenie Ministra Spraw Wewnętrznych i Administracji z dnia 18 kwietnia 2005 r. w sprawie wzoru flagi oraz oznakowania jednostek pływających i statków powietrznych PolicjiRozporządzenie Ministra Infrastruktury z dnia 21 października 2005 r. w sprawie wzorów flag dla statków morskich na oznaczenie pełnionej specjalnej służby państwowej oraz okoliczności i warunków ich podnoszenia波兰旗帜波兰

Indenting and Dedenting ASP code with Python