1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ludmilkaskok [199]
4 years ago
6

Write a program (using a loop) that determines the expression. Run the program with n = 1:10, n=1:1,000, n = 1:100,000. Compare

the results with pi function. (use Format long)
Computers and Technology
1 answer:
prisoha [69]4 years ago
7 0

The question is incomplete! The complete question along with Matlab code and explanation is provided below!  

Question:

The value of pi can be estimated by: √6*∑1/n² from n=1 to n=∞

Write a program (using a loop) that determines the expression. Run the program with n= 1:10, n=1:1,000, n= 1:100,000. Compare the results with pi function. (use Format long)

Explanation:

We implemented a summation series that approximates the value of pi. The value of pi approaches to the real value of pi as n gets larger. we calculated the value of pi using a for loop with n= 10, n=1,000, and n= 100,000 then compared this value with the value of built-in function of Maltab pi. The results are discussed below.

Matlab Code:

format long

n = 100000;

sum = 0;

for k=1:n

   sum = sum + 1/k^2;

end

value = sqrt(6*sum)

pi

diff = pi - value

Output:

For n = 10:

pi =    3.141592653589793

value =  3.049361635982070

diff =    0.092231017607723

For n = 100:

pi =    3.141592653589793

value =  3.140638056205995

diff =     0.000954597383798

For n = 100,000:

pi =    3.141592653589793

value =    3.141583104326456  

diff =      0.000009549263336

As you can see the difference between real and calculated value of pi is quite large for n = 10 but the difference is very small for n = 100,000. The calculated value is correct up to 4 decimal digits for n = 100,000.

You might be interested in
Difference between video game laser and projectile
jonny [76]
The laser is similar to the hitscan system. It moves quickly, so as soon as you shoot, the laser will instantly travel and hit the target where you aim. On the other hand, a projectile will travel to the target over time, meaning you have to account for the projectile dropping over that distance (and aim higher, in front of the target, etc.) to make sure you land the hit.
3 0
4 years ago
Most colleges require blank years of foriegn language for admission
Sladkaya [172]

They require about 4 years of foreign language if you want to learn more afterwards then it is another 2 years or 3.

3 0
4 years ago
Technician A says that automotive engine blocks are usually classified by the number of cylinders the block. Technician B says t
viva [34]
<span>A. Both Technicians A and B is the answer</span>
8 0
4 years ago
Write a program to find a peak in an array of ints. Suppose the array is {-1, 0, 2, 5, 6, 8, 7}. The output should be "A peak is
Sergeeva-Olga [200]

Answer:

Following are the code to this question:

#include<iostream>//declaring header file  

using namespace std;

int main()//main method

{

int n= 6,j=0;//declaring integer variable

int X[n];//defining an array

for(j=0;j<=n;j++)//defining a loop for input value

cin>>X[j];//input value from the user

if(j==0) //defining if block that checks value at beginning

{

if(X[j]>=X[j+1])//defining if block to check to compare first and second value  

{

cout<<"A peak is at array index "<<j<<" and the value is "<<X[j];//use print method to largest value with index number  

}

}

else//defining else block

{

for(j=0;j<=n;j++)//defining for loop for compare other value

{

if(j==n-1) //use if block that checks next index  

{

if(X[j]>=X[j-1])//use if block to compare value  

cout<<"A peak is at array index "<<j<<" and the value is "<<X[j];//use print method to largest value with index number

}

else

{

if(X[j]>=X[j-1] && X[j]>=X[j+1])//comapre value

cout<<"A peak is at array index "<<j<<" and the value is "<<X[j];//use print method to largest value with index number

}

}

}

return 0;

}

Output:

please find the attached file.

Explanation:

In the given code, inside the main method two integer variable "n and j", is declared, in the next step, an array "x"is defined which input the value from the user end.

  • In the next step, multiple if block is used, in the first if block it comapre the first and second value if it grater then it will print the value with its index number.
  • In the next if block, it comapre is next value and if it grater then it will print the value with its index number.  

5 0
3 years ago
What methods do you use when researching a complicated or difficult subject? What tools are most useful to narrowing down and va
dlinn [17]
You use observation and take down notes of what is going on, you then record your notes and use this to help u further your research
5 0
3 years ago
Other questions:
  • In Python
    15·1 answer
  • What happens when a returntype, even void, is specified as a constructor in Java?
    14·1 answer
  • Tom is required to present the activities of his Nature club each month to the school committee. Which presentation element can
    12·2 answers
  • What entity created the open systems interconnection (osi) seven-layer model?
    15·1 answer
  • Acts as a platform on which application software runs?
    6·1 answer
  • What are the correct steps to find the system specifications such as the amount of RAM or system type?
    13·1 answer
  • What is the most likely reason that a digital artist would use a program such as Autodesk Maya or Max to create 3-D images for a
    12·1 answer
  • Which statement gives an advantage of multicellular organisms?
    7·2 answers
  • WHAT DO YOU LEARN IN CODE.ORG​
    11·1 answer
  • HTML, the markup language of the web, specifies colors using the RGB model. It uses a two-digit hexadecimal (that is, base 16) r
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!