Question

Need solution for question 5.6 using python?

tation to within e, 5.11 Determine the real root of x 80: (a) analytically and (b) with the false-position method to within e, = 2.5%. Use initial guesses of 2.0 and 5.0. Compute the estimated error Ea and the true error after each 1.0% teration 5.2 Determine the real root of (x) 5r - 5x2 + 6r -2 (a) Graphically (b) Using bisection to locate the root. Employ initial guesses of 5.12 Given x0 and and iterate until the estimated error eg falls (x) = _206 _ 1.5x4 + 10x + 2 below a level of ε,-10% 5.3 Determine the real root of (x)=-25 + 82x-90x2+ 44x 8r + 0.7x: (a) Graphically (b) Using bisection to determine the root to ε, 10%. Employ Use bisection to determine the maximum of this function. Emplo initial guesses ofx-0 and x, and perform iterations until the approximate relative error falls below 5%. 5.13 The velocity u of a falling parachutist is given by initial guesses of xi = 0.5 and x = 1.0 (c) Perform the same computation as in (b) but use the false-1) nm position method and ε = 0.2% 5.4 (a) Determine the roots of f(x) =-12-21x+ 18x2 2.75x graphically. In addition, determine the first root of the function c- 15 kgs, computethe mass m so that the velocity is v 36 m/s with (b) bisection, and (c) false position. For (b) and ( a a 10 s. Use the false-position method to determine m to a level guesses of x1--1 and Xu-0, and a stopping criterion of 1% 5.5 Locate the first nontrivial root of sin x- x where x is in radi ans. Use a graphical technique and bisection with the initial interval an 82-k from 0.5 to 1 . Perform the computation until ε is less than ε,-2%. where g -9.81 m/s. For a parachutist with a drag coefficient ofe, = 0.1% 5.14 Use bisection to determine the drag coefficient needed so that parachutist has a velocity of 36 m/s after 4 s of free fall Note: The acceleration of gravity is 9.81 m/s2. Start with initial by substituting your final answer into guesses of 3 and x5 and terate until the approximate relative error falls below 2%. Also perform an error check by sub- the original equation 5.6 Determine the positive real root of In () 0.7 (a) graphi- stituting your final answer into the original equation. cally, (b) using three iterations of the bisection method, with initial guesses of x 0.5 andx2, and (c) using three iterations of the discharged from a cylindrical tank through a long pipe can be false-position method, with the same initial guesses as in (b) 5.7 Determine the real root of f(x) (0.8- 0.3x)/x: (a) Analytically (b) Graphically (c) Using three iterations of the false-position method and initial As depicted in Fig. P5.15, the velocity of water, v (m/s), computed as 2L guesses of 1 and 3, Compute the approximate error εα and the true error ε, after each iteration. Is there a problem with

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

#include <windows.h> // SetConsoleCursorPosition(HANDLE,COORD)

#include <conio.h> // _getch()

/**

* moves the console cursor to the given x/y coordinate

* @param x

* @param y

*/

void moveCursor(int x, int y)

{

COORD c = {x,y};

SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);

}

int main()

{

// player data

int x = 3, y = 4;

char icon = 1;

// game state constants

const int RUNNING = 1, WIN = 2, LOST = 3, USER_QUIT = -1;

// game data

int width = 20, height = 15, input, state = RUNNING;

do

{

// draw the game world

moveCursor(0,0);

for(int row = 0; row < height; row++)

{

for(int col = 0; col < width; col++)

{

cout << '.';

}

cout << '\n';

}

// draw the player

moveCursor(x, y);

cout << icon;

// get input from the user (wait for one key press)

input = _getch();

// process input from the user

switch(input)

{

case 'w': y--; break; // move up

case 'a': x--; break; // move left

case 's': y++; break; // move down

case 'd': x++; break; // move right

case 27: state = USER_QUIT; break; // quit

}

// show the game state message

moveCursor(0, height+1);

switch(state)

{

case WIN: cout << "You WON! Congratulations!\n"; break;

case LOST: cout << "You lost...\n"; break;

}

}

while(state == RUNNING);

// user must press ESCAPE before closing the program

cout << "press ESCAPE to quit\n";

while(_getch() != 27);

return 0;

}

Add a comment
Know the answer?
Add Answer to:
Need solution for question 5.6 using python? tation to within e, 5.11 Determine the real root...
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
  • L. Determine the real root(s) off(x)--5xs + 14x3 + 20x2 + 10x a. Graphically on a graph paper. b....

    l. Determine the real root(s) off(x)--5xs + 14x3 + 20x2 + 10x a. Graphically on a graph paper. b. Using Bisection method c. Using False Position method to determine the root, employing initial guesses of x-2 d. Using the Newton Raphson methods to determine the root, employing initial guess to determine the root, employing initial guesses ofxn-2 and Xu-4 and Es= 18%. and r 5.0 andas answer. 1%. was this method the best for these initial guesses? Explain your xo--l...

  • Numerical methods. Need help please 2. Determine the real rot of f(x)--26+85x-91x+44x -8xx a. Graphically. b....

    Numerical methods. Need help please 2. Determine the real rot of f(x)--26+85x-91x+44x -8xx a. Graphically. b. Using bisection method. Employ initial guesses of x-O and xu 1 and iterate until the approximate error falls below 10%. Perform the same computation using false-position method. Iterate until the approximate error falls below 0.2%. c.

  • 6.5 Employ the Newton-Raphson method to determine a real root for 4x20.5 using initial guesses of...

    6.5 Employ the Newton-Raphson method to determine a real root for 4x20.5 using initial guesses of (a) 4.52 f(x) 15.5x Pick the best numerical technique, justify your choice and then use that technique to determine the root. Note that it is known that for positive initial guesses, all techniques except fixed-point iteration will eventually converge. Perform iterations until the approximate relative error falls below 2 %. If you use a bracket- ing method, use initial guesses of x 0 and...

  • using matlab code please 5.2 Determine the real root of f(x) = 5x? - 5x2 +...

    using matlab code please 5.2 Determine the real root of f(x) = 5x? - 5x2 + 6x-2: a. Graphically. b. Using bisection to locate the root. Employ initial guesses of x= 0 and xy = 1 and iterate until the estimated error &, falls below a level of Es = 10%.

  • (la) Determine the root of the x – ez* + 5 = 0 using the Newton-Raphson...

    (la) Determine the root of the x – ez* + 5 = 0 using the Newton-Raphson method with equation initial guess of xo = 1. Perform the computation until the percentage error is less than 0.03%. (1b) Employ bisection method to determine the root of the f(x)=x* – 3x + 7 =0) using equation two initial guesses of x; =-2.1 and x;, =-1.8 . Perform three iterations and calculate the approximate relative error for the third iteration. What is the...

  • 2) (15 points) a) Determine the roots of f(x)=-12 – 21x +18r? - 2,75x' graphically. In...

    2) (15 points) a) Determine the roots of f(x)=-12 – 21x +18r? - 2,75x' graphically. In addition, determine the first root of the function with b) bisection and c) false-position. For (b) and (c), use initial guesses of x, =-land x, = 0, and a stopping criterion of 1%. 3) (25 points) Determine the highest real root of f(x) = 2x – 11,7x² +17,7x-5 a) Graphically, b) Fixed-point iteration method (three iterations, x, = 3) c) Newton-Raphson method (three iterations,...

  • Problem 2 Determine the real roots of f(x)=-25 +82.x - 90x2 +44x-8x +0.7.x a) Graphically b)...

    Problem 2 Determine the real roots of f(x)=-25 +82.x - 90x2 +44x-8x +0.7.x a) Graphically b) Using bisection method to determine root (0.5, 1.0) 6 = 0.1 c) False position method, Use initial guesses of x=0.5 and x. -1.0 Compute the estimated errore, with stopping criteria 1%

  • 2. A comparative problem: Determine the highest real root of flx)-2x3-11.7x'+17.7x-5 You will achieve this by...

    2. A comparative problem: Determine the highest real root of flx)-2x3-11.7x'+17.7x-5 You will achieve this by performing 3 iterations of the following methods. In each case, calculate the approximate relative error at each iteration (a) The bisection method with starting guesses x 3 and u-4 (b) New Raphson method using Xo 3 as a starting guess. (c) Fixed point iteration usingx 3 as a starting guess but make sure that the method will work (see question 1.b above). (d) Which...

  • 3. Find the positive root of In(x²) = 0.7 20-points a) Using three iterations of the...

    3. Find the positive root of In(x²) = 0.7 20-points a) Using three iterations of the bisection method with initial guesses of Xi on method with initial guesses of x = 0.5 and Xu 2, and b) Using three iterations of the Secant method, with the same initial guesses as in .

  • Letermine the real root of f(x)= - 8x + 56x4x-7 a) Grophically to determine the root...

    Letermine the real root of f(x)= - 8x + 56x4x-7 a) Grophically to determine the root to b) using bsection &a=2%. Employ initial guesses of and xu = 8 xe=3 c) using the false-position method to determine the root to a 25% . Employ the some intials as in (b).

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