I'm trying to multiply a matrix and a vector (imported from a csv) in Wolframscript to speed up a process normally done with Mathematica notebooks. This is my first time using Wolframscript, however, and it seems that it won't simplify my answers. For example, I have tried the simplest of examples:






value1 = Import[file1.csv, "Table"];
value2 = Import[file2.csv, "Table"];

value1 = value1[[1]][[1]];
value2 = value2[[1]][[1]];

Print[FullSimplify[Evaluate[value1 * value2]]] //should be Sqrt[2]*Sqrt[3] = Sqrt[6]

This gives Sqrt[6] in the regular notebook, but Sqrt[2]*Sqrt[3] as output in the command line using Wolframscript.

I've tried FullSimplify, Simplify, Evaluate, etc, yet nothing seems to simplify the answer in wolframscript.

The matrices and vectors I'm trying to multiply eventually are much more complicated, so I'm trying to find a solution for this simple case. I'm wondering if it is something to do with the Sqrt function?

Thanks in advance!

  • 2
    $\begingroup$ Try value1 = Import[file1.csv, "Table"]; value2 = Import[file2.csv, "Table"]; value1 = value1[[1]][[1]]; value2 = value2[[1]][[1]]; Print[FullForm[value1 * value2]]] and see if there are any single or double quotes in what it displays. They MIGHT be strings with Mathematica "helping you" by hiding those quotes and making you think they are numbers while FullForm should you what you really have, well mostly what you really have.. $\endgroup$
    – Bill
    Commented Aug 13, 2019 at 21:06

1 Answer 1


I figured it out... >_<

From this question: Doing calculation on an imported data file

Since I was using csv files (or txt files), you have to first change the data by using \\ToExpression, which will then correctly format the text files. (Note: Using \\Flatten will remove the Sqrt[].

After using \\ToExpression, Wolframscript will correctly simplify and calculate Sqrt[2]*Sqrt[3], and even more complex matrices and vectors (yay).

  • 1
    $\begingroup$ If you're writing these things to file you can be kinder to yourself by writing to a .m file or using the "Package" format when importing and exporting. $\endgroup$
    – b3m2a1
    Commented Aug 13, 2019 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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