I believe the quadratic equation is called degenerate if .
Code:(define no-of-solutions (lambda (a b c) (if (zero? a) 'degenerate (let ([discr ...]) (cond [(zero? discr) 'one] [(negative? discr) 'none] [else 'two])))))
Hi
I am hoping for some help. I am reading and learning from an online programming text for scheme How to Design Programs: An Introduction to Computing and Programming
However I am at a section an example where I need to solve for three coefficients a,b,c and test whether an equation is degenerate. I have no idea I haven't done math for 15 years, coefficients & quadratics ring a bell but I can't remember it at all, and less about degenerates.
The top google searches aren't as they seem to assume we now what they are. Is there a good explanation or text online I can read.
This is the question I am reading for reference in case I may misinterpret it.
PS I assume what I am asking is basic algebra and thats why I have posted to hereDevelop what-kind. The function consumes the coefficients a, b, and c of a quadratic equation. It then determines whether the equation is degenerate and, if not, how many solutions the equation has. The function produces one of four symbols: 'degenerate, 'two, 'one, or 'none.
may be this may help understand degenerate quadratic equations
Conic section - Wikipedia, the free encyclopedia
http://www.geom.uiuc.edu/docs/refere...as/node28.html
http://lmgtfy.com/?q=what+is+a+degen...ic+equation%3F
but i couldn't understand
OKay so if a quadratic equates to 0 its degenerate? Or specifically "a" of a quadratic?
I am not really understanding because even if a = 0 then bx + c = 0 still provide function.
Edit this page doesn't even think degenerate quadratics exist Products of degenerate quadratic forms, by Paul Balmer
Thanks. I managed to solve the problem.
Code:;Determine the state of a quadratic ;number number number -> string ;when a is 0 quadratic is degenerate ;determine when a not equal to 0 how many solutions to quadratic ;what kind (define (what-kind a b c) (cond ;if a is not zero then not degenerate, perform function [( = a 0) 'Degenerate] [(> (* b b )(* 4 a c)) 'TwoSolutions] [(= (* b b )(* 4 a c)) 'OneSolution] [(< (* b b )(* 4 a c)) 'None]))
I have several remarks about the program. Perhaps it is splitting hairs, but a couple of them are kind of important.
First, the function returns symbols, not strings. These are different Scheme datatypes: see sections 6.8 and 6.11 in The Scheme Programming Language book.
Second, the problem statement says to returns different symbols from the ones you are returning.
Third, it is better to use "else" as the last condition in (cond ...). Using language-provided facilities and specifying fewer details makes is harder to introduce an error or a typo.
Finally, is is a good idea to compute the (sign of the) discriminant only once using (let ...). Again, this helps avoid typos and is more efficient.
Edit: It's commendable that you write comments with your code.