# Tag Info

15

The output from Information[] gets sent to the $Urgent stream. Here is how you can capture it: infoFile = OpenWrite["info.txt", FormatType -> OutputForm, PageWidth -> Infinity] Block[{$Urgent = infoFile}, Information["DSolve", LongForm -> False] ] Close[infoFile] Note that I used PageWidth->Infinity. This results in possibly (?) cleaner ...

13

I believe it does work, just not how you expect. :-) From the documentation for PutAppend: Note that there are no quotation marks around filename in the first line. It is not made particularly clear but you can use this syntax with >>>: Range[10] >>> file.txt Which outputs to a file named file.txt directly. This is a special and ...

10

The question is, what do you want to do with the output. The output of Position is in a form so that it can directly be used with Extract list = {a, b, a, a, b, c, b}; pos = Position[list, b]; Extract[list, pos] (* {b, b, b} *) For this simple example, it is a bit useless because we already know, that on all positions pos we have a b in list. ...

10

I consider this a bug in the front end. Very odd it is, that not all forms eat up the first result. Consider this simple example m = {1}; MatrixForm@m MatrixForm@m which gives 2 outputs as expected. If we look on the traffic between kernel and front end, then we see, that the kernel indeed sends 2 outputs back. No matter which kind of form we use: FE ...

10

There are several issues here. You need to "inject" the symbol name into the expression using With (or similar) to prevent trying to make an assignment to ToExpression["col" <> ToString[i]]. Further, you've got spurious Background -> expressions which do not belong. (I also use Symbol in place of ToExpression.) That gives us: ...

9

As Yves already mentioned, you can easily create and edit notebooks through Mathematica commands. A start would be this tutorial, which you can find in the Documentation Center under tutorial/ManipulatingNotebooksFromTheKernel Here is a short example printing the i values into a new notebook: nb = CreateDocument[]; For[i = 1, i <= 10, i++, ...

9

If you examine the Cell expressions (select the cell and hit ctrl-shift-E) you can see that in the first case the lines are separated by \n whereas in the second case [IndentingNewLine] sneaks in (I pasted the second case and hit return between the lines as it pasted as a single line). It would appear that [IndentingNewLine] doesn't count as an input ...

9

You have several possibilities: 1) Instead of Printing into usual StandardForm Cell where the parsing and 2D formatting take significant processor's time you can print into plain text Cells: CellPrint[Cell["stuff=" <> ToString[stuff]]]] This takes substantially less CPU time and should render much faster. 2) Instead of printing into separate cells ...

8

If you make any assumptions you have to share them with Mathematica as well. For Example: Assuming[R > 0, FullSimplify[(R^3)^(1/3)]] (*R*) The default assumption is that all variables are complex. (As @J.M. noted in the comments).

8

On Windows, MathKernel.exe launches the kernel running within a window. The standard output is redirected to that window. To avoid this redirection, we must run the kernel as a console application using Math.exe instead: "C:\Program Files\Wolfram Research\Mathematica\10.0\Math" ^ -noprompt ^ -script C:\Users\a\Desktop\test.m ^ "data goes here" ...

7

As suggested by many (@YvesKlett, @acl) you can use Export : output2 = Flatten[Table[{x[[i]], y[[ j]], z[[k]], x[[i]] + y[[j]] + z[[k]]}, {i, 1, 3}, {j, 1, 3}, {k, 1, 3}], 2] ; Export["test.tsv", output2]

7

I have found one solution, using a temporary file:- streams = AppendTo[$Output, OpenWrite[]]; Module[{}, Print[Plot[Sin[x], {x, 0, 2 Pi}]]; a = 123]; Close@Last@streams;$Output = Most@streams; printoutput = ReadList@First@Last@streams

7

(This answer doesn't include how to make it fullscreen, I can't manage to get any window at all to fullscreen without going through my window manager) With DisplayFunction -> (CreateDialog[#, WindowMargins -> {{1, Automatic}, {Automatic, 1}}]&) you can get it in the top left corner, however it will be on the main display. From WindowMargins: ...

7

Like Mike said in a comment, the key is to use the second argument of Dynamic. In this case I've built a function updateCurrencies which modifies a global variable currencies which holds an Association object with all the currency values in it. currencies = <| "USDollars" -> 0, "Euros" -> 0, "BritishPounds" -> 0, "SwedishKronor" ...

6

I'll assume that you want to echo any literal Set operation that occurs in input, even if it is not on a line by itself. $Pre This may work for you:$Pre = Function[ main, Unevaluated[main] /. Set -> Function[, Print@HoldForm[# = #2]; # = #2, HoldFirst], HoldAll ]; Now: {a = 2 + 2, b = 10/2, c = Sqrt[9]}; a = 4 b = 5 c = 3 ...

6

As already explained, this happens because MatrixForm act as a wrapper. The answer to the question about how this behavior is implemented and how can eventually be reproduced is contained in the Informmation of the system symbol $OutputForms. Indeed ??$OutputForms returns: $OutputForms is a list of the formatting functions that get stripped off ... 6 I propose: a = {1, 4, 11, 14}; b = Range[0, 14]; {#, Pick[b, Mod[b (1 + #), 15], 0]} & /@ a { {1, {0}}, {4, {0, 3, 6, 9, 12}}, {11, {0, 5, 10}}, {14, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}} } Anything more is formatting, which I shall leave to you. 5 One way to do this is to define the solution as sol = Solve[b^2 + b*z + 1 == 0, b][[1]]; and then plot using the strategy suggested in the Help file for Solve, which replaces the variable in the rule (in this case b) with the desired solution: Plot[b /. sol, {z, -10, 10}, PlotRange -> All] 5 You can temporarily redefine Print, like so: fun[] := Module[{}, Print[Plot[Sin[x], {x, 0, 2 Pi}]]; a = 123] list = {}; Block[{Print = AppendTo[list, {##}] &}, fun[]] Now list contains everything that was printed. (Of course in a practical application you'd probably want to do something smarter than an inefficient periodic AppendTo) If you still ... 5 It's just not always true that$(R^3)^{1/3} = R$. How about$R=i$, for example? N[(I^3)^(1/3)] (* Out: 0.866025 - 0.5 I *) If you expect this, you might have more luck with the real-valued CubeRoot function. For example: FullSimplify[CubeRoot[R^3]] (* Out: R *) 5 The following works for me output = OpenWrite["C:\\Users\\Mike Croucher\\outtest3.txt", FormatType -> OutputForm];$Output = output Print["hello"] Close[output]; I get the word 'hello' in outtest3.txt. However, the following does not work output = OpenWrite["C:\\Users\\Mike Croucher\\outtest4.txt", FormatType -> OutputForm]; $Output = output ... 5 I think I would choose to use MakeBoxes and Defer for this: MakeBoxes[a_^Rational[1, x_], fmt_] := ToBoxes[a^Defer[1/x], fmt] Now: -Sqrt[a - bar] -(a - bar)^(1/2) This also catches cases that use RadicalBox: x^(1/3) // TraditionalForm x1/3 Defer is used to allow the output to be used as input. An alternative is Interpretation but that ... 5 You could use the function JWindow from the JVMTools Mathematica add-on package. It returns the JFrame object and the JPanel object, and you can further process these objects, as explained on the page JVMTools window functions (scroll down to the section "Further Processing of the Java Objects"). For example: ... 5 "MatrixForm acts as a "wrapper", which affects printing, but not evaluation. " The output returned by % or Out[] is the result obtained prior to applying the wrapper. It is important to note this behavior is pecular to the assignment to the output history. For example: m = mat // MatrixForm actually assigns the MatrixForm to m (Note this is a ... 5 Just use Style whenever you want to change the style of something: TraditionalForm[Style[x^3 + y^3 == 22 z^3, FontSize -> 24]] 5 Oh, you just incorrectly type the equation in Mathematica, your second one should be: 1 - 2 d + 2 d b + 2 e b == 0, check the 2 d term. It's not a 2 b. Solve[{2 + 2 a d + 2 a e == 0, 1 - 2 d + 2 d b + 2 e b == 0, 1 + 2 d c + 2 e c == 0, a^2 + b^2 + c^2 - 2 == 2 b, a^2 + b^2 + c^2 - 2 == 0}, {a, b, c, d, e}] (* {{a -> -2 Sqrt[2/5], b -> 0, c ... 5 What you observe is a bug (evaluation leek) inside of TreeForm. In particular, observe this: TreeForm[Unevaluated[Print[5 + 6]]] 11 11 As you see, Print is evaluated twice inside of the TreeForm code. It is apparent bug and I suggest you to report it to technical support. 4 Presuming you only want to this special output to come from computations that bind a variable to the value of the computation, here is one way it can be done by$Pre and $Post: SetAttributes[saveSet, HoldAll]; saveSet[form : Set[var_, _]] := (lastSet = ToString@Unevaluated@var; form); saveSet[form : ___] := (lastSet =.; form)$Pre = saveSet; \$Post = ...

4

When handling symbols like you do, I find it best to avoid converting from and to strings. This is typically needed in other languages to do meta-programming, however due to Mathematicas philosophy being that everything is an expression, meta-programming can be accomplished simply by holding evaluation order. Here is a simple implementation of your ...

4

As mentioned in the comments, to search for multi-letter palindromes, two underscores are needed as described in the help for string patterns: Palindrome[] := DictionaryLookup[y__ /; (y == StringReverse[y])] Now, Mathematica is probably not good enough to come up with lyrical palindromes.

Only top voted, non community-wiki answers of a minimum length are eligible