# Tagged Questions

Questions on Mathematica's scoping constructs (Block, Module, With, etc.)

261 views

### Compile not correctly initializing a variable defined inside Module

Bug introduced in 8.0 and persisting through 10.3.1 or later In the following example, inside the minimumX's Module, ...
127 views

### Integrate - Why is the integration variable not local

I have noticed something odd: Let f[t_]:=Integrate[x, {x, 0, t}] h[t_]:=Sum[x, {x, 0, t}] Now, enter ...
584 views

### Compile recursive function modifying global variables

How to compile recursive formula when it relies on more than a few global variables (global to the topmost compiled function)? It is unreasonable to pass on all such variables to each recursive ...
76 views

236 views

### Exhaustive examples of variable replacement due to nested scoping constructs

Consider the following examples, where I have replaced dollar signs in the output by a D. ...
128 views

### Are there any videos that show how different Mathematica expressions are evaluated?

Are there any videos that show how different Mathematica expressions are represented internally as object graphs and demonstrate how they are transformed during an evaluation? I am asking because I ...
317 views

### Module in numerical model for NonlinearModelFit is slow and leaks memory

I am trying to make a NonlinearModelFit where the model is the result of a numerical calculation. My code works, but it is very slow and also seems to have a memory ...
175 views

### Is Mathematica's lexical scoping broken?

Why do these two lines output different things (b and 0, respectively)? Is it a bug? ...
120 views

### Why is it not allowed to define vectors of variables in a scoping construct?

The following command assigns 1 to a, 2 to b and 3 to c: ...
115 views

### Assign variables from list inside With or Module

I have found that it is possible to assign variables from lists, as follows. r = {1, 2, 3}; {a, b, c} = r; b 2 However, ...
58 views

### How to use Compile? Bivariate Gibbs Sampler

I am trying to use compile to speed up my Gibbs sampler. I know I can use Reap and Sow to speed up tremendously. I have a more complicated Bayesian posterior that I want to speed up with compile so I ...
73 views

### Scoping all symbols

After working Mathematica for a couple weeks to write a larger program, beyond doing integrals, I am starting to gain an appreciation for the Wolfram Language. There are a couple issues that drive me ...
102 views

### Compile issues, scoping and order of evaluation

I have a few questions about compiling functions, which I think are all related to scoping and order of evaluation. I will illustrate them by a minimal example of the problem I have. I'm sorry for ...
50 views

### ParallelTable gets slower when rerun in a module

Question: Why does the performance of ParallelTable within a Module drop so horribly when the module is RERUN several times? ...
82 views

### Should I Remove the initial symbols of Module?

Often we use Module to construct complicate function. Consider that Module create new vars every time we run the function, should I remove the initial values at the end of Module-function?Or should I ...
134 views

### Building Reusable Custom Controls?

I would like to build an application using Mathematica 10. I would very much like to structure the application for maximum maintainability. To this end I would like to segregate controls and user ...
51 views

### Settings to disable global scope

I am building a fairly large application in Mathematica, and globally scoped variables are causing issues. I would like globally scoped variables to be out-of-scope for my expressions, except by ...
82 views

### How to implement nested With as a single construct using functional programming (Fold)?

It is possible to define my own With construct where each local constant can depend on the previous defined local constants? I wish to replace something like this ...
221 views

### Variable scope in nested NMaximize, NMaxValue

I'm trying to use NMaxValue inside other statements (FindRoot and NMinimize). Those statements should bind variable names, but I'm getting weird warnings which seem to indicate that the variables ...
30 views

### How to use a numerical integral as an input function

I am new to mathematica. I am trying to use a numerical indefinite integral as an input function of a module. I have a function $$r^* \equiv r^*(r)=\int_0^{1/r} B(z)dz$$ with $B(z)$ being a analytic ...
29 views

### How to plot eigenvalues as a function of parameters in a dynamic module?

I am trying to make a fancy interactive plot that shows how the eigenvalues of a matrix mat change under variation of parameters ...