Mathematica:以极坐标形式显示复数

发布于 2024-09-27 12:33:22 字数 1053 浏览 2 评论 0原文

我想以三角函数形式显示复数。例如:

z = (-4)^(1/4);

我不确定该命令是什么,而且写起来很愚蠢:

alt text

我想,该命令是 ExpToTrig,但解决方案不可能只是 1+i (或者可以,但我误用了它?)。如何以三角函数形式显示复数。

编辑:

命令是 ExpToTrig,它只是没有给出所有解决方案(或者我无法找出如何解决)。终于通过编写纯函数 NrootZpolar[n][z] 解决了我的问题:

NrootZpolar := 
 Function[x, 
  Function[y, 
       ( Abs[y] ^ (1/x) *
       ( Cos[((Arg[y] + 360° * Range[0, x - 1]) / x)] + 
       I*Sin[((Arg[y] + 360° * Range[0, x - 1]) / x)]))
  ]
 ]

并使用:

In[689]:= FullSimplify[NrootZpolar1[4][-4]]
Out[689]= {1 + I, -1 + I, -1 - I, 1 - I}

可视化:

ComplexListPlot[list_] := ListPlot[Transpose[{Re[list], Im[list]}], AxesLabel -> {Re, Im}, PlotLabel -> list, PlotMarkers -> Automatic]
Manipulate[ComplexListPlot[FullSimplify[NrootZpolar1[n][z]]], {z, -10, 10}, {n, 1, 20}]

“替代文本”

I want to display complex numbers in trig form. For example:

z = (-4)^(1/4);

I'm not sure what the command for that is, and its silly to write:

alt text

I thought, that the command was ExpToTrig, but solution can't possibly be just 1+i (Or can it, and I'm misusing it?). How do display complex number in trig form.

Edit:

Command is ExpToTrig, it just does not give all the solutions (or i have failed to find out how). Finally solved my problem with writing a pure function NrootZpolar[n][z]:

NrootZpolar := 
 Function[x, 
  Function[y, 
       ( Abs[y] ^ (1/x) *
       ( Cos[((Arg[y] + 360° * Range[0, x - 1]) / x)] + 
       I*Sin[((Arg[y] + 360° * Range[0, x - 1]) / x)]))
  ]
 ]

And use:

In[689]:= FullSimplify[NrootZpolar1[4][-4]]
Out[689]= {1 + I, -1 + I, -1 - I, 1 - I}

To visualize:

ComplexListPlot[list_] := ListPlot[Transpose[{Re[list], Im[list]}], AxesLabel -> {Re, Im}, PlotLabel -> list, PlotMarkers -> Automatic]
Manipulate[ComplexListPlot[FullSimplify[NrootZpolar1[n][z]]], {z, -10, 10}, {n, 1, 20}]

alt text

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

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

发布评论

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

评论(3

再见回来 2024-10-04 12:33:22

您可以用极坐标形式 r(cos theta + i sin theta) 表示复数 z,其中 r = Abs[z] 且 theta = Arg[z]。因此,您需要的唯一 Mathematica 命令是 Abs[] 和 Arg[]。

You can express a complex number z in polar form r(cos theta + i sin theta) where r = Abs[z] and theta = Arg[z]. So the only Mathematica commands you need are Abs[] and Arg[].

℉絮湮 2024-10-04 12:33:22

如果您只需要偶尔这样做,那么您可以定义一个类似的函数

In[1]:= ComplexToPolar[z_] /; z \[Element] Complexes := Abs[z] Exp[I Arg[z]]

In[2]:= z = (-4)^(1/4);
In[3]:= ComplexToPolar[z]
Out[3]= Sqrt[2] E^((I \[Pi])/4)

In[4]:= ComplexToPolar[z] == z // FullSimplify
Out[4]= True

以便扩展函数(不是您问题的一部分),您使用

In[5]:= ComplexExpand[, TargetFunctions -> {Abs, Arg}]

最后,如果您总是希望以极坐标形式编写复数,则类似

In[6]:= Unprotect[Complex];
In[7]:= Complex /: MakeBoxes[Complex[a_, b_], StandardForm] := 
 With[{abs = Abs[Complex[a, b]], arg = Arg[Complex[a, b]]}, 
  RowBox[{MakeBoxes[abs, StandardForm], 
    SuperscriptBox["\[ExponentialE]", 
      RowBox[{"\[ImaginaryI]", MakeBoxes[arg, StandardForm]}]]}]]

将使转换自动进行

In[8]:= 1 + I
Out[8]= Sqrt[2]*E^(I*(Pi/4))

请注意,这仅适用于显式复数 - 即具有 FullFormComplex[a,b] 的数字。除非您对其使用类似 Simpify 的内容,否则它将在上面定义的 z 上失败。

If you only need to do it occasionally, then you could just define a function like

In[1]:= ComplexToPolar[z_] /; z \[Element] Complexes := Abs[z] Exp[I Arg[z]]

so that

In[2]:= z = (-4)^(1/4);
In[3]:= ComplexToPolar[z]
Out[3]= Sqrt[2] E^((I \[Pi])/4)

In[4]:= ComplexToPolar[z] == z // FullSimplify
Out[4]= True

For expanding out functions (not that this was part of your question) you use

In[5]:= ComplexExpand[, TargetFunctions -> {Abs, Arg}]

Finally, if you always want complex numbers written in polar form then something like

In[6]:= Unprotect[Complex];
In[7]:= Complex /: MakeBoxes[Complex[a_, b_], StandardForm] := 
 With[{abs = Abs[Complex[a, b]], arg = Arg[Complex[a, b]]}, 
  RowBox[{MakeBoxes[abs, StandardForm], 
    SuperscriptBox["\[ExponentialE]", 
      RowBox[{"\[ImaginaryI]", MakeBoxes[arg, StandardForm]}]]}]]

will make the conversion automatic

In[8]:= 1 + I
Out[8]= Sqrt[2]*E^(I*(Pi/4))

Note that this will only work on explicitly complex numbers -- ie those with the FullForm of Complex[a,b]. It will fail on the z defined above unless you use something like Simpify on it.

可遇━不可求 2024-10-04 12:33:22

从数学上来说,(-1)^(1/4) 是对符号的滥用。没有这样的数字。

您使用该令人厌恶的内容(:))表达的是方程的根:

z^4 == 1  

在 Mathematica 中(就像一般的数学一样)使用弧度比使用角度更方便。以弧度表示,您可以定义例如

 f[z1_,n_] := Abs[z] (Cos[Arg[z]] + I Sin[Arg[z]]) /.Solve[z^n+z1 == 0, z,Complex]

g[z1_,n_] := Abs[z] (Exp [I Arg[z]]) /.Solve[z^n+z1 == 0, z,Complex]  

根据您的符号偏好(三角或指数......但最后一个是首选)。

要获取所需的 (-4)^(1/5) 表达式,只需键入

g[4,5] or f[4,5]

Mathematically speaking, (-1)^(1/4) is an abuse on notation. There is no such a number.

What you are expressing using that abomination ( :) ) are the roots of an equation:

z^4 == 1  

In Mathematica (as in math in general) is more convenient to use radians than degrees. Expressed in radians, you may define for example

 f[z1_,n_] := Abs[z] (Cos[Arg[z]] + I Sin[Arg[z]]) /.Solve[z^n+z1 == 0, z,Complex]

or

g[z1_,n_] := Abs[z] (Exp [I Arg[z]]) /.Solve[z^n+z1 == 0, z,Complex]  

depending on your notation preference (trig or exponential ... but the last is preferred).

To get your desired expression for (-4)^(1/5) just type

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