|
-
Aug 22nd, 2005, 02:45 AM
#1
Thread Starter
New Member
How to factorise a numeric expression using VB?
I need to factorise an numeric expression using VB.And also to display the two possible values of the expression.
Eg. x^2 +2x+1
Thanks..
-
Aug 25th, 2005, 06:08 AM
#2
Lively Member
Re: How to factorise a numeric expression using VB?
Found the roots of your expression.
In your case x1=-1 and x2=-1.
the factorsare are the negative values of the roots:
-(-1) = 1
Your factorised expression is (x+1)(x+1)
Pieter
-
Aug 25th, 2005, 08:23 AM
#3
New Member
Re: How to factorise a numeric expression using VB?
I think what Mo's getting at though is what's the algorithm.
If all the equations to be solved are quadratics as per the example, it's dead simple.
The equation is y= ax^2 + bx + c and then
x1= (-b + (b^2 - 4ac)^.5) / 2a
x2= (-b - (b^2 - 4ac)^.5) / 2a
Simple code will do that arithmetic.
First you should have the code do 2 things...
1) check for a=0 since the equation is then a straight line not a parabola and it's illegal to divide by the 2a if a=0
2) check if the square root term b^2 - 4ac is <0, because if it is there is no real square root and the curve does not cut the x axis.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|