Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, we are going to approximately compute the square root of 2, using a loop. The value you are looking for is a

In this assignment, we are going to approximately compute the square root of 2, using a loop. The value you are looking for is a value like: 1.41421 The computation will be done using something Computer Scientists call iteration. This public web page gives a full description of the basic processing.

** I'm pretty new to coding, especially in java script. I also don't have much knowledge around C++ programming. I really need help with how to set up the var and everything for this case problem. **

URL: https://www.macs.hw.ac.uk/~pjbk/pathways/cpp1ode124.html 4 Copyright 2017 by Robert W. Senser, Jr If math is not your claim to fame, here are the key items you will need to know:

The key formula needed is: new_app = (old_app + value/old_app)/2;

new_app is the approximation generated from old_app, the previous approximation The basic processing is shown in the following lines of C++ code, taken from the above web page:

tol = .0001 old_app = value;

// take value as first approximation new_app = (old_app + value/old_app)/2;

while (fabs((new_app-old_app)ew_app) > tol)

image text in transcribedimage text in transcribed{ old_app = new_app; new_app = (old_app + value/old_app)/2; }

These lines of C++ code are similar to JavaScript and form a model for the while loop you need to use. You will need to adjust these lines for use in JavaScript. Be sure to replace the C++ fabs() with JavaScripts Math.abs(). Again, you must change this code. For example, the value variable can be replaced by 2. Think about how the variables are declared. With Chrome, correct results from this HTML page and script might look like:

4/4 This homework problem does not have so many hints! C) The script you write will have the same style as those above. In this assignment, we are going to approximately compute the square root of 2, using a loop. The value you are looking for is a value like: 1.41421... The computation will be done using something Computer Scientists call "iteration". This public web page gives a full description of the basic processing. URL: https://www.macs.hw.ac.uk/pibk/pathways/cpp1ode124.html Copyright 2017 by Robert W. Senser, Jr If math is not your claim to fame, here are the key items you will need to know: The key formula needed is: new_app- (old_app value/old_app)/2; new_app is the approximation generated from old app, the previous approximation The basic processing is shown in the following lines of C++ code, taken from the above web page: tol .0001 old app value;//take value as first approximation new_app (old appvalue/old app)/2 while (fabs((new_app-old_app)ew_app)>tol) old_app new_app new_app (old_app+value/old _app)/2; These lines of C++ code are similar to JavaScript and form a model for the while loop you need to use. You will need to adiust these lines for use in JavaScript. Be sure to replace the C++ fabs() with JavaScript's Math.abs) Again, you must change this code. For example, the value variable can be replaced by 2. Think about how the variables are declared. With Chrome, correct results from this HTML page and script might look like: Example Progr y hw03q4.html | file:///F:/aaFRCC-17Spr | p, This page says: estimate of sqrt(2) is approximately 1.4142135623746899 Prevent this page from creating additional dialogs OK

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions

Question

advantages of software firewall

Answered: 1 week ago

Question

Can be relied on to do what they say they will do.

Answered: 1 week ago