polynomials

vba use linest to calculate polynomial coefficients and index to output

南笙酒味 提交于 2020-01-17 03:23:41
问题 I have two rows of data, fracture pressure and depth. I have to code in vba to generate the polynomial (quadratic for this case) equation and then output the coefficients to the worksheet. I am using Linest and Index. For this two rows of data, I don't know how many datasets I have because I need to delete some noisy data first (the definition of noisy data is randomly so the number of datasets vary each time), so I can't use something like "A17:A80" in the linest function. However, it looks

Multivariate polynomial division in sage

跟風遠走 提交于 2020-01-02 10:02:29
问题 I try to do a simple division of polynomials in two variables using sage. Unfortunately, I get an unexpected result, as is illustrated in the code below. I tried several different ways to instantiate the ring and its variables, but the result stays the same. Using the %-operator to get a rest of a division yields the same results. Any ideas? R, (x, y) = PolynomialRing(RationalField(), 2, 'xy').objgens() t = x^2*y^2 + x^2*y - y + 1 f1 = x*y^2 + x f2 = x*y - y^3 (q, r) = t.quo_rem(f1) print

Multivariate polynomial division in sage

谁都会走 提交于 2020-01-02 10:02:01
问题 I try to do a simple division of polynomials in two variables using sage. Unfortunately, I get an unexpected result, as is illustrated in the code below. I tried several different ways to instantiate the ring and its variables, but the result stays the same. Using the %-operator to get a rest of a division yields the same results. Any ideas? R, (x, y) = PolynomialRing(RationalField(), 2, 'xy').objgens() t = x^2*y^2 + x^2*y - y + 1 f1 = x*y^2 + x f2 = x*y - y^3 (q, r) = t.quo_rem(f1) print

What does the capital letter “I” in R linear regression formula mean?

我与影子孤独终老i 提交于 2019-12-28 02:35:07
问题 I haven't been able to find an answer to this question, largely because googling anything with a standalone letter (like "I") causes issues. What does the "I" do in a model like this? data(rock) lm(area~I(peri - mean(peri)), data = rock) Considering that the following does NOT work: lm(area ~ (peri - mean(peri)), data = rock) and that this does work: rock$peri - mean(rock$peri) Any key words on how to research this myself would also be very helpful. 回答1: I isolates or insulates the contents

Calculating the coefficients of a differentiated polynomial using re.compile and searching in python

。_饼干妹妹 提交于 2019-12-24 23:07:49
问题 Testing the polynomial ' 2x^3+4x^2+8x-16 ' my code below outputs [6, 8] as the coefficients of the differentiated polynomial. However, the output should be [6, 8, 8] . Why is the function getNewCoefficients producing the wrong result? What would be a good way to produce the correct result? def getNumbers(polynomial): regex = re.compile(r"[+-]?\d+(?:\.\d+)?") return regex.findall(polynomial) def formatNumbers(numbers): formattedNumbers = [] for e in numbers: if (e[0] == '+'): formattedNumbers

The roots of the characteristic polynomial and the eigenvalues are not the same

时光毁灭记忆、已成空白 提交于 2019-12-24 07:53:48
问题 This is matrix B B = [1 2 0 ; 2 4 6 ; 0 6 5] The result of eig(B) is: {-2.2240, 1.5109, 10.7131} and the characteristic polynomial of B by this link is syms x polyB = charpoly(B,x) x^3 - 10*x^2 - 11*x + 36 but the answer of solve(polyB) is 133/(9*(3^(1/2)*5492^(1/2)*(i/3) + 1009/27)^(1/3)) + ((3^(1/2)*5492^(1/2)*i)/3 + 1009/27)^(1/3) + 10/3 (3^(1/2)*(133/(9*(3^(1/2)*5492^(1/2)*(i/3) + 1009/27)^(1/3)) - ((3^(1/2)*5492^(1/2)*i)/3 + 1009/27)^(1/3))*i)/2 - 133/(18*(3^(1/2)*5492^(1/2)*(i/3) + 1009

numpy calculate polynom efficiently

泪湿孤枕 提交于 2019-12-23 10:26:26
问题 I'm trying to evaluate polynomial (3'd degree) using numpy. I found that doing it by simpler python code will be much more efficient. import numpy as np import timeit m = [3,7,1,2] f = lambda m,x: m[0]*x**3 + m[1]*x**2 + m[2]*x + m[3] np_poly = np.poly1d(m) np_polyval = lambda m,x: np.polyval(m,x) np_pow = lambda m,x: np.power(x,[3,2,1,0]).dot(m) print 'result={}, timeit={}'.format(f(m,12),timeit.Timer('f(m,12)', 'from __main__ import f,m').timeit(10000)) result=6206, timeit=0.0036780834198

efficient way to take powers of a vector

六月ゝ 毕业季﹏ 提交于 2019-12-23 07:49:31
问题 I wrote a code that numerically uses Legendre polynomials up to some high n-th order. For example: .... case 8 p = (6435*x.^8-12012*x.^6+6930*x.^4-1260*x.^2+35)/128; return case 9 ... If the vector x is long this can become slow. I saw that there is a performance difference between say x.^4 and x.*x.*x.*x and thought I could use this to improve my code. I've used timeit and found that for: x=linspace(0,10,1e6); f1= @() power(x,4) f2= @() x.4; f3= @() x.^2.^2 f4= @() x.*x.*x.*x f4 is faster by

polynomial addition using linked list in java

和自甴很熟 提交于 2019-12-22 17:28:12
问题 Here's my implementation of a addition of two polynomials using a linked List. For example if I want to add 3x^2+5^x+3 and 4x^3+5x+2 first I check if there are similar exponents in the two polynomials and if so I add their coefficients and I append the exponents to a string. After adding similar exponents then using the string I add the remaining parts in both polynomials to the final result. public class Node2{ int coef; int exp; Node2 next; Node2(int c,int e,Node2 n){ coef=c; exp=e; next=n;

Laguerre polynomials in MATLAB

时光毁灭记忆、已成空白 提交于 2019-12-20 04:45:07
问题 I tried using the .. command in MATLAB to generate Laguerre polynomials but I keep getting this error every time: I found this in the help section: Since I have defined x as symbolic I shouldn't be getting this error. Also on website I found this which says that the function does not run in MATLAB. Can anyone help? Thanks in advance 回答1: Like you say, and the matlab help says this function only works inside mupad, maybe in later versions it works in matlab console. If you want to use it,