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

名間水力發電廠 目录 沿革 設施 鄰近設施 註釋 外部連結 导航菜单23°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.7113923°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.71139計畫概要原始内容臺灣第一座BOT 模式開發的水力發電廠-名間水力電廠名間水力發電廠 水利署首件BOT案原始内容《小檔案》名間電廠 首座BOT水力發電廠原始内容名間電廠BOT - 經濟部水利署中區水資源局

Prove that NP is closed under karp reduction?Space(n) not closed under Karp reductions - what about NTime(n)?Class P is closed under rotation?Prove or disprove that $NL$ is closed under polynomial many-one reductions$mathbfNC_2$ is closed under log-space reductionOn Karp reductionwhen can I know if a class (complexity) is closed under reduction (cook/karp)Check if class $PSPACE$ is closed under polyonomially space reductionIs NPSPACE also closed under polynomial-time reduction and under log-space reduction?Prove PSPACE is closed under complement?Prove PSPACE is closed under union?

Is my guitar’s action too high? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Strings too stiff on a recently purchased acoustic guitar | Cort AD880CEIs the action of my guitar really high?Μy little finger is too weak to play guitarWith guitar, how long should I give my fingers to strengthen / callous?When playing a fret the guitar sounds mutedPlaying (Barre) chords up the guitar neckI think my guitar strings are wound too tight and I can't play barre chordsF barre chord on an SG guitarHow to find to the right strings of a barre chord by feel?High action on higher fret on my steel acoustic guitar