如何将多项式变换到另一个坐标系?

发布于 2024-07-06 01:52:18 字数 472 浏览 6 评论 0 原文

使用各种矩阵数学,我求解了一个方程组,得出 n 次多项式的系数,

Ax^(n-1) + Bx^(n-2) + ... + Z

然后在给定的 x 范围内评估多项式,本质上我正在渲染多项式曲线。 现在问题来了。 我在一个我们称之为“数据空间”的坐标系中完成了这项工作。 现在我需要在另一个坐标空间中呈现相同的曲线。 在坐标空间之间转换输入/输出很容易,但最终用户只对系数 [A,B,....,Z] 感兴趣,因为他们可以自己重建多项式。 如何呈现第二组系数 [A',B',....,Z'],它们表示不同坐标系中相同形状的曲线。

如果有帮助的话,我正在二维空间中工作。 普通的旧 x 和 y。 我还觉得这可能涉及将系数乘以变换矩阵? 它会合并坐标系之间的比例/平移因子吗? 它会是这个矩阵的逆矩阵吗? 我觉得我正朝着正确的方向前进......

更新:坐标系是线性相关的。 会有有用的信息吗?

Using assorted matrix math, I've solved a system of equations resulting in coefficients for a polynomial of degree 'n'

Ax^(n-1) + Bx^(n-2) + ... + Z

I then evaulate the polynomial over a given x range, essentially I'm rendering the polynomial curve. Now here's the catch. I've done this work in one coordinate system we'll call "data space". Now I need to present the same curve in another coordinate space. It is easy to transform input/output to and from the coordinate spaces, but the end user is only interested in the coefficients [A,B,....,Z] since they can reconstruct the polynomial on their own. How can I present a second set of coefficients [A',B',....,Z'] which represent the same shaped curve in a different coordinate system.

If it helps, I'm working in 2D space. Plain old x's and y's. I also feel like this may involve multiplying the coefficients by a transformation matrix? Would it some incorporate the scale/translation factor between the coordinate systems? Would it be the inverse of this matrix? I feel like I'm headed in the right direction...

Update: Coordinate systems are linearly related. Would have been useful info eh?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

柠檬心 2024-07-13 01:52:19

如果您必须多次计算变量 z = ax+b 的变化(我的意思是对于许多不同的多项式),泰勒的答案就是正确的答案。 另一方面,如果只需执行一次,则将矩阵系数的计算与最终评估结合起来要快得多。 最好的方法是通过 Hörner 的方法对 (ax+b) 点处的多项式进行符号求值:

  • 将多项式系数存储在向量 V 中(一开始,所有系数均为零),并且对于 i = n 为 0 ,将其乘以 (ax+b) 并加上 Ci
  • 添加 Ci 表示将其与常数项相加
  • 乘以 (ax+b) 表示将所有系数乘以 b 生成向量 K1,将所有系数乘以 a 并移位将它们从常数项中移出到向量 K2 中,并将 K1+K2 放回到 V 中。

这将更容易编程,并且计算速度更快。

请注意,将 y 更改为 w = cy+d 非常容易。 最后,正如马蒂亚斯特指出的那样,坐标的一般变化不会给你一个多项式。

技术说明:如果您仍然想计算矩阵 T(由 Tyler 定义),您应该使用 Pascal 规则的加权版本来计算它(这是 Hörner 计算隐式执行的操作):

t< sub>i,j = b ti,j-1 + a ti-1,j-1

这样,您就可以逐列简单地计算它, 从左到右。

Tyler's answer is the right answer if you have to compute this change of variable z = ax+b many times (I mean for many different polynomials). On the other hand, if you have to do it just once, it is much faster to combine the computation of the coefficients of the matrix with the final evaluation. The best way to do it is to symbolically evaluate your polynomial at point (ax+b) by Hörner's method:

  • you store the polynomial coefficients in a vector V (at the beginning, all coefficients are zero), and for i = n to 0, you multiply it by (ax+b) and add Ci.
  • adding Ci means adding it to the constant term
  • multiplying by (ax+b) means multiplying all coefficients by b into a vector K1, multiplying all coefficients by a and shifting them away from the constant term into a vector K2, and putting K1+K2 back into V.

This will be easier to program, and faster to compute.

Note that changing y into w = cy+d is really easy. Finally, as mattiast points out, a general change of coordinates will not give you a polynomial.

Technical note: if you still want to compute matrix T (as defined by Tyler), you should compute it by using a weighted version of Pascal's rule (this is what the Hörner computation does implicitely):

ti,j = b ti,j-1 + a ti-1,j-1

This way, you compute it simply, column after column, from left to right.

高速公鹿 2024-07-13 01:52:19

你有这样的方程:

y = Ax^(n-1) + Bx^(n-2) + ... + Z

在 xy 空间中,并且你希望它在某个 x'y' 空间中。 您需要的是变换函数 f(x) = x' 和 g(y) = y' (或 h(x') = x 和 j(y') = y)。 在第一种情况下,您需要求解 x 并求解 y。 获得 x 和 y 后,您可以将这些结果代入原始方程并求解 y'。

这是否微不足道取决于用于从一个空间转换到另一个空间的函数的复杂性。 例如,如下方程:

5x = x' and 10y = y'

非常容易求解结果

y' = 2Ax'^(n-1) + 2Bx'^(n-2) + ... + 10Z

You have the equation:

y = Ax^(n-1) + Bx^(n-2) + ... + Z

In xy space, and you want it in some x'y' space. What you need is transformation functions f(x) = x' and g(y) = y' (or h(x') = x and j(y') = y). In the first case you need to solve for x and solve for y. Once you have x and y, you can substituted those results into your original equation and solve for y'.

Whether or not this is trivial depends on the complexity of the functions used to transform from one space to another. For example, equations such as:

5x = x' and 10y = y'

are extremely easy to solve for the result

y' = 2Ax'^(n-1) + 2Bx'^(n-2) + ... + 10Z
ζ澈沫 2024-07-13 01:52:19

如果输入空间是线性相关的,那么矩阵应该能够将一组系数转换为另一组系数。 例如,如果您的“原始”x 空间中有多项式:

ax^3 + bx^2 + cx + d

并且您想要转换为不同的 w 空间,其中 w = px+q

那么您想要找到a'、b'、c' 和 d' 使得

ax^3 + bx^2 + cx + d = a'w^3 + b'w^2 + c'w + d'

并且通过一些代数,

a 'w^3 + b'w^2 + c'w + d' = a'p^3x^3 + 3a'p^2qx^2 + 3a'pq^2x + a'q^3 + b'p^ 2x^2 + 2b'pqx + b'q^2 + c'px + c'q + d'

因此

a = a'p^3

b = 3a'p^2q + b'p^2

c = 3a'pq ^2 + 2b'pq + c'p

d = a'q^3 + b'q^2 + c'q + d'

可以重写为矩阵问题并求解。

If the input spaces are linearly related, then yes, a matrix should be able to transform one set of coefficients to another. For example, if you had your polynomial in your "original" x-space:

ax^3 + bx^2 + cx + d

and you wanted to transform into a different w-space where w = px+q

then you want to find a', b', c', and d' such that

ax^3 + bx^2 + cx + d = a'w^3 + b'w^2 + c'w + d'

and with some algebra,

a'w^3 + b'w^2 + c'w + d' = a'p^3x^3 + 3a'p^2qx^2 + 3a'pq^2x + a'q^3 + b'p^2x^2 + 2b'pqx + b'q^2 + c'px + c'q + d'

therefore

a = a'p^3

b = 3a'p^2q + b'p^2

c = 3a'pq^2 + 2b'pq + c'p

d = a'q^3 + b'q^2 + c'q + d'

which can be rewritten as a matrix problem and solved.

未央 2024-07-13 01:52:19

如果我正确理解你的问题,则不能保证在更改坐标后该函数将保持多项式。 例如,令y=x^2,则新坐标系x'=y,y'=x。 现在方程变为 y' = sqrt(x'),它不是多项式。

If I understand your question correctly, there is no guarantee that the function will remain polynomial after you change coordinates. For example, let y=x^2, and the new coordinate system x'=y, y'=x. Now the equation becomes y' = sqrt(x'), which isn't polynomial.

岁月染过的梦 2024-07-13 01:52:18

问题陈述有点不清楚,所以首先我将澄清我自己的解释:

你有一个多项式函数

f(x) = Cnxn + Cn-1xn-1 + ... + C0

[我更改了 A、B、... 0 以便更轻松地使用下面的线性代数。]

Z 到 Cn, Cn-1, ..., C 进行如下转换: z = ax + b   您想用它来查找相同多项式的系数,但以z表示:

f(z) = Dn zn + Dn-1zn-1 + ... + D0

这可以通过一些线性代数很容易地完成。 特别是,您可以定义一个 (n+1)×(n+1) 矩阵 T,它允许我们进行矩阵

乘法 d = T * c

其中 d 是具有顶部条目的列向量D0,到最后一个条目Dn,列向量c类似于Ci 系数,矩阵 T 有 (i,j)-第 [ith 行,j th 列] 条目 tij

  给出 tij =(j选择iai bji

其中 (j select i) 为二项式系数,当 i > 时 = 0 j。 另外,与标准矩阵不同,我认为 i,j 每个范围从 0 到 n(通常从 1 开始)。

当您手动插入 z=ax+b 并使用 二项式定理

The problem statement is slightly unclear, so first I will clarify my own interpretation of it:

You have a polynomial function

f(x) = Cnxn + Cn-1xn-1 + ... + C0

[I changed A, B, ... Z into Cn, Cn-1, ..., C0 to more easily work with linear algebra below.]

Then you also have a transformation such as:   z = ax + b   that you want to use to find coefficients for the same polynomial, but in terms of z:

f(z) = Dnzn + Dn-1zn-1 + ... + D0

This can be done pretty easily with some linear algebra. In particular, you can define an (n+1)×(n+1) matrix T which allows us to do the matrix multiplication

  d = T * c ,

where d is a column vector with top entry D0, to last entry Dn, column vector c is similar for the Ci coefficients, and matrix T has (i,j)-th [ith row, jth column] entry tij given by

  tij = (j choose i) ai bj-i.

Where (j choose i) is the binomial coefficient, and = 0 when i > j. Also, unlike standard matrices, I'm thinking that i,j each range from 0 to n (usually you start at 1).

This is basically a nice way to write out the expansion and re-compression of the polynomial when you plug in z=ax+b by hand and use the binomial theorem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文