2

I am dealing with a program with Mathematica where I compute expressions that take a very long time to compute. I need these results for further computation and/or display. I would like not to have to redo all the computations all the time, so save the results in files that can be imported again, without computation. But I need Mathematica to be able to read the expressions as mathematical expressions again, not just as text files.

For example, if I export the expression GR*Gl into a file on my hard drive, and I import it later in another program and assign it the name GA, I want that, if I assign further GR = 2 and Gl = 3, GA to be equal to 2*3 = 6. In other words, I want to be able to use it for further mathematical computation, as I would do directly in the original program.

Which commands should I use for that? I am not finding how to do this very simple thing.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Thomas921
  • 21
  • 2

1 Answers1

1

I believe you want to save your expression as a text file, read the text file back in as a string, then convert the string to an expression using ToExpression[], as below. Is ToExpression[] the function you were seeking? The two //FullForm's are not necessary, of course, but they show how the string is converted to a Wolfram Language expression for a multiplication using the Times[] function.

enter image description here

user15996
  • 627
  • 4
  • 7