Mathematica、Arg 和简化

发布于 2024-10-05 22:41:29 字数 423 浏览 0 评论 0原文

我在使用 Mathematica 处理复数时遇到问题。我做错了什么吗?

两个例子:

  1. ComplexExpand[(x + I y)^(1/2)] 产量 (x^2 + y^2)^(1/4) Cos[1/2 Arg[x + I y]] + I (x^2 + y^2)^(1 /4) Sin[1/2 Arg[x + I y]]

    到目前为止我还没有找到办法 更简单的结果(确实存在!)

  2. ComplexExpand[Sqrt[x^2 + y^2] Cos[Arg[x + I y]] + I Sqrt[x^2 + y ^2] Sin[Arg[x + I y]]]
    产生与 ComplexExpand 参数相同的结果,但显然应该是 x + I y!

提前致谢!

I've got problems in using Mathematica with complex numbers. Am I doing something wrong?

Two examples:

  1. ComplexExpand[(x + I y)^(1/2)]
    yields (x^2 + y^2)^(1/4) Cos[1/2 Arg[x + I y]] + I (x^2 + y^2)^(1/4)
    Sin[1/2 Arg[x + I y]]

    and I've found no way so far to get
    a simpler result (which does exist!)

  2. ComplexExpand[Sqrt[x^2 + y^2] Cos[Arg[x + I y]] + I Sqrt[x^2 + y^2] Sin[Arg[x + I y]]]
    yields the same result of the argument of ComplexExpand, while it should obviously be x + I y !

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雅心素梦 2024-10-12 22:41:29

对于第二个,请记住 Mathematica 无法对您的符号做出假设,因此默认情况下“数字”是复数。

这就是为什么当你输入:

a = Sqrt[x^2 + y^2] Cos[Arg[x + I y]] + I Sqrt[x^2 + y^2] Sin[Arg[x + I y]];
ComplexExpand@a

你会得到

Sqrt[x^2 + y^2] Cos[Arg[x + I y]] +  I Sqrt[x^2 + y^2] Sin[Arg[x + I y]]

或者如果你输入

FullSimplify@a

你会得到

E^(I Arg[x + I y]) Sqrt[x^2 + y^2]

Just 因为 Mathematica 不知道 X 和 Y 是 REALS

但您可以显式声明它,因此 Mathematica 可以将它们视为实数。

试试这个:

a = Sqrt[x^2 + y^2] Cos[Arg[x + I y]] + I Sqrt[x^2 + y^2] Sin[Arg[x + I y]];
$Assumptions = Element[x, Reals] && Element[y, Reals]
FullSimplify[a]

你会得到

x + I y   

记住,重置你的 $Asductions 只需要

$Assumptions = True

但一般来说,不要指望 Mathematica 会按照你想要的方式呈现复数......

For the second one, remember that Mathematica can't make assumptions on your symbols, so a "number" is complex by default.

That's the reason why when you enter:

a = Sqrt[x^2 + y^2] Cos[Arg[x + I y]] + I Sqrt[x^2 + y^2] Sin[Arg[x + I y]];
ComplexExpand@a

you get

Sqrt[x^2 + y^2] Cos[Arg[x + I y]] +  I Sqrt[x^2 + y^2] Sin[Arg[x + I y]]

or if you enter

FullSimplify@a

you get

E^(I Arg[x + I y]) Sqrt[x^2 + y^2]

Just because Mathematica doesn't know that X and Y are REALS.

But you can explicitly declare it, so Mathematica is allowed to treat them as reals numbers.

Try this:

a = Sqrt[x^2 + y^2] Cos[Arg[x + I y]] + I Sqrt[x^2 + y^2] Sin[Arg[x + I y]];
$Assumptions = Element[x, Reals] && Element[y, Reals]
FullSimplify[a]

and you'll get

x + I y   

Remember that resetting your $Assumptions only needs

$Assumptions = True

But in general, don't expect Mathematica will render complex numbers the way you want them...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文