| Author |
Message |
gramili
Joined: 05 Feb 2010 Posts: 1
|
Posted: February 5, 2010 10:18 AM Post subject: How to extract from polinom ... ? |
|
|
If I have a polinom
11*x^5-99*x^3+65*x^2+5
How to get numbers which multiple x^ from polinom?
In this example I want to get list of numbers like
{11, 0, -99, 65, 0, 5}
Is there any function or method?
that represents numbers in my polinom
11*x^5+0*x^4-99*x^3+65*x^2+0*x+5
Thank you in advance |
|
| Back to top |
|
 |
BlainUSM
Joined: 24 Oct 2009 Posts: 30 Location: New England
|
Posted: February 6, 2010 3:58 AM Post subject: |
|
|
If the degree of the polynomial is taken as a given, then the following input may be used to define a function that will return the coefficients:
Define co(p, n) = seq(d(p,x,i)/i!, i, n, 0, -1) | x = 0
The parameter p is the polynomial and n is the polynomial’s degree. Note that “d” is accessed by pushing “2nd” and then “8”.
For your problem:
Input: co(11*x^5-99*x^3+65*x^2+5, 5)
Output: {11, 0, -99, 65, 0, 5}
There are many other ways of obtaining the coefficients; they may be extracted with careful use of the “part” command, identified with the “solve” command, returned as a matrix from the “rref” command, obtained with other algebraic methods, or parsed with plain vanilla string operations.
The function co(p,n) may be modified so that the parameter n no longer needs to be given... |
|
| Back to top |
|
 |
BlainUSM
Joined: 24 Oct 2009 Posts: 30 Location: New England
|
Posted: February 8, 2010 2:30 PM Post subject: |
|
|
Below is code for a function that will return the coefficients of an arbitrary polynomial (given only the polynomial):
co(p)
Func
Local i,z
{}->z
1->i
p->z[1]
While string(d(p,x))!="0" and string(d(p,x))!="0."
d(p,x)->p
p/i!->z[i+1]
i+1->i
EndWhile
Local t
For i,1,floor(dim(z)/2)
z[i]->t
z[dim(z)-i+1]->z[i]
t->z[dim(z)-i+1]
EndFor
Return z|x=0
EndFunc
To test the program type "co(x^2 + 4x - 3)" your output should be "{1, 4,-3}".
Note: The symbol != is short for not equal to, which may be accessed via the catalog. Also, the symbol for differentiation, d, may be accessed by pushing "2nd" and then "8". |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|
Saphic 1.5 // Theme created by Sopel
|
|