| | |
Finding Coefficients of a polynomial, roots are provided from command line
![]() |
•
•
Join Date: Sep 2008
Posts: 3
Reputation:
Solved Threads: 0
Some numbers like 1,2,3,4,.... are provided from the command line. Considering them to be roots of a polynomial of that degree< equal to number of roots > , i was trying to find the coefficients of the constructed polynomial, i was using the concept of multiplication of two single degree polynomials.
for e.g if the numbers are 1,2 and3.
the P(x) == (x-1)(x-2)(x-3).
so if give 1 and 2 in the command line. the sample output should be 1 , -3, 2.
Please help me......
for e.g if the numbers are 1,2 and3.
the P(x) == (x-1)(x-2)(x-3).
so if give 1 and 2 in the command line. the sample output should be 1 , -3, 2.
Please help me......
•
•
Join Date: Aug 2008
Posts: 206
Reputation:
Solved Threads: 31
1) First, represent a polynomial (of the form c_0 + c_1*x + c_2*x^2 + .... c_n*x^n) is represented by an array with elements (c_0, c_1, c_2, c_3, .... c_n).
2) Work out how to multiply two arbitrary polynomials together. ie. given a polynomial A (a_0, a_1, a_2, a_3, .... a_n) and a polynomial B (b_0, b_1, b_2, b_3, .... b_m) work out how to obtain a polynomial A*B = C = (c_0, c_1, c_2, c_3, .... c_(m+n)). Hint: The process to produce C from A and B is called convolution.
3) For the first root on the command line, create a polynomial X = (root, 1).
4) For all other roots on the command line;
a) create a polynomial Y = (root, 1)
b) obtain a polynomial Z = X*Y using the approach worked out in Step 2.
c) set X = Z
5) Voila!!!
2) Work out how to multiply two arbitrary polynomials together. ie. given a polynomial A (a_0, a_1, a_2, a_3, .... a_n) and a polynomial B (b_0, b_1, b_2, b_3, .... b_m) work out how to obtain a polynomial A*B = C = (c_0, c_1, c_2, c_3, .... c_(m+n)). Hint: The process to produce C from A and B is called convolution.
3) For the first root on the command line, create a polynomial X = (root, 1).
4) For all other roots on the command line;
a) create a polynomial Y = (root, 1)
b) obtain a polynomial Z = X*Y using the approach worked out in Step 2.
c) set X = Z
5) Voila!!!
![]() |
Other Threads in the C Forum
- Previous Thread: How the hell did i do this! funny as hell
- Next Thread: Compiler optimizing arrays
| Thread Tools | Search this Thread |
#include * adobe ansi array asterisks binarysearch centimeter changingto char character cm convert copyimagefile cprogramme creafecopyofanytypeoffileinc database dynamic execv feet fgets file floatingpointvalidation fork function getlogicaldrivestrin givemetehcodez global grade gtkwinlinux hacking histogram ide inches include incrementoperators infiniteloop input interest intmain() iso kernel keyboard kilometer license linked linkedlist linux list locate looping lowest matrix meter microsoft mqqueue number oddnumber opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer posix power probleminc process program programming radix recursion recv recvblocked research reversing segmentationfault sequential single socket socketprograming socketprogramming standard strchr string suggestions systemcall test threads turboc unix urboc user variable voidmain() wab whythiscodecausesegmentationfault windowsapi





