怎么有效压缩表达式
mathematica吧
全部回复
仅看楼主
level 4
c=KnotData["Trefoil","SpaceCurve"];n=FrenetSerretSystem[c[u],u][[-1,2;;]];ParametricPlot3D[Evaluate[5c[u]+RotationMatrix[7u].{2Cos[v],Sin[v]}.n],{u,0,2Pi},{v,0,2Pi},Mesh->None,PlotStyle->MaterialShading["Copper"],Lighting->"ThreePoint",PlotPoints->50,ViewPoint->{1,0,2}]
以这段代码为例,目前有270个字符。
请问如何减小整个表达式的长度,还可以正常被执行,不改变计算结果。
2022年06月05日 10点06分 1
level 4
大佬救命[哈哈]
2022年06月05日 10点06分 2
level 6
代码先偷走了
2022年06月05日 15点06分 3
level 4
我感觉我自带话题终结者属性[泪][泪][泪]
目前我能想到的有两个,
尽可能使用前缀表达式,可以少一个字符
将重复使用的函数重命名成单字符
another example:
x=Cos;y=Sin;c=KnotData[{3,1},"SpaceCurve"]@u;n=FrenetSerretSystem[c,u][[-1,2;;]];ParametricPlot3D[9c+RotationMatrix[5u].{x@v,y@v}.n(3+x[3v]+x[6v]),{u,0,2Pi},{v,0,2Pi},PlotStyle->MaterialShading@"Glazed",Lighting->"ThreePoint",Mesh->None,PlotPoints->50,ViewPoint->Top]
不知哪位大佬还能压缩这个表达式的长度[真棒]
2022年06月06日 18点06分 5
1