当前位置: 首页 > backend >正文

使用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]

http://www.xdnf.cn/news/9348.html

相关文章:

  • OpenCV---findCountours
  • [java八股文][JavaSpring面试篇]SpringBoot
  • 前端Vue3列表滑动无限加载实现
  • 佰力博科技与您谈谈高温介电温谱仪如何保养
  • ROS2学习(15)------ROS2 TF2 机器人坐标系管理器
  • MySQL问题:MySQL中使用索引一定有效吗?如何排查索引效果
  • LeetCode-栈-最小栈
  • 现代 CSS 高阶技巧:实现平滑内凹圆角的工程化实践
  • UDP 传输时间(延迟)
  • 关于Oracle SGA内存抖动
  • FastAPI 异常处理
  • vscode ssh远程服务端设置
  • OpenCV视觉图片调整:从基础到实战的技术指南
  • PH热榜 | 2025-05-26
  • hive 笔记
  • WEB安全--RCE--webshell HIDS bypass4
  • PostgreSQL auto_explain
  • Unity3D中Mono与IL2CPP对比
  • 使用mermaid快速绘制流程图
  • 3D Tiles高级样式设置与条件渲染(3)
  • 50多种垃圾类型都能清理Wise便携版:系统临时文件 /浏览器缓存秒清理
  • 利用亮数据实现大规模数据自动抓取
  • 项目部署react经历
  • IDEA使用Git进行commit提交到本地git空间后撤回到commit版本之前
  • 本地jar包发布到maven远端
  • Vue 3.0 自定义 Composition API 管理状态
  • 银发团扎堆本地游,“微度假”模式如何盘活银发旅游市场?
  • 医疗HMI设计规范解读:如何平衡合规性与用户体验?
  • Sweet Snippet 之 指数函数优化
  • Spring AI 本地Ollama