使用Mathematica绘制随机多项式的根

使用ListPlot和NSolve直接绘制:

复制代码
(*返回系数为r和s之间整数的n次随机多项式*) 
eq[n_, r_, s_] := RandomInteger[{r, s}, {n}] . Array[Power[x, # - 1] &, n] 
(*返回给定随机多项式的根所对应的笛卡尔坐标*) 
sol[n_, r_, s_] := {Re[#], Im[#]} & /@ (x /. NSolve[eq[n, r, s] == 0, x]) ListPlot[sol[400, 1, 6], PlotRange -> {{-1.5, 1.5}, {-1.5, 1.5}}, AspectRatio -> Automatic, PlotStyle -> {PointSize[Medium], Opacity[0.2], Black}]

使用Image和Fourier:

复制代码
SetSystemOptions["SparseArrayOptions" -> {"TreatRepeatedEntries" -> 1}];
\[Gamma] = 0.12;
\[Beta] = 1.0;
fLor = Compile[{{x, _Integer}, {y, _Integer}}, (\[Gamma]/(\[Gamma] + 
        x^2 + y^2))^\[Beta], RuntimeAttributes -> {Listable}(*,
   CompilationTarget->"C"*)];
<< Developer`
$PlotComplexPoints[list_, magnification_, paddingX_, paddingY_, 
  brightness_] := 
 Module[{RePos = 
    paddingX + 1 + Round[magnification (# - Min[#])] &[Re[list]], 
   ImPos = paddingY + 1 + Round[magnification (# - Min[#])] &[Im[list]],
    sparse, lor, dimX, dimY}, dimX = paddingX + Max[RePos];
  dimY = paddingY + Max[ImPos];
  Image[(brightness Sqrt[dimX dimY] Abs[
       InverseFourier[
        Fourier[SparseArray[
           Thread[{ImPos, RePos}\[Transpose] -> 
             ConstantArray[1, Length[list]]], {dimY, dimX}]] Fourier[
          RotateRight[
           fLor[#[[All, All, 1]], #[[All, All, 2]]] &@
            Outer[List, Range[-Floor[dimY/2], Floor[(dimY - 1)/2]], 
             Range[-Floor[dimX/2], Floor[(dimX - 1)/2]]], {Floor[
             dimY/2], 
            Floor[dimX/2]}]]]])\[TensorProduct]ToPackedArray[{1.0, 
      0.3, 0.1}], Magnification -> 1]]

直接绘制10000个随机的复平面点图:

复制代码
$PlotComplexPoints[ RandomComplex[{-1 - I, 1 + I}, 10000], 300, 20, 20, 10]

随机的150阶多项式的根的分布图:

复制代码
expr = Evaluate@Sum[RandomInteger[{1, 10}] #^k, {k, 150}] &; 
list = Table[N@Root[expr, k], {k, 150}]; 
$PlotComplexPoints[list, 320, 20, 20, 140]
相关推荐
阿Y加油吧9 小时前
力扣打卡——搜索二维矩阵、相交链表
线性代数·leetcode·矩阵
qq_2837200510 小时前
WebGL基础教程(十四):投影矩阵深度解析——正交 vs 透视,从公式推导到实战
线性代数·矩阵·webgl·正交·投影
wyiyiyi1 天前
【线性代数】对偶空间与矩阵转置及矩阵分解(Java讲解)
java·线性代数·支持向量机·矩阵·数据分析
爱喝热水的呀哈喽2 天前
py读取dat/plt
线性代数
Eloudy2 天前
矩阵算子 A 与矩阵算子 B 的 相对熵
线性代数·矩阵·量子计算
AI科技星2 天前
基于空间光速螺旋归一化的动力学方程推导与数值验证
人工智能·线性代数·算法·机器学习·平面
罗罗攀3 天前
PyTorch学习笔记|张量的线性代数运算
人工智能·pytorch·笔记·学习·线性代数
无水先生3 天前
理解线性代数的对偶性质
线性代数
历程里程碑4 天前
链表-----
数据结构·线性代数·算法·链表·矩阵·lua·perl
优思学苑4 天前
优思学院:QC新七大手法之「矩阵图法」是?
线性代数·矩阵