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

learn more… | top users | synonyms (1)

15
votes
0answers
222 views

Compile not correctly initializing a variable defined inside Module

Bug introduced in 8.0 and persisting through 10.1.0 or later In the following example, inside the minimumX's Module, ...
10
votes
0answers
421 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 ...
5
votes
0answers
192 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. ...
5
votes
0answers
121 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 ...
4
votes
0answers
228 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 ...
3
votes
0answers
93 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: ...
2
votes
0answers
63 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 ...
2
votes
0answers
96 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 ...
1
vote
0answers
78 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 ...
1
vote
0answers
107 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 ...
1
vote
0answers
46 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 ...
1
vote
0answers
79 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 ...
1
vote
0answers
186 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 ...
0
votes
0answers
60 views

Is tensor argument passing to module expensive?

I wrote a simple module which is supposed to do recursive computation, however it turns out to be expensive even for 300 points. I am not sure why is it slow, all the computations seem to be ...
0
votes
0answers
30 views

Set::setraw error help includes Module

Simple program for euler's method. I changed it to this and it works, just not to the extent I want it to. Right now I have to define x and y locally, whereas I'd rather set them as a global initial ...
0
votes
0answers
48 views

What is the right way to combine a Package, Module, ParallelTable and NIntegrate?

I am stuck with a curious problem. I would like to to have a package from which i can call a function test[path], which then performs a time consuming numerical ...
0
votes
0answers
93 views

Best practices for breaking up functional blocks?

Say I have a main function that does some job, and I'm only interested in the final result of ans, i.e., the local functions are not important and produce no ...
0
votes
0answers
56 views

Where to put manipulate brackets for slider effect to refresh page

In order to move the plane of a best fit around to alter the sum of the residuals, I have decided to pick on one point and attach a slider to it, this adds a little variance and moves the table ...
0
votes
0answers
103 views

Local variable names - Is there an easy way?

I apologize first, because this has been asked, like in Treat all variables as local in a module [duplicate] Variable scope similar to other languages But I don't get how to use them. Some codes ...
0
votes
0answers
130 views

Programming a Meijer G related result

I am not that new in Mathematica, but I do not remember I have ever used it for programming (like we may do in Java). I have an important result given here by this integral: $$ \int_0^{+\infty} ...