0

I wrote a Mathematica script, which calculates an integral value at a list of points and writes it to a file:

```
ϵ :=78.36;
z := 1;
bohr := 0.52917721;
boltzmann = 3.16681535*10^-6;
c := 10 * 6.02214129*10^23*1.0*10^-27*bohr^3;
κ := Sqrt[2.*4*π*c*z];
kBT := boltzmann * 300;
λ = κ/Sqrt[ϵ]*Sqrt[z/(kBT)]
funcin =
1/(ϵ*π)*Exp[-(2*r + λ*Sqrt[r^2 + ρ^2 - 2*r* ρ*Cos[θ]])]*
r^2*Sin[θ]*1/Sqrt[ρ^2 + r^2 - 2*r*ρ*Cos[θ]]
intfuncinang =
Assuming[r > 0 && ρ > 0 && ϵ > 0 & &λ > 0, Integrate[funcin, {θ,0,π}, {ϕ,0, 2π}]]
Assuming[ρ > 0 && ϵ > 0 && λ > 0,
funcins =
Integrate[intfuncinang, {r,0,ρ}] + Integrate[intfuncinang,{r, ρ, Infinity}]
]//Simplify
dataimport = Import["inputfile.dat", "Table"];
datatoint = dataimport[[1 ;;, 1]]
Print[Length[datatoint]]
int = Array[#&, Length[datatoint]];
Do[ρ = datatoint[[i]];
int[[i]] = N[funcins];
points = {datatoint[[i]], int[[i]]};
points >>> "outputfile.dat"
, {i, Length[datatoint]}]
```

I run this on the console with `math -nopromt -run "<<script.m"`

. This works always for some values, but crashes after some time. I am using *Mathematica* 8. Does anyone have an idea why I am getting crashes?

1I'm afraid that we would need

`inputfile.dat`

to try your code :) – Öskå – 2014-05-14T09:24:31.4731Unrelated to your problem, but

`Array[#&,Length[datatoint]]`

is just`Range[Length[datatoint]]`

. Perhaps`points>>>"outputfile.dat"`

could use a`;`

to suppress output to the console (I can imagine that a large amount of that may choke the console). – Sjoerd C. de Vries – 2014-05-14T09:38:38.277Another thing: your assignment of

`funcins`

withinthe`Assuming/Simplify`

combo doesn't mean`funcins`

contains the simplified result. You have to assign it to the result of the simplification (so outside of the call). – Sjoerd C. de Vries – 2014-05-14T09:44:16.407Thanks already for the comments. I try to suppress the output with ; now, lets see how it works. How can I upload the input file? – Guiste – 2014-05-14T09:59:19.223

Does not help, still aborting... – Guiste – 2014-05-14T10:10:52.580

http://www.datafilehost.com/d/d72eed1e here you find the inputfile.dat – Guiste – 2014-05-14T10:34:06.590

1That seems to lead to a .exe file. I'm sorry, but I'm not going to download that. Could you try pastebin.com? – Sjoerd C. de Vries – 2014-05-14T10:35:59.553

http://pastebin.com/CV8x5ZV0 – Guiste – 2014-05-14T11:07:47.327

please use datatoint = dataimport[[2;;,1]], the first point is not calculatable – Guiste – 2014-05-14T11:12:00.173

1@SjoerdC.deVries, it leads to the right

`.dat`

file for me :) – Öskå – 2014-05-14T14:36:47.063So is it working for you? – Guiste – 2014-05-14T19:29:12.933

@Guiste First you are saying

– Öskå – 2014-05-15T13:43:59.287`r>0`

and then you`Integrate`

from`0`

to`rho`

. That's not possible. And secondly: check here for how to pass`Assumptions`

to`Integrate`

.