c++ sequence calculator x_n+1 = f (x_n) = (1/7)∗((x_n^3)+2)Edit Distance Between Two StringsEdit distance functionA working stack allocator“Edit distance” UVA programming challengeCourse Grade CalculatorCode that calculates Hailstone Sequence of input numbers, and code that calculates the number with the largest Hailstone sequence smaller than `z`Change calculatorHackerRank: XOR-sequenceSimple Calculator AppsSigma calculator

How much character growth crosses the line into breaking the character

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

What should you do when eye contact makes your subordinate uncomfortable?

Longest common substring in linear time

Is there a name for this algorithm to calculate the concentration of a mixture of two solutions containing the same solute?

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

Store Credit Card Information in Password Manager?

How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?

How to indicate a cut out for a product window

Why did the EU agree to delay the Brexit deadline?

Why did the Mercure fail?

Are the IPv6 address space and IPv4 address space completely disjoint?

Is the U.S. Code copyrighted by the Government?

Multiplicative persistence

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

Not using 's' for he/she/it

Pre-mixing cryogenic fuels and using only one fuel tank

How should I respond when I lied about my education and the company finds out through background check?

Freedom of speech and where it applies

Can I sign legal documents with a smiley face?

Melting point of aspirin, contradicting sources

Is this toilet slogan correct usage of the English language?

Yosemite Fire Rings - What to Expect?

Must Legal Documents Be Siged In Standard Pen Colors?



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


Edit Distance Between Two StringsEdit distance functionA working stack allocator“Edit distance” UVA programming challengeCourse Grade CalculatorCode that calculates Hailstone Sequence of input numbers, and code that calculates the number with the largest Hailstone sequence smaller than `z`Change calculatorHackerRank: XOR-sequenceSimple Calculator AppsSigma 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 5 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

कुँवर स्रोत दिक्चालन सूची"कुँवर""राणा कुँवरके वंशावली"

Why is a white electrical wire connected to 2 black wires?How to wire a light fixture with 3 white wires in box?How should I wire a ceiling fan when there's only three wires in the box?Two white, two black, two ground, and red wire in ceiling box connected to switchWhy is there a white wire connected to multiple black wires in my light box?How to wire a light with two white wires and one black wireReplace light switch connected to a power outlet with dimmer - two black wires to one black and redHow to wire a light with multiple black/white/green wires from the ceiling?Ceiling box has 2 black and white wires but fan/ light only has 1 of eachWhy neutral wire connected to load wire?Switch with 2 black, 2 white, 2 ground and 1 red wire connected to ceiling light and a receptacle?

चैत्य भूमि चित्र दीर्घा सन्दर्भ बाहरी कडियाँ दिक्चालन सूची"Chaitya Bhoomi""Chaitya Bhoomi: Statue of Equality in India""Dadar Chaitya Bhoomi: Statue of Equality in India""Ambedkar memorial: Centre okays transfer of Indu Mill land"चैत्यभमि