考虑一下我在maxima中得到这个输出:
b : solve([ans,ans2],[x,y]);
float(b);
[[x=0.0,y=%r11],[x=-5.0,y=0.0],[x=1.0422311,y=0.537285*%i],[x=-0.940313,y=0.537285*%i],[x=-5.1019178,y=0.537285*
%i],[x=1.0422311,y=-0.537285],[x=-0.940313,y=-0.537285],[x=-5.1019178,y=-0.537285],[x=1.0422311,y=-0.537285*%i],[x=-
0.940313,y=-0.537285*%i],[x=-5.1019178,y=-0.537285*%i],[x=1.0422311,y=0.537285],[x=-0.940313,y=0.537285],[x=-5.1019178,y
=0.537285]]
我如何对解决方案进行排序,只获得域-2上的解决方案。 x< 2和-2< y< 2?
我已经寻找了这个解决方案,它会非常有用,因为我可以找到我正在寻找的东西而没有任何“噪音”。
这可能是我在“求解”命令括号中写的吗?
提前多多感谢!
答案 0 :(得分:1)
您可以使用sublist
b: [[x=0.0,y=%r11],[x=-5.0,y=0.0],[x=1.0422311,y=0.537285*%i],[x=-0.940313,y=0.537285*%i],[x=-5.1019178,y=0.537285*
%i],[x=1.0422311,y=-0.537285],[x=-0.940313,y=-0.537285],[x=-5.1019178,y=-0.537285],[x=1.0422311,y=-0.537285*%i],[x=-
0.940313,y=-0.537285*%i],[x=-5.1019178,y=-0.537285*%i],[x=1.0422311,y=0.537285],[x=-0.940313,y=0.537285],[x=-5.1019178,y
=0.537285]];
filter(s):= block([x: assoc(x, s), y: assoc(y, s)],
featurep(x, real) and featurep(y, real) and x>-2 and x<2 and y>-2 and y<2);
sublist(b, 'filter);
返回:
(%o9) [[x = 1.0422311, y = - 0.537285], [x = - 0.940313, y = - 0.537285],
[x = 1.0422311, y = 0.537285], [x = - 0.940313, y = 0.537285]]