在枫树中求解方程系统
我有一个n个方程的系统和n个未知变量,符号总和。我想创建一个循环以在输入n时求解此方程系统。
y:= s-> 1/6 cos(3 s);
a:=(k,s) - > PICEEWISE(k<> 0,1/2 exp(k s i)/abs(k),k = 0,ln(2) exp(s 0 i) - sin(s));
s:=(j,n) - > 2 j pi/(2*n + 1);
n:= 1; 对于从-n到n的J eqn [j]:= sum((a(k,s(j,n))))。(a [k]),k = -n .. n .. n)= y(s(j,n)); 结束;
等式:= seq(eqn [i],i = -n .. n);
solve({eqs},{a [i]});
在此处输入图像描述 请帮助我!
I have a system of n equations and n unknown variables under symbol sum. I want to create a loop to solve this system of equations when inputting n.
y := s -> 1/6cos(3s);
A := (k, s) -> piecewise(k <> 0, 1/2exp(ksI)/abs(k), k = 0, ln(2)exp(s0I) - sin(s));
s := (j, n) -> 2jPi/(2*n + 1);
n := 1;
for j from -n to n do
eqn[j] := sum((A(k, s(j, n))) . (a[k]), k = -n .. n) = y(s(j, n));
end do;
eqs := seq(eqn[i], i = -n .. n);
solve({eqs}, {a[i]});
enter image description here
Please help me out!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在您的明文代码中添加了一些丢失的乘法符号,以重现它。
您可以将名称集(为此解决)作为可选参数。但这必须包含实际名称,而不仅仅是抽象占位符
a [i]
。您也可以在此处省略不确定的名称,作为可选的参数到
solve
(因为您希望为所有这些求解,并且没有其他名称)。对于
n:= 3
和n:= 4
它有助于solve
如果exp
呼叫,请在此处更快获得结果变成触发电话。即,如果
n
高于4,则可能需要等待精确的结果(符号)结果。但是,即使在n:= 10
对我来说,浮点结果也很快。也就是说,调用fsolve
,而不是solve
。但是,即使那也可能是不必要的,因为似乎以下是
n&gt; = 3
的解决方案。此处所有变量都设置为零,除A [-3]
和A [3]
都设置为1/2
。I added some missing multiplication symbols to your plaintext code, to reproduce it.
You can pass the set of names (for which to solve) as an optional argument. But that has to contain the actual names, and not just the abstract placeholder
a[i]
as you tried it.You could also omit the indeterminate names here, as optional argument to
solve
(since you wish to solve for all of them, and no other names are present).For
n:=3
andn:=4
it helpssolve
to get a result quicker here ifexp
calls are turned into trig calls. Ie,If
n
is higher than 4 you might have to wait long for an exact (symbolic) result. But even atn:=10
a floating-point result was fast for me. That is, callingfsolve
instead ofsolve
.But even that might be unnecessary, as it seems that the following is a solution for
n>=3
. Here all the variables are set to zero, excepta[-3]
anda[3]
which are both set to1/2
.