polynomial-math

How to calculate CRC-16 from HEX values?

风格不统一 提交于 2019-12-03 08:43:01
In my code i need to calculate CRC-16 16 bit values for the HEX values stored as NSdata, below is the code snippet to calculate CRC-16 in c. void UpdateCRC(unsigned short int *CRC, unsigned char x) { // This function uses the initial CRC value passed in the first // argument, then modifies it using the single character passed // as the second argument, according to a CRC-16 polynomial // Arguments: // CRC -- pointer to starting CRC value // x -- new character to be processed // Returns: // The function does not return any values, but updates the variable // pointed to by CRC static int const

How to calculate coefficients of polynomial using Lagrange interpolation

人走茶凉 提交于 2019-12-03 05:46:07
I need to calculate coefficients of polynomial using Lagrange interpolation polynomial , as my homework, I decide to do this in Javascript. here is definition of Lagrange polynomial (L(x)) Lagrange basis polynomials are defined as follows Calculate y value for specific X (W(x) function) is simple but I need to calculate coefficients of polynomial (array of [a0, a1, ..., an]) I need to do this to n<=10 but it will be nice to have arbitrary n, then I can put that function into horner function and draw that polynomial. I have function that calculate denominator in first equation function

How can I fix this “plus” method in Polynomial class using BigInteger

旧时模样 提交于 2019-12-02 08:50:49
问题 I appreciate the help. I was able to finish modifying everything in this class into BigInteger format except for the compose method. Can anyone help me with this last part as to why it is not working correctly? I really appreciate it, thanks. import java.math.BigInteger; public class Polynomial { private BigInteger[] coef; // coefficients private int deg; // degree of polynomial (0 for the zero polynomial) /** Creates the constant polynomial P(x) = 1. */ public Polynomial(){ coef = new

Why is this polynomial equation badly conditioned?

爷,独闯天下 提交于 2019-12-02 07:17:11
I have 1x1024 matrix. So I'd like to estimate a polynomial equation. X= (0:1023)' Y= acquired data. A 1024 element vector Then I try this in MATLAB: polyfit(x,y,5) But MATLAB makes an abnormal result with warning. Warning: Polynomial is badly conditioned. Add points with distinct X values, reduce the degree of the ... I don't understand what am I doing wrong? Update I got a bunch of numbers like this. Y= -0.0000000150 ... 0.00001 ... 0 ... 0.17 X= 0~255 polyfit(X,Y,4) I got a polynomial but it does not match to original curve. Is there any options to match between original curve and polyfit's

Horner's rule for two-variable polynomial

末鹿安然 提交于 2019-12-01 18:01:36
Horner's rule is used to simplify the process of evaluating a polynomial at specific variable values. https://rosettacode.org/wiki/Horner%27s_rule_for_polynomial_evaluation#Standard_ML I've easily applied the method using SML, to a one variable polynomial, represented as an int list: fun horner coeffList x = foldr (fn (a, b) => a + b * x) (0.0) coeffList This works fine. We can then call it using: - val test = horner [1.0, 2.0, 3.0] 2.0; > val test = 17.0 : real Where [1.0, 2.0, 3.0] is the list representing the polynomial coefficients, 2.0 is the value of the variable x, and 17.0 is the

Solving system of nonlinear equations with python

天涯浪子 提交于 2019-12-01 03:39:01
Can I solve a system of nonlinear equations in terms of parameters in python? Is there a example or tutorial? I can do this easily in maple, but the expressions for my particular system are pretty big and copying them over is quite hard. Example: sigma*(y-x) = 0 x*(rho-z)-y = 0 x*y-beta*z = 0 You should get the solutions: [[x = 0, y = 0, z = 0], [x = sqrt(beta*rho-beta), y = sqrt(beta*rho-beta), z = rho-1], [x = -sqrt(beta*rho-beta), y = -sqrt(beta*rho-beta), z = rho-1]] The reason I ask: I have a large system of nonlinear ODEs. I want to solve for the fixed points (this is doable, it's been

Solving system of nonlinear equations with python

妖精的绣舞 提交于 2019-12-01 01:10:36
问题 Can I solve a system of nonlinear equations in terms of parameters in python? Is there a example or tutorial? I can do this easily in maple, but the expressions for my particular system are pretty big and copying them over is quite hard. Example: sigma*(y-x) = 0 x*(rho-z)-y = 0 x*y-beta*z = 0 You should get the solutions: [[x = 0, y = 0, z = 0], [x = sqrt(beta*rho-beta), y = sqrt(beta*rho-beta), z = rho-1], [x = -sqrt(beta*rho-beta), y = -sqrt(beta*rho-beta), z = rho-1]] The reason I ask: I

Why do different methods for solving Xc=y in python give different solution when they should not?

怎甘沉沦 提交于 2019-12-01 00:52:14
I was trying to solve a linear system Xc=y that was square. The methods I know to solve this are: using inverse c=<X^-1,y> using Gaussian elimination using the pseudo-inverse It seems as far as I can tell that these don't match what I thought would be the ground truth. First generate the truth parameters by fitting a polynomial of degree 30 to a cosine with frequency 5. So I have y_truth = X*c_truth . Then I check if the above three methods match the truth I tried it but the methods don't seem to match and I don't see why that should be the case. I produced fully runnable reproducible code:

identify graph uptrend or downtrend

谁说胖子不能爱 提交于 2019-11-30 22:06:51
I am attempting to read in data and plot them on to a graph using python (standard line graph). Can someone please advise on how I can classify whether certain points in a graph are uptrends or downtrends programmatically? Which would be the most optimal way to achieve this? Surely this is a solved problem and a mathematical equation exists to identify this? here is some sample data with some up trends and downtrends x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30] y = [2,5,7,9,10,13,16,18,21,22,21,20,19,18,17,14,10,9,7,5,7,9,10,12,13,15,16,17,22,27]

identify graph uptrend or downtrend

六月ゝ 毕业季﹏ 提交于 2019-11-30 17:40:37
问题 I am attempting to read in data and plot them on to a graph using python (standard line graph). Can someone please advise on how I can classify whether certain points in a graph are uptrends or downtrends programmatically? Which would be the most optimal way to achieve this? Surely this is a solved problem and a mathematical equation exists to identify this? here is some sample data with some up trends and downtrends x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27