Question: Please write the following code in Scheme: 5. Remember the Quadratic formula, which can be used to find the roots of a quadratic eguation? For

Please write the following code in Scheme:Please write the following code in Scheme: 5. Remember the Quadratic formula,

5. Remember the Quadratic formula, which can be used to find the roots of a quadratic eguation? For a quadratic equation ax2 + bx+c=0,a #0, the formula is - 6 + x= 62 - 4ac 2a 2a Notice that this gives us two different roots (because of the +) whenever b2 - 4ac + 0. Write the following Scheme functions. (a) (root1 a b c) that gives us the root corresponding to the plus in the in the quadratic formula (that is, calculate -b+ b2 - 4ac). (b) (root2 a b c) that gives us the root corresponding to the minus in the # in the quadratic formula (that is, calculate - late -b-1b2-4ac 2a (c) (number-of-roots a b c) which calculates the number of distinct roots to the equation ax2 + bx+c=0,a # 0 (which will either be 1 or 2). (d) (real-roots? a b c) is a boolean function that evaluates to #t when the roots of ax? + bx + c = 0,a # 0 are real numbers. Note that you do not have to calculate the roots to determine whether they are real or complex numbers. Note: there are some common calculations done in the above functions; it may make sense to write some auxiliary functions to make your code simpler. 0 1 or 6. Given a k-by-k matrix M containing only 0 or 1 values, for k > 2, (a) Write a simple function that determines when any 2 x 2 binary matrix M is not one of the (1 0 2 x 2 anti-lonesome matrices, 101) All other binary matrices are lonesome matrices. Your function should return #t if M is lonesome. It should return #f otherwise. (b) If you have a 3x3 binary matrix M then it is lonesome if dropping any row and dropping any column does not give a 2 x 2 anti-lonesome matrix. Write a simple function that determines when any 3 x 3 matrix M is lonesome. Your function should return #t if M is lonesome. It should return #f otherwise. 5. Remember the Quadratic formula, which can be used to find the roots of a quadratic eguation? For a quadratic equation ax2 + bx+c=0,a #0, the formula is - 6 + x= 62 - 4ac 2a 2a Notice that this gives us two different roots (because of the +) whenever b2 - 4ac + 0. Write the following Scheme functions. (a) (root1 a b c) that gives us the root corresponding to the plus in the in the quadratic formula (that is, calculate -b+ b2 - 4ac). (b) (root2 a b c) that gives us the root corresponding to the minus in the # in the quadratic formula (that is, calculate - late -b-1b2-4ac 2a (c) (number-of-roots a b c) which calculates the number of distinct roots to the equation ax2 + bx+c=0,a # 0 (which will either be 1 or 2). (d) (real-roots? a b c) is a boolean function that evaluates to #t when the roots of ax? + bx + c = 0,a # 0 are real numbers. Note that you do not have to calculate the roots to determine whether they are real or complex numbers. Note: there are some common calculations done in the above functions; it may make sense to write some auxiliary functions to make your code simpler. 0 1 or 6. Given a k-by-k matrix M containing only 0 or 1 values, for k > 2, (a) Write a simple function that determines when any 2 x 2 binary matrix M is not one of the (1 0 2 x 2 anti-lonesome matrices, 101) All other binary matrices are lonesome matrices. Your function should return #t if M is lonesome. It should return #f otherwise. (b) If you have a 3x3 binary matrix M then it is lonesome if dropping any row and dropping any column does not give a 2 x 2 anti-lonesome matrix. Write a simple function that determines when any 3 x 3 matrix M is lonesome. Your function should return #t if M is lonesome. It should return #f otherwise

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!