Hot answers tagged

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


4

From the OP comments the slices (or contours) of a multi-dimensional function is what is being sought. A way to do this is the have each Plot in Manipulate set as Dynamic on the variables not on the x-axis. Such that, as these variables are adjusted the contour in the variable on the x-axis updates. For example, for $f(x,y,z) =z\sin(x)-y$ the contours 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. ...


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


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

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


2

As you've noticed both Plot and Manipulate are scoping constructs. And the problem is that you want to manipulate expressions that contain variables which are meant to be scoped and where is a naming conflict. What you want probably is possible but I think the fastest solution is just to avoid naming conflicts: With[{ exprsToPlot = {xp^y, x^yp}, ...


2

I believe that I now know the answer. In addition to setting InitializationCellEvaluation option to True InitializationCellWarning option to False with the notebook selected, you also need to set these same values at the Global Preference level.


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


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


1

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


1

Manipulate is HoldAll and the body isn't evaluated till it is displayed. That's because effectively there is Dynamic[body]. I once explained that a little in Manipulate in Manipulate. So inside the package it won't do anything, as no output is generated. You can see this here: ClearAll[x]; Manipulate[x = 5, {y, Null}]; Pause[1]; x Manipulate[x = 5, {y, ...


1

You can achieve this with Inactive and Activate. f[x_, y_, z_] := x + y + z v = {4, 5, 6}; Inactivate only f with Inactive and allow v to resolve. Then Activate the result for the answer. fv = Inactive[f][Sequence @@ v] Activate[fv] Hope this helps.


1

Why not just deconstruct the argument in the pattern without using Index at all? g[{x1_,x2_,x3_}]:=f[x1,x2,x3]



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