dantay9 Posted March 12, 2009 Share Posted March 12, 2009 (edited) I am making a trinomial solver because I hate having to solve them and not knowing if they are even solvable. I have the equation split up and the necessary parts assigned to variables, but I don't know where to go from here. Can someone point me in the right direction. Thanks in advance. Edited March 12, 2009 by dantay9 Link to comment Share on other sites More sharing options...
qazwsx Posted March 12, 2009 Share Posted March 12, 2009 I think most solvers use matrices to solve equations. Link to comment Share on other sites More sharing options...
dantay9 Posted March 12, 2009 Author Share Posted March 12, 2009 (edited) I know that solving systems of equations is easiest using matricies, but can you solve just one equation using matricies? Edited March 12, 2009 by dantay9 Link to comment Share on other sites More sharing options...
martin Posted March 12, 2009 Share Posted March 12, 2009 (edited) I know that solving systems of equations is easiest using matricies, but can you solve just one equation using matricies? Assuming you have got the factors worked out correctly then I assume that for each factor the sign could be +ve or -ve, and for each pair of factors for the square term any of the other factors for the linear term might be the correct ones. So you can go through all possibilities. Lets say the sign for the first square term factor is $a; the sign for the second square term factor is $b; the sign for the first linear term factor is $c and the second is $d. Then we can do this For $as = -1 To 1 Step 2;for either sign of the first square factor For $bs = -1 To 1 Step 2;etc For $cs = -1 To 1 Step 2 For $ds = -1 To 1 Step 2 For $j = 0 To UBound($SquaredFactors) - 1 For $k = 0 To UBound($ConstantFactors) - 1 If ($as * $SquaredFactors[$j][0] + $cs * $ConstantFactors[$k[0]) * ($bs * $SquaredFactors[$j][1] + $ds * $ConstantFactors[$k[1]) = 0 Then ;we have found an answer EndIf ;try with factors swapped If ($as * $SquaredFactors[$j][0] + $cs * $ConstantFactors[$k[1]) * ($bs * $SquaredFactors[$j][1] + $ds * $ConstantFactors[$k[0]) = 0 Then ;we have found an answer EndIf Next Next Next Next Next Next But this seems like a very complicated way to solve the problem and it's restricted to integer results, although I think your functions could be simplified. Why not use a more conventional approach? EDIT: By conventional I mean ANS = (-b +/-(b2 - $ac)1/2)/2a Edited March 12, 2009 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
dantay9 Posted March 12, 2009 Author Share Posted March 12, 2009 I decided to use this way because my plan was to factor the trinomial, not solve it. I don't want an exact answer. I want to know if it can be factored. Link to comment Share on other sites More sharing options...
martin Posted March 12, 2009 Share Posted March 12, 2009 I decided to use this way because my plan was to factor the trinomial, not solve it. I don't want an exact answer. I want to know if it can be factored.OK, you can do it any way you want of course.Anyway, was my suggestion any help? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
dantay9 Posted March 12, 2009 Author Share Posted March 12, 2009 Oh! I forgot to reply back. Yes, it was a lot of help. It worked great. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now