polynomial-math

Algorithm in C to calculate coefficients of polynomial using Lagrange interpolation

半城伤御伤魂 提交于 2019-12-23 04:42:29
问题 I've been stuck on this for a while now. I'm writing an algorithm in C to pull out the coefficients of a polynomial using Lagrange's interpolation method. My code partially works, for instance if we do the first example here http://en.wikipedia.org/wiki/Lagrange_polynomial#Example_1 then the code can print out the first 2 coefficients (0 and 4.834848) Similarly with example 3 on that article, it will print the 2 coefficients 6 and -11. I need to be able to accurately get all the coefficients

Interpolate polynomial over a finite field

十年热恋 提交于 2019-12-22 09:00:57
问题 I want to use python interpolate polynomial on points from a finite-field and get a polynomial with coefficients in that field. Currently I'm trying to use SymPy and specifically interpolate (from sympy.polys.polyfuncs ), but I don't know how to force the interpolation to happen in a specific gf. If not, can this be done with another module? Edit: I'm interested in a Python implementation/library. 回答1: SymPy's interpolating_poly does not support polynomials over finite fields. But there are

Finding real roots of quartic equation using ferrari's method

非 Y 不嫁゛ 提交于 2019-12-21 21:10:52
问题 I am currently trying to solve a quartic equation using Ferrari's method from Wikipedia. I want to retrieve only the real roots, discarding the imaginary one. My implementation does not return the good value for real roots. I can't find the mistakes in the formula. My CubicEquation works as expected, and my bi-quadratic solving either. Now, I am only missing the Ferrari's method to be done but I can't make it work! Here's my class: public class QuarticFunction { private final double a;

Why is `poly` complaining about degree less than number of unique points?

大憨熊 提交于 2019-12-21 09:15:02
问题 I am trying to generate orthogonal polynomials in R, but I keep getting an error I don't understand > poly(1:1000, 50) Error in poly(1:1000, 50) : 'degree' must be less than number of unique points Surely the number of unique points is 1000? What does it mean? Is this a bug, and if so does anyone know I work around? Edit: This appears to kick in for degree > 27 for any number of points - is this an undocumented limit? 回答1: Numerical overflow. If you look at the code for poly , you'll see it's

Finding roots of polynomial in Java

时光怂恿深爱的人放手 提交于 2019-12-19 09:09:50
问题 I need to find (approximate, numerical) solution to Legendre polynomial. I tried the several Java libraries but none have what I am looking for (the closest is commons-math which even has code for finding the solutions in Laguerre Solver but does not expose the method). Is there an existing solution or do I need to implement my own? 回答1: You can use efficient-java-matrix-library Please find the below sample example for the same public class PolynomialRootFinder { /** * <p> * Given a set of

Solving a Linear Diophantine Equation(see description for examples)

大城市里の小女人 提交于 2019-12-18 04:09:14
问题 Let me start off by clarifying that(before you guys dismiss me), this is not a homework problem and I'm not a university student. :) EDIT Thanks to @Klas and others, my question now boils down to a mathematical equation which needs to be solved programmatically. I'm looking for an algorithm/code which solves Linear Diophantine Equation . For lesser mortals like me, here's how such an equation looks like: Example 1: 3x + 4y + 5z = 25 (find all possible values of x,y,z) Example 2: 10p + 5q + 6r

Fitting polynomial model to data in R

血红的双手。 提交于 2019-12-17 04:40:05
问题 I've read the answers to this question and they are quite helpful, but I need help particularly in R. I have an example data set in R as follows: x <- c(32,64,96,118,126,144,152.5,158) y <- c(99.5,104.8,108.5,100,86,64,35.3,15) I want to fit a model to these data so that y = f(x) . I want it to be a 3rd order polynomial model. How can I do that in R? Additionally, can R help me to find the best fitting model? 回答1: To get a third order polynomial in x (x^3), you can do lm(y ~ x + I(x^2) + I(x

Canonical coefficients from Newton polynomial

℡╲_俬逩灬. 提交于 2019-12-14 01:40:34
问题 A while ago I implemented a Polynom approximation for a game I programmed. I am using Newton's pyramide method. It took me quite a while to figure it out, but my solution requires to calculate the binomial coefficients and I also have to sum up all the coefficients for the final coefficient of each power (since solving this problem is similar to squaring, cubing.. terms and calculating the binomial coefficients) For example: pick k out of n of the bionomeal terms and add them one pick is

efficiently determining if a polynomial has a root in the interval [0,T]

大城市里の小女人 提交于 2019-12-13 11:54:02
问题 I have polynomials of nontrivial degree (4+) and need to robustly and efficiently determine whether or not they have a root in the interval [0,T]. The precise location or number of roots don't concern me, I just need to know if there is at least one. Right now I'm using interval arithmetic as a quick check to see if I can prove that no roots can exist. If I can't, I'm using Jenkins-Traub to solve for all of the polynomial roots. This is obviously inefficient since it's checking for all real

I/O Loop in Haskell

删除回忆录丶 提交于 2019-12-13 09:05:56
问题 I am currently working on this Haskell problem and I seem to be stuck. Write a function, evalpoly, that will ask a user for the degree of a single variable polynomial, then read in the coefficients for the polynomial (from highest power to lowest), then for a value, and will output the value of the polynomial evaluated at that value. As an example run: > evalpoly What is the degree of the polynomial: 3 What is the x^3 coefficient: 1.0 What is the x^2 coefficient: - 2.0 What is the x^1