联接数学变量 [英] Join math variables

查看:88
本文介绍了联接数学变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够加入数学变量.我的意思是,例如,可以加入以下内容(我不知道这是否实际上称为加入):

I would like to be able to join math variables. What I mean with this is that, for example, the following can be joined (I don''t know if this is actually called joining):

2x^2 - 5x^2 + 2x + 3x - 5 + 6

加入(等于):

-3x^2 + 5x + 1

是否有图书馆或有人提供用于此类操作的代码段?如果您有提示或简单的技巧,也请告诉我.谢谢.

Is there a library or does someone have a code snippet for such actions? If you have a hint or an easy trick, also please tell me. Thanks.

推荐答案

您正在谈论的过程称为简化.我想通过遍历每个元素(其中元素0是2x 2 ,元素1是-5x 2 ,等等)并记下每个元素来完成此操作唯一索引(功率).当遇到之前发生的索引时,请将当前元素添加到具有匹配索引的唯一元素中,然后继续.

此后,您只需要显示它即可.这样,您就可以遍历唯一元素列表并进行打印.

The process you''re talking about is called simplifying. I would assume it''s done by going through each element (where element 0 is 2x2, element 1 is -5x2, etc) and making a note of each unique index (the power). When you encounter an index that''s occurred before, add the current element to the unique element that''s got the matching index and move on.

After that you just need to display it. With this, you just iterate through the list of unique elements and print them.


这篇关于联接数学变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆