Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

I would like to export a long Table of (complex) numbers to a text file using Export["file.txt",%];

A sample line from the obtained file looks like this:

{0.11288378916846890559999999999`18.05263157894737, {{1.6974001229071336*^-12, -5.163757820258834*^-15 + 1.9829374389565386*^-13*I}, {-5.163757820258834*^-15 - 1.9829374389565386*^-13*I, 3.1517458450250055*^-13}}}

First, I do not understand where the `18.05263157894737 comes from. It does not appear in the Mathematica file. How can I get rid of it? Then I would prefer a formatting of the number s like 1.6974001229071336e12 instead of 1.6974001229071336*^-12. The ultimate purpose is import in Maple. So if there is such an export feature it would be welcome too. Note that I need at least 18 digits precision.

share|improve this question

marked as duplicate by m_goldberg, The Toad Aug 5 '13 at 5:36

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

This is a duplicate of like 3-4 questions rolled into one... For starters: mathematica.stackexchange.com/q/2915/5, mathematica.stackexchange.com/q/469/5, –  The Toad Jun 3 '12 at 19:55
Yes, that helps a lot already. Only the additional List, Complex expressions are a little bit inconvenient, but thats still easier to fix using the text editor. –  highsciguy Jun 3 '12 at 20:57

3 Answers 3

The `18.0526315789473 indicates that the preceding number is an arbitrary precision (versus machine precision) number with a precision of 18.0526315789473. To get rid of it, you can convert your data to machine precision with N.

Borrowing from the answers linked to by R.M., you might be looking for something like this:

data = {0.11288378916846890559999999999`18.05263157894737, \
{{1.6974001229071336*^-12, -5.163757820258834*^-15 + 
      1.9829374389565386*^-13*I}, {-5.163757820258834*^-15 - 
      1.9829374389565386*^-13*I, 3.1517458450250055*^-13}}};

newdata = 
     ScientificForm[#, Round@MachinePrecision, 
      NumberFormat -> (#1 <> "e" <> #3 &)] &, N@data, {-1}], 2]

(* Out:
{"1.128837891684689e-1", {"1.697400122907133e-12", 
  "-5.163757820258832e-15 + 1.982937438956539e-13 I"}, \
{"-5.163757820258832e-15 - 1.982937438956539e-13 I", 

Export["file.txt", newdata, "Table"];

(* Out:
1.697400122907133e-12   -5.163757820258832e-15 + 1.982937438956539e-13 I
-5.163757820258832e-15 - 1.982937438956539e-13 I    3.151745845025005e-13

I'm assuming that you were looking for a true plain-text tabular format (i.e. without the curly brackets in your question's example). I'm not sure what Maple needs for acceptable input, so you might want to modify this.

share|improve this answer

Maybe you could map FortranForm to the numbers of the list:

trans[x_?NumericQ] := FortranForm[x]
trans[x_] := x

list = {0.11288378916846890559999999999`18.05263157894737, \
{{1.6974001229071336*^-12, -5.163757820258834*^-15 + 
      1.9829374389565386*^-13*I}, {-5.163757820258834*^-15 - 
      1.9829374389565386*^-13*I, 3.1517458450250055*^-13}}};


Export["file.txt, export]

then the exported file looks like this (copied from »less«):

0.112883789168468906 {{1.6974001229071336e-12, (-5.163757820258834e-15,1.9829374389565386e-13)}, {(-5.163757820258834e-15,-1.9829374389565386e-13), 3.1517458450250055e-13}}

These are two rows in the original file.

share|improve this answer

You can use Chop to reformat this data for Export. Mathematica is showing the full accuracy of the number, which is probably beyond what you expect.

 in(3)= pts = Chop[{0.11288378916846890559999999999`18.05263157894737, \
        {{1.6974001229071336*^-12, -5.163757820258834*^-15 + 
        1.9829374389565386*^-13*I}, {-5.163757820258834*^-15 - 
        1.9829374389565386*^-13*I, 3.1517458450250055*^-13}}}]

out(3)= {0.112883789168468906, {{0, 0}, {0, 0}}}
share|improve this answer
Thanks, but no, thats not what I want! I like to have the full precission (or at least 18 digits) in all numbers but I do not want the `18.05263157894737 and the ^ because Maple does not understand what it means. –  highsciguy Jun 3 '12 at 20:45
Why don't you do all the calculations in Maple? –  The Toad Jun 3 '12 at 20:46
Hard to believe, but sometimes Mathematica is the better tool:) I take the best from both worlds... –  highsciguy Jun 3 '12 at 21:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.