-1

So...I want to create five different polynomials inside a loop in order to make a Sturm sequence, but I don't seem to be able to dynamically name a set of polynomials with different names.

For example:

In the first iteration it would define p1(x):whatever

Then, in the second iteration it would define p2(x):whatever

Lastly, in the Nth iteration it would define pn(x):whatever

So far, I have managed to simply store them in a list and call them one by one by its position. But surely there is a more professional way to accomplish this?

Sorry for the non-technical language :)

4

1 回答 1

0

我认为下标变量在这里是合适的。就像是:

for k:1 thru 5 do
    p[k] : make_my_polynomial(k);

那么p[1], ...,p[5]是你的多项式。

当您分配给一个下标变量时,例如foo[bar]: baz,其中foo尚未定义为列表或数组的地方,Maxima 创建了它所谓的“未声明数组”,它只是一个查找表。

编辑:您可以引用下标变量而不为它们分配任何值。例如,x^2 - 3*x + 1您可以写u[i]^2 - 3*u[i] + 1whereu[i]尚未分配任何值。许多(大多数?)函数将下标变量视为与非下标变量相同,例如diff(..., u[i])区分 wrt u[i]

于 2019-01-17T23:36:13.790 回答