New answers tagged

2

Question 2: But I don't know why this is done this way: MakeBoxes @ Graphics[Disk[]] (*GraphicsBox[DiskBox[{0, 0}]]*) MakeBoxes @ Whatever[Disk[]] (*expected*) (*RowBox[{"Whatever", "[", RowBox[{"Disk", "[", "]"}], "]"}]*) This is because typesetting rules are applied in a chain where the choices of branches depend of the previous choices ...


2

I am going to attempt to answer your questions off the cuff. I have been somewhat inactive on this site recently and also not using Mathematica much, so I am surely not at my best, so "take this with a grain of salt" as they say. Question 1 What is the typesetting in Mathematica? What procedures does it include? Typesetting is anything that is done for ...


2

ClearAll[leftSplit, rightSplit] leftSplit[q2_?NumericQ] := NMinimize[Max[Abs[q1 - 0], Abs[q2 - q1]], {q1}] rightSplit[q2_?NumericQ] := NMinimize[Max[Abs[q3 - q2], Abs[1 - q3]], {q3}] NMinimize[Max[leftSplit[q2][[1]], rightSplit[1 - q2][[1]]], {q2}] (* or NMinimize[Max[leftSplit[1 - q2][[1]], rightSplit[q2][[1]]], {q2}] *) {0.5, {q2 -> 0.5}}


0

Restructure the FullForm using ReplaceAll: f1 = # /. head_[a___][d___] :> head[## & @@ ({a} /. w_Function :> w[d])] & Examples: {#, f1 @ #} &[(((Log@(D[#1, x] &))))[h[{x, y}]] ] {#, f1 @ #} &[(((I (D[#1, x] &) ((D[#1, y] &)))))[h[{x, y}]] ] Alternatively, define a function that processes the box forms of ...


4

Since any function in Mathematica can be used in postfix form by appending & to make it a pure function, the following code can be used: In[39]:= 20 // Range[#]-1 & // Map[#*# &] // Select[EvenQ] // Take[#, 10] & // Fold[Plus, #] & Out[39]= 1140 Alternatively, Total or Apply[Plus] could be used instead of Fold[Plus, #] &; Fold is ...


5

This is an extended comment. This behaviour is new in 10.4. I can reproduce it with 10.4.1 on OS X, but not with 10.3.1. This may be related: DistributeDefinitions and synchronization in Mathematica 10 We can try to analyse what happens like this: z := (Print[$KernelID]; 1); SetSharedVariable[z]; ParallelEvaluate[z] ...


1

Perhaps something like: test[steps_] := Module[{}, n = 0; Print["% Complete: ", Dynamic[n*100/steps]]; For[n = 0, n < steps, n++, Pause[1]]; NotebookFind[SelectedNotebook[], "Print", All, CellStyle]; NotebookDelete[]] See also: A self-deleting button to delete Print cells


2

I felt like it is something very fundamental for working with UI developement in MMA so I asked WRI Support to help me. It took a while but I received a very good answer, which is to suspend DynamicUpdating when Export takes place. [...] For the effect you want, turn off the global DynamicUpdating option for the fronend just before the call to ...


3

I would memoize sol[a]. The Evaluate in position does nothing if it does not wrap the entire expression after the :=. It's not that important, so I would just drop it. The issue with [[1]] (or First) can be handle in sol. Here are the changes I've described: sol[a_] := sol[a] = First@NDSolve[{x''[t] == -2 x[t], x[0] == a, x'[0] == 1}, {x}, {t, 0, 10}] ...


0

This helps to get rid of that [[1]] as per your request, however without having the code that is really slowing this down, I cannot be sure it would help improve your performance. If it does, great! If not, you have eliminated one possible cause. You state the performance glitch is with position[t,a] function. However, can you remove the 0.01 timesteps in ...


4

Without diving into your code too much, everything will run a LOT more smoothly if you use ParametricNDSolve to solve your differential equations with the parameter a: pfun = ParametricNDSolveValue[{x''[t] == -2 x[t], x[0] == a, x'[0] == 1}, x, {t, 0, 10}, {a}] position[t_, a_] := {Sin[#], Cos[#]} &@pfun[a][t] You can keep everything else the same. ...


2

InitializationGroup vs group of InitializationCells If you create a new cell in an InitializationGroup it will automatically become an InitializationCell. For the group of InitializationCells you will get a default one, which you can turn into another InitializationCell or not. A set of InitializationCells vs one InitializationCell. I can't find any ...


0

I fixed the issue by utilizing the "Cubics" and "Quartics" options for eigensystem. The code runs much quicker and the manipulates are smoother. There is no more eigenvalues jumping around. Before the output of the eigensystem was a bunch of "root" expressions which I believe remained unevaluted until the plot functions. Now that the expressions are expanded ...


3

Do not use x as both a dependent variable in NDSolve and an index in Table. Instead, try, Table[Solu[-a, -1, 1 + a, .3, 50], {a, 0, 2}] (* {{7.19845*10^-22, -0.102113, 0.102113, 3.31597, 3.31597, 3.26406}, {-0.10725, -0.10725, 0.214501, 3.33333, 3.16227, 3.16227}, {-67.8836, -67.7287, 135.612, 3.29475, 0.133514, 0.162306}} *)


2

You can't run Kernel Blocking Dialogs on the preemptive link. But you can prompt other dialogs. And we can abuse that to run a procedure containing Input[], DialogInput[] or some system dialogs. The trick is to run your code inside an asynchronous initialization of the regular dialog: MessageDialog[ DynamicModule[{}, 1, Initialization :> ...



Top 50 recent answers are included