Program to Generate Sequence of x Values using Next Function, Exercises of Mathematics

A c++ program that calculates the sequence of x values using the next function. The next function returns the square root of (3*(1+x)/x). The program initializes x with a value of 2 and prints the first and last values of the sequence after calculating 20 terms. The document also mentions the expression for xn+2 but does not provide the calculation. This program could be useful for students studying advanced mathematics, particularly those interested in sequences and recursive functions.

Typology: Exercises

2020/2021

Uploaded on 10/11/2022

amihamilarum777
amihamilarum777 🇮🇳

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
(1)
The values for the asked x's are given together:
Program to generate this:
#include<iostream>
#include<cmath>
usingnamespacestd;
//methodtogetnextxvalue
doublenext(doublex)
{
returnsqrt((3*(1+x))/x);
}
intmain()
pf2

Partial preview of the text

Download Program to Generate Sequence of x Values using Next Function and more Exercises Mathematics in PDF only on Docsity!

The values for the asked x's are given together: Program to generate this: #include #include using namespace std; // method to get next x value double next(double x) { return sqrt((3*(1+x))/x); } int main()

// set initial value double x0 = 2; // loop 20 times for(int i=1; i<=20; i++) { // get next x double xn = next(x0); // if it is 1st or 20th term, print it if(i==1 || i == 20) cout << "i = " << i << " \t xi = " << xn << endl; // update x x0 = xn; } } Now, the expression for xn+2 is: As showing every step is not possible here, just the final result is given. (2) These are the values of the ordered x and y at i = 3 and 4