Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,396 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,104 people online right now. Registration is fast and FREE... Join Now!




factoring

 
Reply to this topicStart new topic

factoring, polynomials

MingusDew
29 Sep, 2006 - 12:15 AM
Post #1

New D.I.C Head
*

Joined: 28 Sep, 2006
Posts: 13


My Contributions
ok I know that if you took algebra in high school you probably spent a week learning how to factor polynomials, and chances are you hated it. Hence you can see why I would like to write a program to handle this sort of thing, and it just seems like a good challange for someone at my skill level.

CODE

#include <iostream>
#include <math>

using namespace std;

int main()
{
  flaot x,y,a,b,c,a1,b1,c1,d1;

  cout<<"trying to factor a polynomial\n";
  cout<<"please enter first value, in xe2 form\n";
  cin>> a;
  cout<<"and the variable\n;"
  cin>> 'x';
  cout<<"now the second value\n";
  cin>> b;
  cout<<"and the variable\n";
  cin>> 'x';
  cout<<"nown the last value\n";
  cin>> c;
  //axe2-bx+c=0
  a=a1*c1;
  b=a1*d1+b1*C1
  
  
  


I know its incomplete I just got lost at this point trying to figure out how to make the prog. handle the character xe2 which is x to the power of 2, x^2 evaluates the same way, and be able to divide it mathematically.

for those of you who dont know anything about factoring polynomials I'll give you a basic overview:

xe2-5x+6
factors to:
(x-2)(x-3)

2xe2+7x+6
factors to:
(2x+3)(x+2)

thanks for the help in advance
User is offlineProfile CardPM
+Quote Post

max302
RE: Factoring
29 Sep, 2006 - 03:05 AM
Post #2

Proud supporter of the lulz
Group Icon

Joined: 5 Mar, 2006
Posts: 1,281


Dream Kudos: 200
My Contributions
What a coincidence, I doing polynomials just now. What's hard in making a machine this kind of job is that algebra uses abstract numbers (x,a,b ect), and a computer doesn't consider abstraction, so when you use a variable in an equation, it will pop out it's value. There must be a function for algebra, but I'm not a senior in C++ so I don't know it.
User is offlineProfile CardPM
+Quote Post

Louisda16th
RE: Factoring
29 Sep, 2006 - 06:34 AM
Post #3

 
Group Icon

Joined: 3 Aug, 2006
Posts: 1,790



Thanked: 1 times
Dream Kudos: 755
My Contributions
Try this. Since you are dealing with quadratic expressions, you could use the quadratic equation formula to find the roots. Then check if they are intergers. This will not work with (x-1/2)(x-1/3) etc....
User is offlineProfile CardPM
+Quote Post

born2c0de
RE: Factoring
29 Sep, 2006 - 09:49 AM
Post #4

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 3,935



Thanked: 34 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
I wrote this Code Snippet years ago and I think this is exactly what you are looking for.

Tell me what you think.
User is offlineProfile CardPM
+Quote Post

DeeViLiSh
RE: Factoring
29 Sep, 2006 - 12:07 PM
Post #5

D.I.C Head
Group Icon

Joined: 25 Jul, 2006
Posts: 175



Thanked: 1 times
Dream Kudos: 575
My Contributions
You spelled float flaot, that might be a solution to your problem >_>
I don't understand your a=a1*c1 since a1 and c1 haven't been initialized or modified by user.
Unless you meant a1*c1=a which is different and I doubt will be accepted by compiler.

This post has been edited by Dark_Nexus: 1 Oct, 2006 - 02:16 PM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/5/08 02:55AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month