My Math Forum need ideas concerning polynomial class

 Computer Science Computer Science Forum

August 31st, 2013, 08:21 PM   #11
Global Moderator

Joined: Nov 2006
From: UTC -5

Posts: 16,046
Thanks: 938

Math Focus: Number theory, computational mathematics, combinatorics, FOM, symbolic logic, TCS, algorithms
Re: need ideas concerning polynomial class

Quote:
 Originally Posted by gelatine1 I just realised that It would be better to make my monomials also a rational function as you call it. in case of negative exponents like 5ab^-1. Or should I simply leave it like a negative exponent ?
I'd leave them alone. You can handle 5ab^-1 as (5a)/(b) where 5a and b are monomials and (5a)/(b) is a rational function. Or not... it's up to you.

September 1st, 2013, 08:03 AM   #12
Senior Member

Joined: Mar 2012
From: Belgium

Posts: 654
Thanks: 11

Re: need ideas concerning polynomial class

Quote:
 Originally Posted by CRGreathouse So what you've written so far is basically just the I/O part -- well, or just the I part anyway. This is what I think of as the unfun part. I think what you wrote is fine, though I might have done it differently. But the fun part is what comes next: implement rational functions using monomials, and their operators. There's also a small unfun part -- I/O for rational functions -- but this shouldn't be too bad. I'll leave this here just in case: https://en.wikipedia.org/wiki/Shunting-yard_algorithm
You made me think again Well actually I was planning to just have some polynomial class which would simply allow me to do this:
Code:
polynomial a("a-b");
polynomial b("a^2+ab+b^2");

cout<<a*b<<endl;
But if I read what you just said then you would make it such that the user has to input (a-b)*(a^2+ab+b^2) and then I parse everything of it using the shunting yard algorithm you gave me which looks very useful so thanks for that

 September 1st, 2013, 12:47 PM #13 Global Moderator     Joined: Nov 2006 From: UTC -5 Posts: 16,046 Thanks: 938 Math Focus: Number theory, computational mathematics, combinatorics, FOM, symbolic logic, TCS, algorithms Re: need ideas concerning polynomial class Sounds good!
 September 2nd, 2013, 06:27 AM #14 Senior Member   Joined: Mar 2012 From: Belgium Posts: 654 Thanks: 11 Re: need ideas concerning polynomial class Mhmmm I wanted to start programming on this now but some question came up again. What if the user enters something like $(a+b)^{(a-b)}$ or just something like $(a+b+ab)^a$ Should I allow A user to do things like that ? Because Actually I have no idea how to take care of those. Another problem I thought of today is this. How can my interpreter see the difference between the two different power signs used here: (5a^2b+b^2a)^3 two of them are just a part of my monomial. and the other one is the power sign over the polynomial. but for the computer that is the same
September 2nd, 2013, 08:24 AM   #15
Global Moderator

Joined: Nov 2006
From: UTC -5

Posts: 16,046
Thanks: 938

Math Focus: Number theory, computational mathematics, combinatorics, FOM, symbolic logic, TCS, algorithms
Re: need ideas concerning polynomial class

Quote:
 Originally Posted by gelatine1 Mhmmm I wanted to start programming on this now but some question came up again. What if the user enters something like $(a+b)^{(a-b)}$ or just something like $(a+b+ab)^a$ Should I allow A user to do things like that ? Because Actually I have no idea how to take care of those.
I would return an error in that case. This produces a mathematical object but not a rational function. Since the goal was to handle rational functions (or just polynomials), this is out of scope just like if the user entered "$\int x$".

Quote:
 Originally Posted by gelatine1 Another problem I thought of today is this. How can my interpreter see the difference between the two different power signs used here: (5a^2b+b^2a)^3 two of them are just a part of my monomial. and the other one is the power sign over the polynomial. but for the computer that is the same
Probably you'll need to implement a general powering routine, and the parser will just tell it to raise "5a^2b+ab^2" to the power of 3. Right now you're handling the special case of powers of variables, but the general case can solved without too miuch trouble once you have multiplication and addition routines.

 September 2nd, 2013, 12:07 PM #16 Senior Member   Joined: Mar 2012 From: Belgium Posts: 654 Thanks: 11 Re: need ideas concerning polynomial class Well I started implenting the shunting-yard algorithm now. I will let you know if I am ready. (or if I have more questions). And by the way I have just (finally!) encountered a practical use of pointers lol I have always been wondering why those things actually exist untill today haha.
 September 5th, 2013, 11:59 AM #17 Senior Member   Joined: Mar 2012 From: Belgium Posts: 654 Thanks: 11 Re: need ideas concerning polynomial class Hello it's me again. I managed to write my shunting-yard interpreter and I can convert a string with a polynomial to a reverse polish notation. But now I don't really know what exactly to do with it.. I could reinterpret it again to get again the original polynomial but that would be pointless.
 September 5th, 2013, 02:36 PM #18 Global Moderator     Joined: Nov 2006 From: UTC -5 Posts: 16,046 Thanks: 938 Math Focus: Number theory, computational mathematics, combinatorics, FOM, symbolic logic, TCS, algorithms Re: need ideas concerning polynomial class You could consider RPN to be your internal notation, or you might want a particular specialized form of it (this is what I'd do, since then equating polynomials would be the same as equating internal expressions). In any case it seems that your goal should be to take two polynomials (rational functions) and combine them with +, -, * (+, -, *, /) to get another. You may also wish to implement equality and limits.

 Tags class, ideas, polynomial

 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post Keroro Advanced Statistics 0 February 17th, 2014 09:43 PM Keroro Algebra 0 February 17th, 2014 09:37 PM r-soy Physics 13 June 3rd, 2012 11:44 AM jcmc2112 New Users 2 July 19th, 2010 08:47 AM ely_en Algebra 0 September 1st, 2008 05:29 AM

 Contact - Home - Forums - Cryptocurrency Forum - Top