• Jan 8th 2011, 05:00 AM
sayth
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.

Quote:

Develop 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.
PS I assume what I am asking is basic algebra and thats why I have posted to here
• Jan 8th 2011, 05:17 AM
emakarov
I believe the quadratic equation $ax^2+bx+c=0$ is called degenerate if $a = 0$.

Code:

```(define no-of-solutions   (lambda (a b c)     (if (zero? a)         'degenerate         (let ([discr ...])           (cond             [(zero? discr) 'one]             [(negative? discr) 'none]             [else 'two])))))```
• Jan 8th 2011, 05:44 AM
Prove It
Quote:

Originally Posted by emakarov
I believe the quadratic equation $ax^2+bx+c=0$ is called degenerate if $a = 0$.

Code:

```(define no-of-solutions   (lambda (a b c)     (if (zero? a)         'degenerate         (let ([discr ...])           (cond             [(zero? discr) 'one]             [(negative? discr) 'none]             [else 'two])))))```

And if that's the case, then the quadratic is actually a linear function.
• Jan 8th 2011, 06:15 AM
grgrsanjay
• Jan 8th 2011, 03:38 PM
sayth
Quote:

Originally Posted by Prove It
And if that's the case, then the quadratic is actually a linear function.

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.

• Jan 8th 2011, 03:41 PM
Prove It
If the coefficient of $\displaystyle x^2$, i.e. $\displaystyle a$ is $\displaystyle 0$, then the quadratic is degenerate.

It's called degenerate because the quadratic function no longer "resembles" a quadratic, it now "resembles" a linear function.
• Jan 8th 2011, 10:09 PM
sayth
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]))```
• Jan 9th 2011, 03:29 AM
emakarov
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.