Hot answers tagged

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 ...


14

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 ...


13

Citing this 1996 year MathGroup post by Dave Wagner, A similar function, Continuation[n], is called to format the character at the beginning of continued lines. So, for example, the definition Format[Continuation[n_]] := StringForm["(``)",n] would place a line number inside of parentheses on the second and subsequent lines of a multi-line ...


11

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++, ...


11

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 <...


11

A more general way, which can be used for other functions like Solve, is to use Normal. Integrate[1/x^s, {x, 1, Infinity}] (* ConditionalExpression[1/(-1 + s), Re[s] > 1] *) Normal[%, ConditionalExpression] (* 1/(-1 + s) *) Edit It looks like as of version 10, one can just use the one argument Normal: Integrate[1/x^s, {x, 1, Infinity}] (* ...


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

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: DynamicModule[{...


10

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" ...


10

To summarize the comments into an answer: The second element is a list of lists because there may be several different tags sown. For example, Reap[Sow[1, x]; Sow[2, y]; result] (* {result, {{1}, {2}}} *) Another example by belisarius, Reap[Sow[1, {x, y}]; Sow[2, y]; Sow[3, x], _, tag] (* {3, {tag[x, {1, 3}], tag[y, {1, 2}]}} *) See also this ...


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 ...


9

The reason is that you have empty history because you set $HistoryLength = 0 (as you confirm in the comments). I recommend setting $HistoryLength to be at least 3 in order to get the [Show Full Output] button working in the most practical cases.


9

I don't think Mathematica is using depth sorting to decide surface visibility. My reasoning is that a geometry like this: Graphics3D[ Table[ { AbsoluteThickness[10], If[OddQ[u/(60 °)], Red, Blue], Line[{{Cos[u], Sin[u], -.1}, {Cos[u + 80 °], Sin[u + 80 °], +.1}}] }, {u, 0, 360 °, 60 °}], Boxed -> False] would be displayed ...


9

Rectangle cannot have a gradient color. Here's one way to construct such a gradient. Under the hood it is using Polygon with the VertexColors option. Graphics[ChartElementData["GradientRectangle", "ColorScheme" -> "Rainbow", "GradientOrigin" -> Left][{{0, 1}, {0, 1}}]] {{0, 1}, {0, 1}} corresponds to {{xmin, xmax}, {ymin, ymax}} for the ...


9

Clear[color]; color = ColorData[{"Rainbow", "Reverse"}]; Planck[T_, colorparameter_] := Plot[(1/lambda)^5/(Exp[100/(T lambda)] - 1), {lambda, 0, 10}, PlotPoints -> Automatic, PlotRange -> All, PlotStyle -> Directive[Thick, colorparameter], PerformanceGoal -> "Quality"] max = 10; Manipulate[ Show[{Planck[T, color[T/max]]}, PlotRange ...


9

This is a bug I fixed in 10.4.0. Sorry for the inconvenience! To work around it in earlier versions, evaluate the following block of code: InactiveDump`assembleInactiveSumProduct[{args_, disp_, interp_, char_, tag_, tooltip_, fmt_}] := TemplateBox[args, tag, DisplayFunction -> Function[disp], InterpretationFunction -> Function[interp], ...


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

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]


8

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 ...


8

This is not a bug. It is an expected result of numerical roundoff error and the somewhat unusual way Mathematica computes division. What is roundoff error? Floating point numbers have a finite precision. With almost any arithmetic operation performed, the result is not exact: digits beyond about the 16th get discarded. What's special about how ...


8

It seems to me that your function depends on too many variables to be represented entirely as a 3D contour. Perhaps we can get to what you need by approximation. To start off, here is perhaps an example of a 3D contour on the surface of the unit sphere for a specific value of $t$ ($t=1$): SliceContourPlot3D[ WaveDensity[1, x, y, z], x^2 + y^2 + z^2 == 2, ...


8

Mathematica is a term rewriting system. It works by taking an input expression and transforming it according to some rules to produce an output expression. The implication is that every evaluation will have a result. For every input there is an output. Null is simply the expression used to represent "no result". In StandardForm and OutputForm it is not ...


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" ->...


7

NonlinearModelFit returns a FittedModel object. Please see the respective documentation pages on how to use these objects. Most importantly: these objects contain a lot of information that is not meant to be read by you, the user. What you see on the screen is just a shorthand representation of the object. In most cases, you cannot copy this visual ...


7

This uses a function that should be available to version 7, ContourPlot3D[ x^2 + y^2 + z^2 == 4, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, ColorFunction -> Function[{x, y, z}, ColorData["Rainbow"][WaveDensity[1, x, y, z]]], Mesh -> None, ColorFunctionScaling -> False, PlotPoints -> 80 ] In this case the density values lie between 0 and 1 ...


7

\[Continuation] is also the name of the special character used to indicate that input should be interpreted as continuing in the next line, or to break output too long for the current window. I suspect Continuation[] to be the operator form of that infix symbol. On second thought, I suspect that the formatting references you found are linked to special ...


7

After a quick Google search I came across this, which provides a description. Translation: Continuation[n] is the result at the beginning of the nth line in a multiline printed Expression. The default value of Continuation is either the string " " or the string ">". The value of Continuation is can be changed with the command Format[Continuation[n_]]:=...



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