Question

Using MATLAB: 22/7 is a commonly used fraction that estimates pi. Unfortunately it is not very accurate. Using a maximum...

Using MATLAB: 22/7 is a commonly used fraction that estimates pi. Unfortunately it is not very

accurate. Using a maximum of three digits in the numerator and denominator, find

the fraction that is the closest approximation to pi. Have the computer output the

numerator, denominator, and the true percent error

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

clear, clc
num=1;
den=1;
min=10;
for i=1:1000
for j=1:1000
if(abs(i/j-pi)<min)
min=abs(i/j-pi);
num=i;
den=j;
end
end
end
fprintf('Fraction is %d/%d, true percent error=%.4e\n',num,den,abs(num/den-pi)/pi*100)

MATLAB R2018a Search Documentation Log In НOME PLOTS APPS EDITOR PUBLISH VEW Insert fx Find Files Run Section Go To Compare C

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Using MATLAB: 22/7 is a commonly used fraction that estimates pi. Unfortunately it is not very accurate. Using a maximum...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hello, on the Hackerrank coding challenges there was one called Minimal Distance to Pi. it is classified as hard. I was...

    Hello, on the Hackerrank coding challenges there was one called Minimal Distance to Pi. it is classified as hard. I was wondering how I can code it in Python? thank you 9:14イ Done 1 of 30 Minimal Distance to Pi ☆ Points: 1262.07 Rank: 605 Problem Submissions Leaderboard Ed Given two long integers, min and maz. find and print a common fraction,. such that min ^ d S maz and T is minimal (recall that 3. 1415926535 8979323846 2643383279 5028841971...

  • in matlab sthat this n is hardly different from the scalar version in Section 4.3 . The root estimates are stored as columns in an array . The Newton step is calculated using a backslash. The fu...

    in matlab sthat this n is hardly different from the scalar version in Section 4.3 . The root estimates are stored as columns in an array . The Newton step is calculated using a backslash. The function norm is used for the magnitude of a vector, instead magnitude of a scalar. Function 4.5,1 (netonsys) Newron's method for a system of equations function x=newtonsys (f,x1) 2 % NETONSYS Newton's method for a system of equations 3 % Input : function that...

  • IN JAVA PLEASE HELP! ALSO PLEASE ADD COMMENTS Summary Build two classes (Fraction and Fraction Counter)...

    IN JAVA PLEASE HELP! ALSO PLEASE ADD COMMENTS Summary Build two classes (Fraction and Fraction Counter) and a Driver for use in counting the number of unique fractions read from a text file. We'll use the ArrayList class to store our list of unique Fraction Counters. Rather than designing a monolithic chunk of code in main like we did in the previous homework, we'll practice distributing our code into containers (called classes) that you will design specifically to tackle this...

  • Lab 1.java only Goal: This lab will give you experience with defining and using classes and...

    Lab 1.java only Goal: This lab will give you experience with defining and using classes and fields, and with conditionals and recursive functions. Getting Started --------------- Read the Fraction.java class into a text editor and compile it filling in the command javac -g Fraction.java. The program should compile without errors. In a shell window, run the program using "java Fraction". The program should run, although it will print fractions in a non-reduced form, like 12/20. Part I: Constructors (1 point)...

  • MATLAB Create a function that provides a definite integration using Simpson's Rule Problem Summar This example demo...

    MATLAB Create a function that provides a definite integration using Simpson's Rule Problem Summar This example demonstrates using instructor-provided and randomized inputs to assess a function problem. Custom numerical tolerances are used to assess the output. Simpson's Rule approximates the definite integral of a function f(x) on the interval a,a according to the following formula + f (ati) This approximation is in general more accurate than the trapezoidal rule, which itself is more accurate than the leftright-hand rules. The increased...

  • X Part I. Derive Bivariate Regression by hand. Again, we are using the same data set that we used in the in-cl...

    X Part I. Derive Bivariate Regression by hand. Again, we are using the same data set that we used in the in-class assessment. Case Dietary Fat Body Fat 22 9.8 22 11.7 14 8.0 21 9.7 32 10.9 26 7.8 30 21 17 1. Step 1: Find the mean of dietary fat x = 2. Step 2: Find the mean of body fat y = 3. Step 3: Find the sum of (x1 - x)y- y) = 3316 4. Step...

  • please help with no 3,4,5 and 6 Thanks 1. What is standard error? Measure of statistical...

    please help with no 3,4,5 and 6 Thanks 1. What is standard error? Measure of statistical accuracy of an estimate, equal to the standard deviation of the theorental distribution of a large populanon of such estimates 2. What calculation is used to describe the variation in measurements. 3. In experiment 3.2. You will be measuring out 40ml of volume. How many times will you measure 40 ml? 4. What is the difference for each time you measure out 40ml? In...

  • 13) The cost the Almy type of market 7) The market is an example of A)...

    13) The cost the Almy type of market 7) The market is an example of A) mattress: a monopoly B) com a perfectly competitive C) car insurance an oligopoly D) cell phone; a perfectly competitive 5) airplane manufacturing a monopolistically competitive 8) What is the difference between perfect competition and monopolistic competition? A) Perfect competition has a large number of small firms while monopolistic competition does not in monopolistic competition, firms produce identical goods, while in perfect competition, firms produce...

  • 18.1 Lab Lesson 11 (Part 1 of 1) Part of lab lesson 11 There in one...

    18.1 Lab Lesson 11 (Part 1 of 1) Part of lab lesson 11 There in one part to lab lesson 11. The entire lab will be worth 100 points. Lab lesson 11 part 1 is worth 100 points For part 1 you will have 80 points if you enter the program and successfully run the program tests. An additional 20 points will be based on the style and formatting of your C++ code. Style points The 20 points for coding...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT