Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. Write and test the following functions that deal with points and lines in the Cartesian plane. (a) (y-value x b , a function of

image text in transcribed

4. Write and test the following functions that deal with points and lines in the Cartesian plane. (a) (y-value x b , a function of three parameters (an z value, a y-intercept b, and a slope m) that returns the y value of the line at that r, that is mz b (b) (points-slope x1 yl x2 y2), a function of four parameters (the x and y values of two points) that calculates the slope of a line through those points (^i,yi) and (r2,y2). You may assume that the two points are distinct. (Note: this function is not required to work if the slope of the line is undefined.) (c) (points-intercept x1 yl x2 y2), a function of four parameters (the x and y values of two points) that calculates the y-intercept of a line through points (i,y and (r2, 32) You may assume that the two points are distinct. (Note: this function is not required to work if the line does not have a y-intercept.) (d) (on-parallels? x1 yl x2 y2 x3 y3 x4 y4), a function of eight parameters (the x and y values of four points), returns true if the line through points (i,y) and (2,2) is parallel to the line through points (r3,y3) and (x4,y4). You may assume that points 1,) and2,2) are distinct, as are (r3,y3) and (,) Note: this function can use any of the functions defined above, but should give a correct answer even in the cases where points-slope or points-intercept would fail. 5. Remember the Quadratic formula, which can be used to find the roots of a quadratic eguation!? For a quadratic equation ar2 + br + c-0, a0, the formula is 2a Notice that this gives us two different roots (because of the ) whenever b2-4ac0. Write the following Scheme functions. (a) (root 1 a b c) that gives us the root corresponding to the plus in the in the quadratic (b) (root2 a b c) that gives us the root corresponding to the minus in the in the quadratic (c) (number-of-roots a b c) which calculates the number of distinct roots to the equation (d) (real-roots? a b c) is a boolean function that evaluates to #t when the roots of ar2+ formula (that is, calculate318 la) formula (that is, calculate ar2 + br + c = 0, a0 (which will either be 1 or 2) br + c = 0, a0 are real numbers. Note that you do not have to calculate the roots to determine whether they are real or complex numbers

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

Big Data With Hadoop MapReduce A Classroom Approach

Authors: Rathinaraja Jeyaraj ,Ganeshkumar Pugalendhi ,Anand Paul

1st Edition

1774634848, 978-1774634844

More Books

Students also viewed these Databases questions