用Mathematica實現3B1B的效果
涉及程式碼:素數螺旋
原始程式碼
Graphics
[
Point
[
CoordinateTransformData
[
“Polar”
->
“Cartesian”
,
“Mapping”
]
/@
Table
[{
#
,
#
}
&@
Prime
[
k
],
{
k
,
1
,
1000
}]]]
由
提供的
ListPolarPlot[{#, #} & /@ Prime@Range@1000]
相關畫圖程式碼
向量圖:
Module[{mu, g, L}, mu = 0。5; g = 9。8; L = 4;
VectorPlot[{y, - mu y - (g/L) Sin[x]}, {x, -5, 5}, {y, -5, 5}]
]
流線圖:
Module[{mu, g, L}, mu = 0。5; g = 9。8; L = 4;
StreamPlot[{y, - mu y - (g/L) Sin[x]}, {x, -5, 5}, {y, -5, 5}]
]
還有解ODE
mu = 0。5; g = 9。8; L = 4;
sol = NDSolveValue[{x‘’[t] == -mu x‘[t] - (g/L) Sin[x[t]],
x[0] == Pi/3, x’[0] == 0}, x, {t, 0, 10}]; Plot[
sol[\[FormalX]], {\[FormalX], 0。, 10。}]
畫那個3D 圖
隨機點數=5;
取樣數=200;
pts=RandomReal[1,{隨機點數,2}];
sam=Table[BSplineFunction[pts,SplineClosed->True][t],{t,0,1,1/取樣數}];
Show[
ListPlot3D[MapThread[Append[#2,#1]&,{EuclideanDistance@@@#,Mean/@#}&@Subsets[sam,{2}]],PlotRange->Full],
ParametricPlot3D[Append[BSplineFunction[pts,SplineClosed->True][t],0],{t,0,1}]
]
畫那些格子
ComplexPlot[Sqrt[z],{z,-5-5I,5+5I},ColorFunction->“CyclicReImLogAbs”]
的復變換
程式碼由
提供
格林公式計算
GreenFunction[{\!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]\(u[x, t]\)\) - \!\(
\*SubscriptBox[\(\[PartialD]\), \({x, 2}\)]\(u[x, t]\)\)},
u[x, t], {x, -\[Infinity], \[Infinity]}, t, {y, s}];
Plot3D[% /。 {y -> 0, s -> 0}, {x, -1, 1}, {t, 0。01, 0。1},
ViewPoint -> {-5, 2, 3}, PlotRange -> All]
程式碼出自幫助手冊 ref/GreenFunction
本文持續更新