Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer in C language You will face different kinds of equations you need to solve in your engineering life. Unfortunately, you may not know how

Answer in C language

image text in transcribed

You will face different kinds of equations you need to solve in your engineering life. Unfortunately, you may not know how to solve all of them. As an engineer, you will use numerical methods to approximate the solution. There are tons of numerical methods to find the root of an equation like the bisection method, secant method, false position method, etc. Today we are going to implement a famous method named Newton's method. The idea is simple. Suppose we are going to find a real root of a continuous function f(x), and we assume the derivative f(x) exists for all real x. Given an initial guess x0, if it is not a root, we can find the tangent line at that point. The equation of the tangent is y=f(x0)x+c, and we can solve c by c=f(x0)f(x0)x0. So we have y=f(x0)(xx0)+f(x0). The next guess x1 is the x-intercept of this tangent line. That is 0=f(x0)(x1x0)+f(x0), which gives x1=x0f(x0)f(x0). We can repeat the procedure until we solve f(x) or we get a close enough solution. From the above you can see the method will fail under some conditions like f(xn)=0 for some n. In fact you need to have an initial guess "close enough" to the root to ensure the method converges. But in practice you won't know the range of the initial guesses which work. So we need to fix a maximum number of iterations, i.e., after a fixed number of steps we will stop. Sometimes it may only improve a bit if you try more iterations, so we can stop the method if the change between two iterations is too small. Task: Find all (approximated) roots of the cubic equation ax3+bx2+cx+d=0, where the coefficients are all real and read from user input. Apply Newton's method to find a real root, and then do polynomial division to get a quadratic equation for solving the remaining (may be real or complex) roots. More to think: (This is a maths problem) Do you know how to solve a cubic equation without using numerical methods? How to implement that using C

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions