473,586 Members | 2,839 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 2907
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
3504
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() functionality (which solves arbitrary polynomials). Does anyone know of a Python module/package that implements that? Just
9
5967
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 #define Polynomial_h class Polynomial
1
3640
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
2840
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 is the inversed process, if I have get the R(x), is there a inverse polynomial to generator the M(x)? Another example is that I have a 32-bit data...
14
11309
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, e.g. f(x)=x^8+x^4+x^3+x+1 in C? How to represent the multiplication & division process of polynomial? Regards.
12
2778
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 points and then outputs the polynomial with indeterminant in the form \sum_i=0^n\alpha_i X^i, where X is just some indeterminant. Any hints? ...
11
3917
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 attempting to make a list of polynomial functions such that poly(3) = 1, poly(3) = 3, poly(3) = 9, etc. Could someone point me in the right direction?...
1
4864
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. So...how exactly should I make this function? I understand all the other ways to make a hash function except this one. Laura
1
6482
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 help will be appriciated here is the code: import java.io.*; import java.util.Scanner; public class Polynomial extends UnorderedArrayList {...
0
7836
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8336
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7950
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8212
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6606
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3835
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2343
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 we have to send another system

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.