473,511 Members | 15,364 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

polynomial function

16 New Member
I have a problem in writing a code that accept a polynomia function from the user.The program shouldn't accept the cofficient and exponent at ones not separately.For example 5x^50+x^8+x is a single entery from the user.
Dec 11 '06 #1
3 2894
r035198x
13,262 MVP
I have a problem in writing a code that accept a polynomia function from the user.The program shouldn't accept the cofficient and exponent at ones not separately.For example 5x^50+x^8+x is a single entery from the user.
I'm not getting the last part. If you could please explain again
Dec 11 '06 #2
selam
16 New Member
I'm not getting the last part. If you could please explain again
The aim of the program is to write a program in C++ to accept a polynomial from the user on a single entry
Dec 11 '06 #3
macklin01
145 New Member
It seems to me that you would need to write a function that takes a character string as input and parses it to a polynomial structure of some kind. (An class consisting of an array of coefficients plus some operations, for instance.)

If you can assume that your user writes the polynomial in order from the highest degree term to the lowest degree term, that would help in the parsing. You might then consider first eliminating all whitespace (spaces and tabs) from the input, so that you can assume that the only characters that separate monomial terms are + or -.

The ^ character will indicate the term of each monomial term. (If there is no ^ term, then it's either degree 1 or 0. If there's no x, then it's degree zero.)

I suppose that if you process the string twice, you won't need to assume any kind of ordering. (Process once to determine the maximum degree and thereby the necessary memory allocation for the coefficients, and process a second time to fill in the coefficients.)

I hope that helps a little. -- Paul
Dec 12 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

17
3486
by: Just | last post by:
While googling for a non-linear equation solver, I found Math::Polynomial::Solve in CPAN. It seems a great little module, except it's not Python... I'm especially looking for its poly_root()...
9
5963
by: strotee76 | last post by:
What do I need to do to setTerm() for it to work properly? If you notice any other glaring issues, then please let me know. With this header file: ======================= #ifndef Polynomial_h...
1
3634
by: Rubén Campos | last post by:
I've trying to implement polynomials of arbitrary order as a C++ template, as shown here: template <unsigned long int N> class Polynomial { public: Polynomial (); ~Polynomial ();
2
2829
by: Chen L. | last post by:
Hi all, If I have a 32-bit data M, and the CRC genrator polynomial G(x),which power is 32, then I can get the CRC checkword R by the following algorithm: X^32*M(x) = Q(x)G(x) + R(x), But how...
14
11293
by: Tiza Naziri | last post by:
Hi, Anybody have an idea on how to start writing a C code for generating the inverse of finite field GF(2^8) using extended Euclidean algorithm? What I mean is how to represent a polynomial,...
12
2765
by: daniel.wolff | last post by:
I am looking for a quick C program that takes n+1 pairs of values (integers) (a_i, f(a_i)), i=0,...,n, generates the coefficients \alpha_i, i=0,...,n of the polynomial of degree n that fits these...
11
3909
by: Josiah Manson | last post by:
In the following program I am trying to learn how to use functional programming aspects of python, but the following program will crash, claiming that the recursion depth is too great. I am...
1
4835
by: aphrodite | last post by:
I have to write a program to manage a hash table using collision resolution by chaining, with numeric long integer and string keys and where the hash function should use polynomial accumulation....
1
6470
by: madman228 | last post by:
Hi guys I have run in to a littl bit of trouble. I am writing a class called polynomial in which i need a derivative method I have everything, just dont know how to start the derivative method. Any...
0
7138
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7508
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5662
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.