# Export in Mathematica 9 vs Mathematica 10

Bug introduced in 10.0 and fixed in 10.0.2

I want to export a list of complex numbers as follows:

uu=1.0+0.0I//FortranForm
Export["file.in", Flatten[{uu}], "Table"];


The file (file.in) contains the following:

Version 9:

(1.,0.)


Version 10:

Complex(1.,0.)


I want the output of V9, but I need to use V10. How could I get the same output as in V9, using V10?

• Fixed in version 10.0.2 and later. – ilian Jul 15 '15 at 18:50
• @ilian thank you for commenting on all of these questions. May I suggest that if you are satisfied that something is a bug, that you tag the question as such? This will make it easier to find later on. – Oleksandr R. Jul 17 '15 at 20:37
• @Oleksandr Sure, I usually do this kind of edit but evidently can also forget to. – ilian Jul 17 '15 at 20:52

Ilian mentioned that this is fixed in newer version of Mathematica, but if you are not able to update, the following helper function may be of help:

toFor[c_] := "(" <> ToString[Re[c]] <> "," <> ToString[Im[c]] <> ")"

numbers = RandomComplex[10 + 10 I, 100];
Export["file.in", toFor /@ numbers, "Table"]


This exports a list of numbers in the format indicated above, separated by carriage returns/new lines:

(9.11984,3.81308)
(7.10358,4.19413)
(8.21729,2.03658)
....
(7.74429,1.92139)


UPDATE

OP asked for a version with a specific output precision. Here is an amended version of the toFor function I proposed above in which one can specify the precision of the output.

toForPrec[c_, n_] := "(" <> ToString[SetPrecision[Re[c], n]] <> "," <> ToString[SetPrecision[Im[c], n]] <> ")"

newnumbers = RandomComplex[1/10 + 1/10 I, 100, WorkingPrecision -> 25];
Export["file.in", toForPrec[#, 15] & /@ newnumbers, "Table"]


... and the output now is:

(0.0172977041871843,0.0820605936318249)
(0.00278403446087895,0.0779569707654853)
(0.000249080445256925,0.0400488367614751)
.....
(0.0815582541497981,0.00541653436534768)

• could you please edit your function such that it gives 17 digits after the first non-zero digit? That's what it did in V9. For example: 13 (-0.009899126922473455,0.) 14 (-0.010366600317484277,0.) 15 (0.12651162321086884,0.) 16 (-0.010897017057905087,0.) 17 (-0.380165100325757,0.) – Mencia Jul 17 '15 at 10:43
• @Mencia I updated my answer: please see if it does what you want now. – MarcoB Jul 17 '15 at 14:30