## x + x^2=90

- {Nathan}
- Veteran
**Posts:**1169**Joined:**Thu Aug 19, 2004 6:08 pm**Location:**The wetlands of central Ohio, USA-
**Contact:**

### x + x^2=90

I know that in this case, x is equal to 9, but how would I figure this out mathematically?

- seaBiscuit$
- Coder
**Posts:**45**Joined:**Sun Nov 26, 2006 2:00 pm**Location:**Champaign, Illinois

### Re: x + x^2=90

Looks like you have a quadratic equation thingy.{Nathan} wrote:I know that in this case, x is equal to 9, but how would I figure this out mathematically?

x^2 + x - 90 = 0

though that could be optimized a bit because 'a' and 'b' would be ones.

sid6.7 wrote:everytime i see your avatar i want to scream and kill it....

Yoo could use the brute force approach by writing a little program that uses a FOR loop on X, and keeps testing until it finds it. Something like this:

[code}

FOR X = 1 TO 90

T = X + X^2

IF T = 90 THEN PRINT "ANSWER = ";X : GOTIT=1 :EXIT FOR

NEXT X

IF GOTIT=0 THEN PRINT "NOT FOUND, X MUST BE FRACTIONAL"

[/code]

PS, I haven't tried it.

Regards..... Moneo

- Patz QuickBASIC Creations
- Veteran
**Posts:**399**Joined:**Wed Mar 02, 2005 9:01 pm**Location:**Nashville, Tennessee-
**Contact:**

Yes, I think the quadratic formula would be the best way to solve it, since it works for ANY quadratic.

as the quadratic formula has a plus and minus. However, if the discriminant (B^2-4AC) is negative, QB will generate an error because it has an imaginary solution.

Code: Select all

```
PosX=(-B+SQR((B^2)-(4*A*C)))/(2*A)
NegX=(-B-SQR((B^2)-(4*A*C)))/(2*A)
```