如何使用Python从Mathematica的.dat文件中获取list的派生?

时间:2018-02-09 04:48:16

标签: python wolfram-mathematica

我有来自Mathematica的.dat文件。它有两列:第一列代表预淬火相对化学势($ \ theta_ {0} $),第二列代表完成的平均工作量($ \ braket {W} $)。

0.0001  1.968765727
0.03151592653589794 1.526403743
0.06293185307179587 1.315922249
0.0943477796076938  1.181680326
0.12576370614359172 1.092500991
0.15717963267948964 1.034055677
0.1885955592153876  0.9986171379
0.22001148575128554 0.9811207217
0.25142741228718346 0.9778559454
0.2828433388230814  0.9864639035
0.3142592653589793  1.005123779
0.3456751918948773  1.032472433
0.3770911184307752  1.06748456
0.4085070449666731  1.109396204
0.4399229715025711  1.157654853
0.471338898038469   1.211886853
0.5027548245743669  1.271876803
0.5341707511102649  1.337555877
0.5655866776461628  1.408997391
0.5970026041820607  1.486418909
0.6284185307179586  1.570190989
0.6598344572538566  1.660731115
0.6912503837897546  1.759140881
0.7226663103256524  1.865661911
0.7540822368615504  1.982382946
0.7854981633974484  2.110586591
0.8169140899333462  2.252795219
0.8483300164692442  2.410700136
0.8797459430051422  2.589771972
0.9111618695410401  2.794071187
0.942577796076938   3.033575331
0.9739937226128359  3.323391524
1.0054096491487339  3.699588638
1.0368255756846319  3.905513036
1.0682415022205298  3.365482708
1.0996574287564276  2.902485831
1.1310733552923256  2.502188583
1.1624892818282235  2.154786056
1.1939052083641215  1.851708306
1.2253211349000195  1.585798632
1.2567370614359172  1.351316619
1.2881529879718152  1.122552869
1.3195689145077132  0.9609250081
1.3509848410436112  0.7970216327
1.3824007675795091  0.649843702
1.4138166941154071  0.5169416572
1.4452326206513049  0.3961682839
1.4766485471872028  0.2855755599
1.5080644737231008  0.1836374567
1.5394804002589988  -0.0843703707
1.5708963267948968  0.0002668209559
1.6023122533307945  0.2516937775
1.6337281798666925  0.492273888
1.6651441064025905  0.7253692214
1.6965600329384884  0.9500449098
1.7279759594743864  1.166259793
1.7593918860102844  1.374218726
1.7908078125461822  1.573771245
1.8222237390820801  1.765135571
1.853639665617978   1.948242241
1.885055592153876   2.123273373
1.916471518689774   2.290564007
1.9478874452256718  2.450236891
1.9793033717615698  2.601330042
2.010719298297468   2.745413105
2.0421352248333657  2.881912668
2.073551151369264   2.986664867
2.1049670779051617  3.13340867
2.13638300444106    3.248402463
2.1677989309769576  3.355004915
2.1992148575128554  3.457560413
2.2306307840487536  3.55222602
2.2620467105846513  3.64009798
2.2934626371205495  3.722207193
2.3248785636564473  3.796860739
2.356294490192345   3.866975081
2.3877104167282432  3.931456933
2.419126343264141   3.989416888
2.450542269800039   4.038039032
2.481958196335937   4.089254811
2.5133741228718347  4.118176178
2.544790049407733   4.167857922
2.5762059759436307  4.200698856
2.607621902479529   4.22397227
2.6390378290154266  4.244919941
2.670453755551325   4.258992793
2.7018696820872226  4.267133062
2.7332856086231203  4.268776953
2.7647015351590185  4.263238875
2.7961174616949163  4.249339865
2.8275333882308145  4.225337816
2.858949314766712   4.18946278
2.89036524130261    4.139231773
2.921781167838508   4.070571301
2.953197094374406   3.978907532
2.984613020910304   3.856762428
3.016028947446202   3.693401012
3.0474448739820996  3.473508407
3.078860800517998   3.17101391
3.1102767270538956  2.735631484

当我在Mathematica中绘制它时,我注意到$ \ theta_ {0} = 1.02678266592038 $的尖点。为了验证这是否真的是一个不连续性,我需要对$ \ theta_ {0} $采用$ \ braket {W} $的衍生物。我已经在Mathematica中完成了它,但我的结果并不令人信服。因此,我想在python中尝试它。但是,我对如何启动它一无所知。任何建议都会有很大帮助。谢谢!

Editted: Mathematica代码

a = Import['file.dat']
b = Interpolation[a, Method -> "Spline"]
c = b'

1 个答案:

答案 0 :(得分:0)

我不确定为什么检查衍生物时遇到问题。按照完全相同的方法,你指出,衍生物显示了不连续性的位置。您可以在此处使用此数据来获取Mathematica格式的数据

Import["http://halirutan.github.io/Mathematica-SE-Tools/decode.m"]["http://i.stack.imgur.com/lfXo1.png"]

然后

ip = Interpolation[data, InterpolationOrder -> 3, Method -> "Spline"];
Plot[{ip[x], .1 ip'[x]}, {x, 0.0001, 3.11}]

Mathematica graphics

话虽如此,您可以使用

在此间隔内搜索一阶导数的根
FindRoot[ip'[x], {x, .8, 1.2}]

(* {x -> 1.03119} *)