Skip to main content

All Questions

Tagged with or
Filter by
Sorted by
Tagged with
3 votes
1 answer
131 views

function evaluation - I don't get it

this function returns Pi/4 for a[1,4] In[...]:= a[r_, n_] := Module[{an = Pi/n, h = r Cos[an], w = 2 r Sin[an]}, an]; a[1, 4] Out[...]= Pi/4 so the kernel ...
Paul_A's user avatar
  • 487
5 votes
1 answer
131 views

why DSolve in V 12 returned an internal module variables with $ on them in this example?

Fyi, Reported to WRI in case it is a bug. [CASE:4288939] Is this supposed to happen? ...
Nasser's user avatar
  • 150k
1 vote
1 answer
155 views

How to use Module function?

Here is my issue; I want to iterate a fit to this data for a polynomial of degree 2 up till degree 6. However, at each iteration I drop certain data points that have a poor residual value. So each ...
Carrson Baldwin's user avatar
0 votes
1 answer
111 views

Modifying/optimizing a double sum with an If condition

I would like to better understand double summations where one of the sums depends on the upper limit of the previous sum. This appears frequently in representation theory (to the extent of my ...
user avatar
1 vote
1 answer
62 views

Variables referring to other variables within Module

The following doesn't work: Lol[x_, y_] = Module[ {w=x+1, z = w + 1}, z] because z refers to ...
George's user avatar
  • 3,175
1 vote
1 answer
148 views

Using rules inside Module or Block

I have a rather long piece of code inside a Module, and I want to provide different parameters to the different pieces inside the ...
Nils's user avatar
  • 67
0 votes
1 answer
216 views

NonlinearModelFit of an NDSolve result

I have some data : ...
J.A's user avatar
  • 1,285
13 votes
4 answers
1k views

What is the accessibility of a package's `Private` context variables?

I've been reading up on how Mathematica handles contexts, $Context, $ContextPath, and a few of the tutorials they have on ...
sgdsgyhetwaraw's user avatar
6 votes
1 answer
148 views

RegionPlot3D no longer localizes its arguments?

Bug introduced after 9, fixed in 12.0. Just now, I was astonished to find the behavior of RegionPlot3D changes somewhere after v9 . Consider the following sample: ...
xzczd's user avatar
  • 68.4k
3 votes
1 answer
343 views

How to trace value assigned to local variable(variables in Module)?

Bug introduced in v10.1 or earlier and persists through v11.3 CASE:4240757 Here is my code: ...
shelure21's user avatar
  • 165
0 votes
0 answers
175 views

Assigning values to variables inside Module using user defined function

Say I'm defining a function with some local variables, for which I'm using Module. Now, I want to assign some value (or perhaps a list of values or a list of list, ...
amator2357's user avatar
  • 1,404
1 vote
1 answer
339 views

Why are there local variable conflicts in my recursive function definition?

Sorry to post a long piece of code. There are two places in here where I Print[] 'path2' when the count == 984, because for some reason, that list is getting ...
Jerry Guern's user avatar
  • 4,642
0 votes
1 answer
101 views

Different result in ContourPlot function using different version of Mathematica (?)

I tested "Elasticity with Mathematica" notebook (Mathematica 6) in Mathematica 11.3 and tested C05_stress_kirsch.nb, I added some trigger code to protected function in the tensor2analysis.m file, and ...
Earth's user avatar
  • 1
2 votes
0 answers
41 views

Unexpected symbol::shdw warning during NotebookEvaluate

Consider the following code: ...
Lukas Lang's user avatar
  • 34.4k
1 vote
0 answers
48 views

Why doesn't `ReplaceAll` work in this situation? [closed]

I can work around this by using With, but it seems really odd to get the following: ...
Richard Burke-Ward's user avatar
0 votes
1 answer
246 views

Multiple functions within a Module

I have a function that extracts a numerical value from two vectors, written as Spa[i_,j_]:=Flatten[LaU[i].LaD[j]][[1]]. (Note, I'm sure that this isn't the most ...
Brad's user avatar
  • 135
1 vote
0 answers
115 views

Function returned from module doesn't work [closed]

I have a sequence of steps that work in the main notebook: ...
Pedro Sobota's user avatar
3 votes
2 answers
338 views

Finding the inverse of a function

I am to solve for $r(\rho)$ given the function, ρAsymp[r_, b_, q_] := 1/(1 - q) Gamma[1/(1 - q)]/Gamma[(q - 2)/(q - 1)] r Sqrt[1 - (b/r)^(1 - q)] This can be ...
user583893's user avatar
1 vote
1 answer
49 views

Evaluation of Extract and use the result in a Sum

I am experiencing a problem in the evaluation of a sum. I hope that someone can help me, I am not an expert Mathematica programmer. I'm posting just the portion of code that gives problems, I know ...
Andrew's user avatar
  • 11
4 votes
2 answers
279 views

Scoping of pattern variables [duplicate]

I have run into a problematic behavior, and then came to find that it is a "possible issue" called out in the documentation, but I guess I am just baffled that this IS an issue, and am wondering why. ...
Kevin Ausman's user avatar
  • 2,307
0 votes
1 answer
159 views

Can I bake my own PI using your Wolfram language oven and prebuilt utensils? [closed]

How might I override the value of the Greek letter PI within various builtin language functions in the Wolfram language? Specifically and without having to reinvent the wheel or code equivalent ...
Francis from ResponseBase's user avatar
2 votes
1 answer
327 views

How to define a function inside a module through Evaluate [duplicate]

I am trying to define a function inside a module as following ...
LeafGlowPath's user avatar
  • 1,473
0 votes
0 answers
48 views

Symbol created in Module not seen outside of Module scope [duplicate]

I am using a function defined with a Module[]. In the Module I am creating a new variable name using a ...
brnady's user avatar
  • 1
1 vote
0 answers
67 views

ConditionalExpression still resulting from Assuming a Module's local variables

I have a memoizing, recursive function whose MWE looks like this (the two fake inputs/ICs are from 'K' and 'Bfun2', the latter just a quick way to check the results coming out of the Residue.: ...
nate's user avatar
  • 455
1 vote
2 answers
204 views

How do I localize changes to a variable inside a Do-loop?

I want to change the increment value inside the do loop . But i dont know why it remains for the first declared value? ...
revanth roy's user avatar
3 votes
3 answers
159 views

MostOccuringWeekdays Wolfram Challenge [closed]

I am working this challenge from Wolfram Challenge. I believe that I have solved the problem with the following code (note it is not very efficient - I am new to Mathematica!) ...
Connor Fuhrman's user avatar
3 votes
1 answer
132 views

Module - Symbols out of scope of lexical scoping

The Problem Consider the following code (1): In[1]:= x = 2; Module[{x, y}, y[x_] = x; y[1] ] Out[2]= 2 I expected the answer ...
Max1's user avatar
  • 1,125
3 votes
3 answers
240 views

What is wrong with Module? or me? [closed]

The following code does not give me an answer. It looks all is working when each command inside Module is individually run. But ...
Tugrul Temel's user avatar
  • 6,409
2 votes
1 answer
146 views

Why does Mathematica stay on an endless evaluating loop with Manipulate?

I have built Manipulate to see the impact of a change in time and volatility to the profit of an option strategy, bull spread. To calculate the price of the option, I built the good old Black-Scholes: ...
Thadeu Freitas Filho's user avatar
5 votes
1 answer
179 views

With vs. Block scoping of parameters for Plot

A very basic question.. Why does Block work, but not With, to specify value of a parameter for a function to be plotted? ...
murray's user avatar
  • 12.1k
5 votes
2 answers
207 views

HoldAll Attributes and Delayed Evaluation: ContourPlot with solutions to NDSolve

This is a general question on evaluating functions that are defined to be evaluated with delay. In particular, I am having difficulties working with the ...
OldTomMorris's user avatar
1 vote
3 answers
158 views

Prime number counting function

As part of an assignment for a calculus class, I have to write code for the prime number counting function $p(n)$, I have no problem creating the function itself, but for I want it as a function, ...
mcardiff0321's user avatar
6 votes
0 answers
67 views

Nested rules and automatic renaming of variables [duplicate]

I understand why $ happens here: ClearAll[foo] foo[a_] := (x_ :> a x) foo[1] ...
Kuba's user avatar
  • 138k
1 vote
0 answers
62 views

What use is empty binding list in `Block[{},...]`? [duplicate]

Spelunking the Export function, I stumbled upon the following definition: ...
kkm mistrusts SE's user avatar
2 votes
1 answer
128 views

Problem with local variables when using Module twice in the same code

...
acoustics's user avatar
  • 1,729
1 vote
1 answer
87 views

Problem passing argument in hash table from global context to a module

I was experimenting with passing arguments via a hash table to a module. Found a very strange result. When I pass a function to be plotted inside the module, it comes out empty. Yet all argument ...
Nasser's user avatar
  • 150k
3 votes
1 answer
246 views

Module and With do not work in some cases

I apologize if the title is too vague/general but I couldn't find a better one. I am trying to use either Module or With but it does not work if the object containing the local variables is defined ...
Karim's user avatar
  • 297
9 votes
0 answers
191 views

A bug in Derivative?

Update This is a bug in v11.3 or earlier and is fixed in v12. Original Post Check this out: ...
luyuwuli's user avatar
  • 2,814
0 votes
1 answer
159 views

Want help with debugging a For-loop

I'm trying to run a simulation, which at the end gives a value 'qber'. Now I want to run this simulation multiple times with different values of 'p' each time. And these value of 'p' are actually the ...
Rishabh's user avatar
  • 35
2 votes
2 answers
837 views

Clear variables inside Module

I have a function that uses Module. The function takes as input a .csv that can have as many columns as it wishes to, and it ...
M.O.'s user avatar
  • 425
6 votes
4 answers
229 views

Create rule whose LHS is already defined

My question will be clearest if defined using an example. Consider the following code: Func[k_]:=Block[{a}, a[t_]:=t^k; {a[t]->a[t]} ]; However, calling ...
EZLearner's user avatar
  • 295
1 vote
0 answers
59 views

Dependent variables in With operator [duplicate]

I want write something like this With[{x=1, y=x+1}, y] and get 2 as an answer. What is the correct way to do this?
Weather Report's user avatar
0 votes
0 answers
185 views

How to speed up a module function with a large number of arguments?

I'm setting up a fairly hefty numerical code dealing with matrices of variable dimension, but on the order of hundreds of rows and columns. I'm using a Module format: ...
Brendan Reid's user avatar
1 vote
2 answers
268 views

function fails to use local variable when it is called inside a Module

I have these two functions fun and microstep.Fun makes use of a Module construct within which I define the ...
Alucard's user avatar
  • 2,709
0 votes
0 answers
45 views

To find the Null Space of a matrix which is inside the module

...
acoustics's user avatar
  • 1,729
0 votes
0 answers
37 views

How to define a global function dependent on a local pattern? [duplicate]

When g is in the local scope defined by Block, the following fails: ...
user42582's user avatar
  • 4,225
2 votes
2 answers
293 views

Table and evaluation order

I thought Table should not evaluate the inner code until it inserts the value. I'm confused by test1[3]="a"; test2[4]="b"; Table[DownValues[i],{i,{test1,test2}}] ...
Kvothe's user avatar
  • 4,781
1 vote
1 answer
49 views

Manipulating definitions while reading them with Get

In order to read in a definition with certain parameters replaced by appropriate values I can use for example Block[{a=1.1,b=2.2}, Get["file"]] where ...
Kvothe's user avatar
  • 4,781
2 votes
3 answers
738 views

Use of Module With Functions

Really confused by how one should use the Module[] command in two variables. For example my function here should return the ...
user57592's user avatar
0 votes
0 answers
43 views

Tracking System function (Get) calls, and Stack[_]

Consider the following attempt and variations thereof to track (nested) calls to Get (reasoning of this approach below): ...
Lukas Lang's user avatar
  • 34.4k

1
3 4
5
6 7
12