Negative Numbers

• 10-11-2003
Quantrizi
Negative Numbers
Does anyone know how to turn a value into a negative number?

An example:
Code:

`x = -(b/2(a))`
that would make x be the negative value of b/2a [incase you don't know, it's 1/2 of a quadratic function].

And I know if b/2a comes out negative, the - sign makes it a positive, but I wish to know how to make it negative if it isn't already.
• 10-11-2003
Lynux-Penguin
Code:

```x = -(b/2)*(a); if(x>0)  x=-x;```
-LC
• 10-11-2003
Quantrizi
Quote:

Originally posted by Lynux-Penguin
Code:

```x = -(b/2)*(a); if(x>0)  x=-x;```
-LC

Thank you.

After posting this though, I realized that this would work:
PHP Code:

``` x = -b/2 * a; x2 = x; x3 = -x;  ```
Which does the same, but hey
• 10-11-2003
nickname_changed
Been a while since I did quadratics, but isn't the equation
-b
---
2a?

Which is -b/(2a) which is different to (-b/2)*a

In the same way that
(1/2) * 3 = 3/2
1/(2*3) = 1/6
are different. Just thought I'd mention it.

And quantrizi, your way gives you a positive and negative of the answer, and you can't be sure which is in which unless you test. Lynux Penguins way was better because x will always be negative, like you wanted.

BTW, -b/2a, is that the vertex? Just trying to remember.
• 10-11-2003
swoopy
Try:
x = -abs(b/2(a))

• 10-11-2003
nickname_changed
Yeah I'm pretty sure -b/2a is the X position of the vertex (highest or lowest pt) on the quadratic. Why do you want the negative version of it Quantrizi?

I still prefer
Code:

```x = -b/(2*a); if (x > 0)   x = -x;```
• 10-11-2003
confuted
Code:

```x= (-b+sqrt((b*b)-(4*a*c)))/(2a) and x= (-b-sqrt((b*b)-(4*a*c)))/(2a)```
You shouldn't need to do what you're doing... because x-y for negative y is the same as x+|y| where |n| is the absolute value of n.
• 10-12-2003
nickname_changed
Normally thats used to find the X intercepts of the quadratic. The
Code:

`(b*b)-(4*a*c)`
Part of your equation is the discriminant, if thats negative there are no intercepts (theres no REAL square root of a negative number), if its 0 there is only one interecpt (that is, it touches the X axis), and if its greater than 0 there are two intercepts.

You have the equation twice, one with + one with -. If the discriminant is 0 can you see there will only be one answer, +0 and -0 are the same. If the discriminant is < 0 both equations are invalid (unless we use an imaginary number system), and >0 there will be 2 different answers.

The equation he asked for, -b/2a, is often used to calculate the vertex.