Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1: Solving for Roots using the Quadratic Equation ar + bx+c=0 (-bu-dac 2a Write a function that assigns the coefficients of a second order

image text in transcribed

Part 1: Solving for Roots using the Quadratic Equation ar + bx+c=0 (-bu-dac 2a Write a function that assigns the coefficients of a second order equation as input arguments, solves for the roots x, and xz, and prints the roots to the command window as a formatted text. There are four unique scenarios resulting from the coefficients a, b, and c: 1. is a linear function with only one real root at 2. has two unique real roots 3. has two complex roots with identical real components 4. has one real double root at Use an I, elseif, else statement to evaluate the coefficients for each scenario. Compute the roots using the appropriate part(s) of the quadratic equation. Print the roots and using the fprintf) function to display the roots as text matching the following format: 1. The only root is x = {x1}', where {x1} is the real root 2. The roots are x = {X1} and {X2}', where {X1} and {X2} are real roots 3. The roots are x = {R} +/- {1*, where {R} is the real component and {1} is the imaginary component 4. The double root is x = {x1}', where {x1} is the real double root An initial program is provided in the Learner Template to help with syntax. Test your function using the following input scnearios: >> Lab3Part1(0.1.2). The only root is x = -2 >> Lab3Part1(1.3.2): ( The roots are x = -1 and -2 >> Lab3Part1(1,2,3) ( The roots are x = -1 +/- 1.41421'i >> Lab3Part1(1,2,1) The double root is x = -1 Function Save e Reset 39 MATLAB Documentation 1 %Title: LAB 3 Part 1 2 XAuthor: 3 Date: 4 Description: This function solves for the roots of the quadratic equation 5 % and prints the results as a formatted string to the Command 6 % Window. Input parameters take the form ax^2+bx+c = 0 7 8 function (x1,x2] - Lab3Parti(a,b,c) 9 10 11 12 13 14 15 16 end if a -- @ Scenario 1: linear function x1 = -c/b; %solve for the single real root fprintf('The only root is x = ' ',x1); %print root as formatted text %add your code here end Code to call your function C Reset 1 Lab3Part1(0,1,2); 2 Lab3Parti(1,3,2); 3 Lab3Part1(1,2,3)

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago