如何强制 Mathematica 在 Simplify 和 FullSimplify 中包含用户定义的函数?
假设我有一个关系 r^2 = x^2 + y^2。现在假设经过计算我得到了 x 和 y 的复杂输出,但理论上可以通过使用上述关系来简化很多。我如何告诉 Mathematica 这样做?
我指的是替换规则 x^2+y^2 -> 的情况r^2 和使用带有假设的 Simplify/FullSimplify 将不起作用,例如,如果输出为 x/y + y/x = (x^2+y^2)/(xy) = r^2/(xy)。
简化对于内置函数非常有效,但对于用户定义的函数却不起作用!所以本质上我希望我的函数被像内置函数一样对待!
Let's say I have a relation r^2 = x^2 + y^2. Now suppose after a calculation i get a complicated output of x and y, but which could in theory be simplified a lot by using the above relation. How do I tell Mathematica to do that?
I'm referring to situations where replacement rules x^2+y^2 -> r^2 and using Simplify/FullSimplify with Assumptions won't work, e.g. if the output is x/y + y/x = (x^2+y^2)/(xy) = r^2/(xy).
Simplification works really well with built in functions but not with user defined functions! So essentially I would like my functions to be treated like the built in functions!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信您正在寻找TransformationFunctions。
I believe you are looking for TransformationFunctions.
在你给出的例子中
。但我了解到,在很多情况下,这样的替代是行不通的。我曾经得到的一个提示是用一个更简单的 LHS 替换这个替代品,例如:
x^2 -> r^2-y^2
(或者甚至是x->Sqrt[r^2-y^2]
如果您知道 x 和 y 的值允许这样做)。In the example you give
works. But I've learned that in many occasions replacements like this don't work. A tip I once got was to replace this replacement with one which has a more simpler LHS like:
x^2 -> r^2-y^2
(or evenx->Sqrt[r^2-y^2]
if you know that the values of x and y allow this).