Questions on assigning and unassigning definitions to names that represent them, including issues raised by context and localization. Use tag [assignment] for issues relating to Set versus SetDelayed.
2
votes
1answer
391 views
setting a variable equal to the output of FindRoot
So I set a function f[x]
f[x_] := x*E^(-x) - 0.16064
Then I set a variable 'actualroot' to the function FindRoot, starting at 3
...
30
votes
3answers
668 views
Why modules with no variables?
I was reading some code, in particular, recipe 4.13 on unification pattern-matching in Sal Mangano's Mathematica Cookbook, and there were many instances of Modules with no variables in them, such as
...
5
votes
5answers
335 views
Using a built-in symbol as a variable
I want to produce a Mathematica Computable Document in which N appears as a variable in my formulae. But N is a reserved word in ...
11
votes
7answers
484 views
How to Set parts of indexed lists?
I would like to assign a list to an indexed variable and then change it using Part and Set like this:
...
6
votes
2answers
200 views
How to choose variables from a list for a function and then use the solution in a subsequent function?
I am trying to calculate heating degree days and cooling degree days and output that information to a table. I am using mathematica's curated data to do this. In text this is what I would like to ...
17
votes
1answer
780 views
How to define a global variable in Mathematica?
I have restricted the context of my notebooks to each individual notebook. So variables in each notebook are local and are not seen in another notebook.
But in two of my notebooks I have two ...
8
votes
2answers
139 views
Representing a value in an output as a self defined variable
I'm trying to find a way to have Mathematica always represent a numerical value as a self defined variable that I define using lhs=rhs. For example, if I execute
...
6
votes
4answers
542 views
Define a mathematical set
I have a terribly short question:
Is there a way to define a pure mathematical set?
I tried a bit of googling, but the word "set" has two meanings and the other one (as in setting) as by far more ...
9
votes
3answers
465 views
How to use local variables with indices in a Mathematica Block environment?
I have the following code:
Subscript[f, i_][x_] := Block[{a},
Subscript[a, i] = 3 x;
Subscript[a, 1]
]
If I evaluate for example ...
5
votes
3answers
542 views
Assigning values to a list of variable names
As part of a calculation I need to do something like this
Evaluate[{aaa, bbb, ccc}[[ index]]] = {1, 2, 3, 4, 5}
so if index is ...
14
votes
6answers
887 views
Why can't I define vector v as having subscripted elements v_1, v_2, v_3…?
I'm a very beginner in Mathematica 8 programming. While trying to play a little with tensor analysis I encountered a problem. How to define for example vector in such manner:
v={$v_1,v_2,v_3$}
For ...
12
votes
4answers
430 views
Making a symbol's new definitions be tried before all previously defined ones
Is there any way to "close" a package (or a symbol, or a context) in that if a user of the package adds definitions to the symbol they will be tried before the package defined ones, just like what ...
8
votes
3answers
222 views
Problem when defining variable in Mathematica
I'm trying to run this:
domain := {n, 0, 10};
Plot[n, domain]
but it doesn't work. Instead, it generates the message
...
15
votes
5answers
3k views
How do I clear all user defined symbols?
Is there some way to do this other than going to Evaluation -> Quit kernel and firing a new one up?
61
votes
7answers
2k views
What are the use cases for different scoping constructs?
Mathematica includes three functions that I know of which can be used to effectively (if not actually) define a variable and give it a value within a local scope: ...
12
votes
4answers
943 views
Clear complains that a variable is not a symbol or a string?
Here's a small listing where I've used EscqEsc to typeset θ in the notebook:
...
