Help: how to solve a SECOND DEGREE equation in VB
Author Message Help: how to solve a SECOND DEGREE equation in VB

For a second degree equation (A*X^2 + B*X + C = 0), you would need to
"intelegently" apply the formula

X = ( -B + Sqrt( B^2 - 4*A*C) ) / (2*A)    and
X = ( -B  - Sqrt( B^2 - 4*A*C) ) / (2*A)

Note that you will not always have a "positive" solution to a second degree
equation.  The posibilites include:
1) two positive solution        (when B is negative and Sqrt(B^2-4AC) < B)
2) two negative solution        (when B is positive ans Sqrt(B^2-4AC) < B)
3) one positive solution and one negative solution (when Sqrt(B^2-4AC) > B)
4) two "imaginary" solutions  (when B^2-4AC is negative, because you can
not take the square root of a negative number).

Good Luck,
Joseph

Quote:
> I need to solve a second degree equation in Visual Basic .... something
> like this:
> 12.32*X^2+179.24*X-958.1625=0
> and I need Visual basic to choose the "positive"(X=4.157) solution from
> the equation.
> Can anyone HELP me?

> --

> Jo?o Varandas Marques
> Parede - PORTUGAL

> http://www.*-*-*.com/ ; (Photo Homepage)
> http://www.*-*-*.com/ ;  (Band Homepage)

> PGP key available on request ;)

Tue, 20 Jul 1999 03:00:00 GMT  Help: how to solve a SECOND DEGREE equation in VB

Quote:
> I need to solve a second degree equation in Visual Basic .... something
> like this:
> 12.32*X^2+179.24*X-958.1625=0
> and I need Visual basic to choose the "positive"(X=4.157) solution from
> the equation.

Why not apply the quadratic formula, which gives both roots, and test the
results to see if you got a positive one?  My memory of high-school math may
be faulty, but as I recall it:

Root1 = ((-B) + Sqr((B^2) - 4AC) / 2A
Root2 = ((-B) - Sqr((B^2) - 4AC) / 2A

...where A is 12.32, B is 179.24, and C is 958.1625, in your formula

-- Jim

Tue, 20 Jul 1999 03:00:00 GMT  Help: how to solve a SECOND DEGREE equation in VB

You may try third party custom controls.  I can't remember right off hand
where I saw a formula handling control.  You may try these companies:
Visual Components
Sheridan Systems
Crescent
If they don't have an answer, they should lead you in the right direction.
Good luck.

Quote:
> I need to solve a second degree equation in Visual Basic .... something
> like this:
> 12.32*X^2+179.24*X-958.1625=0
> and I need Visual basic to choose the "positive"(X=4.157) solution from
> the equation.
> Can anyone HELP me?

> --

> Jo?o Varandas Marques
> Parede - PORTUGAL

> http://www3.telepac.pt/bira/photos/fragmentos.html   (Photo Homepage)
> http://www3.telepac.pt/bira/haine/    (Band Homepage)

> PGP key available on request ;)

Tue, 20 Jul 1999 03:00:00 GMT  Help: how to solve a SECOND DEGREE equation in VB

I need to solve a second degree equation in Visual Basic .... something
like this:
12.32*X^2+179.24*X-958.1625=0
and I need Visual basic to choose the "positive"(X=4.157) solution from
the equation.
Can anyone HELP me?

--

Jo?o Varandas Marques
Parede - PORTUGAL

http://www3.telepac.pt/bira/photos/fragmentos.html   (Photo Homepage)
http://www3.telepac.pt/bira/haine/    (Band Homepage)

PGP key available on request ;)

Tue, 20 Jul 1999 03:00:00 GMT

 Page 1 of 1 [ 4 post ]

Relevant Pages