Question

In: Advanced Math

Design a Root Finding solver in Matlab that satisfies the arguments below; • Inputs will be...

Design a Root Finding solver in Matlab that satisfies the arguments below;
• Inputs will be coeficients of the equation.
• Outputs will be roots
• It should work with any polynomial
?=?0+?1?1+?2?2+?3?3+⋯+????

Solutions

Expert Solution

The below function gives you the roots of the any polynomial equation which is in the form of  p1xn+...+pnx+pn+1=0.

Polynomial equations contain a single variable with nonnegative exponents.

r = roots(p) ------------- Predefined matlab function.

Where r is the root of the equation.

p is the column vector, which is the list of coeficients.

Case 1:

For example, create a vector to represent the polynomial x2−x−6, then calculate the roots.

p = [1 -1 -6];
r = roots(p)
r =

     3
    -2

By convention, matlab returns the roots in a column vector.

The poly function converts the roots back to polynomial coefficients.

p2 = poly(r)
p2 =

     1    -1    -6

Case 2:

for a quadratic polynomial x4−1=0.

p = [1 0 0 0 -1];
r = roots(p)
r = 4×1 complex

  -1.0000 + 0.0000i
   0.0000 + 1.0000i
   0.0000 - 1.0000i
   1.0000 + 0.0000i

Case 3 :

For example, find the values of θ that solve the equation.

3cos2(θ)−sin(θ)+3=0.

Use the fact that cos2(θ)=1−sin2(θ) to express the equation entirely in terms of sine functions:

−3sin2(θ)−sin(θ)+6=0.

Use the substitution x=sin(θ) to express the equation as a simple polynomial equation:

−3x2−x+6=0.

p = [-3 -1 6];
r = roots(p)
r = 
    -1.5907
    1.2573

To resolve the substitution, use θ=sin−1(x). The asin function calculates the inverse sine.

theta = asin(r)
theta = 

  -1.5708 + 1.0395i
   1.5708 - 0.7028i

Related Solutions

Write a Matlab function for: 1. Root Finding: Calculate the root of the equation f(x)=x^3 −5x^2...
Write a Matlab function for: 1. Root Finding: Calculate the root of the equation f(x)=x^3 −5x^2 +3x−7 Calculate the accuracy of the solution to 1 × 10−10. Find the number of iterations required to achieve this accuracy. Compute the root of the equation with the bisection method. Your program should output the following lines: • Bisection Method: Method converged to root X after Y iterations with a relative error of Z.
What are the advantages of importing inputs from Matlab and exporting outputs to the Matlab Workspace?...
What are the advantages of importing inputs from Matlab and exporting outputs to the Matlab Workspace? (Select all that apply). a. Simulation results can be analyzed further in Matlab. b. You can drag blocks from the Simulink Library Browser into the Matlab Workspace. c. You can import actual physical data into your model. d. Simulation results can be visualized with a wide variety of Matlab plotting functions.
Write a user defined MATLAB program that performs power factor correction. The inputs to the MATLAB...
Write a user defined MATLAB program that performs power factor correction. The inputs to the MATLAB function should be voltage across the load (in Vrms, assume 0 phase), frequency Resistance of the load Inductance of the load power factor of the load target power factor The output of the function should be the size of the capacitor that one would need to place in parallel with the load to reach the target power factor. Please submit the code for the...
Write a MATLAB function named myaccel that accepts three inputs and has a single output. Inputs:...
Write a MATLAB function named myaccel that accepts three inputs and has a single output. Inputs: a list of time values a list of position values a single time value. Output: a single number which is obtained by numerically differentiating position with respect to time twice (forward difference method) and then interpolating the results based on the third input. Example: time=0:10; position=time.^3; myaccel(time,position,2.8) % should return 22.8
Create a Linear Program solver using Matlab or Python. Prompt variable and constraint entry.
Create a Linear Program solver using Matlab or Python. Prompt variable and constraint entry.
write the code in MATLAB with comments and show the inputs and results of the code...
write the code in MATLAB with comments and show the inputs and results of the code for the question below. Write an .m file in MATLAB, that records audio (you can record your own voice for 20 seconds that was recorded using your phone), then take Fourier transform of the signal (probably FFT).
Matlab code fr natural frequency of lateral vibration of beams...using PDE solver method
Matlab code fr natural frequency of lateral vibration of beams...using PDE solver method
The Ostrowski method for finding a single root of ?(?)=0 is given by Initial guess ?0...
The Ostrowski method for finding a single root of ?(?)=0 is given by Initial guess ?0 ??=??−?(??)?′(??), ??+1=??−?(??)?′(??) ?(??)?(??)−2?(??). a) Write MATLAB or OCTAVE coding to implement the Ostrowski method. (Hint: You may use the coding of Newton Method given in Moodle pages) b) Use your coding to find a root of the equation (?−2)2−ln(?)=0 With initial guess ?0=1.0 and ?0 = 3.0. Write or print the results in your Homework sheet.
I'm writing a code for the Secant Method for root finding, but my code makes an...
I'm writing a code for the Secant Method for root finding, but my code makes an infinite code of the correct answer. Below is my code, how do I fix it? def f(x): return (x**6)+7*(x**5)-15*(x**4)-70*(x**3)+75*(x**2)+175*x-125 def secant(): p0=float(input('Enter an initial guess for the root ')) p1=float(input('Enter another guess ')) TOL=float(input('Enter a tolerance in decimal form ')) n=15 i=1 while i<=n: p=p1-f(p1)*(p1-p0)/(f(p1)-f(p0)) if abs(p-p1)<TOL: print(p) else: p0=p1 p1=p i=i+1 else: print(p) return p    print(secant())
Hi, I need a Matlab code satisfies the following question. Output should be a graph similar...
Hi, I need a Matlab code satisfies the following question. Output should be a graph similar to a sine or cosine graph or similar to electrocardiograms (EKG/ECG) graph. Please I'd appreciate it. All love. Thanks :) In elementary quantum mechanics, the square well is used to model the behavior of a bound particle, in which one or more forces (external potentials, interaction with other particles, etc) prevent or restrict its ability to move about. We have seen in class that...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT