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.
1
vote
1answer
83 views
How to linearize an expression automatically?
I would like to automatically linearize some long equations in the scope of variational calculus. Here follows an example of what I need to do :
Given two variables $a_1 = q_1 + \delta q_1$ and $a_2 ...
1
vote
2answers
73 views
TabView: Reset some dynamic variable on tab selection
Given a TabView panel like this one
TabView[{
DynamicModule[{x = False}, {Checkbox[Dynamic[x]], Dynamic[x]}],
"foo"}]
I ...
8
votes
2answers
136 views
Distribute and analyze large datasets
I need to analyze very large datasets, and they obviously don't fit in a computer memory. I need to produce some statistics on these datasets, and this brings me here:
How can I make some statistical ...
8
votes
1answer
113 views
Different behaviours of Default Argument
I don't really understand the behaviour of Default Argument. If I execute this command in Mathematica:
In: {f[a], f[a + b]} /. f[x_ + y_.] -> p[x, y]
...
10
votes
1answer
191 views
What is $ sign in Mathematica?
Is it a special sign or it can be used as anything else? For creating variables for example.
$x=4
3
votes
2answers
207 views
Mathematica does not understand (R^3)^(1/3) is the same as R [closed]
In the output from a calculation in mathematica stands a/((R^3*c)^(1/3)), with c and a ...
4
votes
4answers
118 views
Put local variables for Block in a variable [duplicate]
Is is possible to assign {x = 2, y = 3, z = 4} to a variable var so that one can write
...
0
votes
4answers
115 views
Specify a variable as an integer
I have a formula that always evaluates to a certain number for any variable X under one condition that X is an integer and ...
1
vote
1answer
70 views
Generating a list of symbolic coefficients [duplicate]
I am trying to do something which I assume should be very simple: I want to generate a list with symbolic coefficients that looks like this:
...
5
votes
1answer
68 views
Why doesn't DumpSave work for elements created within a local notebook context?
I recently noticed that when dealing with notebooks with local context, I cannot successfully DumpSave variables, or, rather, when I call ...
3
votes
1answer
101 views
How to replace variables in an expression?
I have generated a matrix using Mathematica,
$\left(
\begin{array}{ccc}
\text{cos$\theta $} & -\text{sin$\theta $} & \text{cos$\theta $}\, \text{dx}+\text{dx}-\text{dy}\, \text{sin$\theta $} ...
4
votes
2answers
74 views
Creating functions from output of other calculations
Apologies in advance if the title is vague, I'm not really sure what to call this.
I have a function (call it 'foo') that generates a largeish polynomial, and it is natural to make the variables be
...
2
votes
3answers
140 views
How to make a defined symbol stay in symbol form?
How to make a defined symbol stay in symbol form?
w = 3; g = 4;
{w, g}[[2]]
3
I want the output to be ...
0
votes
1answer
73 views
Riffle not acting as expected [closed]
I have defined two tables:
R = Table[Subscript[\[ScriptCapitalR], -i], {i, -12, -1}]
T = Table[Subscript[\[ScriptCapitalT], -i, -i - 1], {i, -12, -1}]
I want to ...
3
votes
2answers
130 views
Save variables values and definition
I used to do a lot of programming in R and recently switched to Mathematica. One thing that bothers me is that I haven't found a way to save variables, their values and definition!
Let's look at an ...
4
votes
1answer
123 views
Module with “local functions”
I am trying to use a Module having "local functions", i.e., those which I need to define only inside this module.
So I tried this:
...
0
votes
0answers
25 views
How to define a vector of arbitary length [duplicate]
I need to use a vector of length which I can change, indexed symbolically
So for e.g. when N=3 I'd like to have
vec={c1,c2,c3}
when N=5
...
5
votes
1answer
100 views
Proper use of arbitrary number of variables
So, I'm working on a project where the number of independent variables is not fixed.
Consider a problem of $N$ independent variables, $\boldsymbol{r}$.
I want to perform different things with them. ...
3
votes
1answer
89 views
Is it safe to assign a variable and function of the same name for different things?
I'm writing out a notebook that goes through the van der Waals Equation of State for gases, and I run into a situation where I want to assign (simplified) Tc[b_]:=5b, use that to solve for b in terms ...
2
votes
1answer
64 views
Strange behaviour of variables in Table
I'm trying to work with some vectors and have run into a strange problem. An obvious way to define a difference of two vectors would be
dif[x_,y_] := x-y
I ...
5
votes
1answer
90 views
Proper localization of variable names
In functions like NonlinearModelFit I need to specify parameters with a symbol name. If I localize these parameters they get cluttered in the output (e.g....
2
votes
2answers
285 views
Global variable initialization in packages
Is it a good idea to Initialize variables globally inside a package ?
will they be local by default to that package ?
1
vote
2answers
131 views
Why does Evaluate[a[[1]]]=0 assign a value to a variable while a[[1]]=0 doesn't?
I'm trying to do a small page counter with Mathematica, for leting me know about my reading progress on some books. I'm stuck on a problem:
...
2
votes
2answers
256 views
defining recursively a function with multiple if conditions
I am trying to recursively define a function which satisfies the following system of equations and which depends on two parameters $n$ and $l$,
$$
\begin{align}
A(x, n, l) &= F[ A(x,n-1,l) ]\\
...
2
votes
3answers
146 views
how can I generate a sequence of assignments?
I want to make a sequence like follows
r[1]=
r[2]=
r[3]=
r[4]=
....
r[n]=
The above r[i] represents coordinates which I have ...
0
votes
2answers
126 views
How can I assign some part of data from one list to another list?
I don't know this is correct question or not,but I have a doubt.
I have two Lists names are list1 and ...
4
votes
2answers
273 views
How to create a Table of Tables with indexed variables
I want to use concise code to generate a table of values that list the addition of a set of vectors. What I am looking for is essentially a Table of Tables.
I will show here the kind of lists I want, ...
14
votes
3answers
437 views
Create an adaptive amount of local variables for error propagation
I intend to write a function which calculates the result and the error for any formula with any amount of variables using the Gauß Error Propagation.
The error $dR$ for a function $R(a,b,c)\,$ and ...
6
votes
2answers
160 views
Can I redefine a list as a set of variables?
Suppose I have a list
mydata = {3, 14, 15, 92, 65}
and in some cases I want to manipulate it as a list, like for reading from and writing to a file, or for ...
10
votes
4answers
374 views
how to differentiate formally?
I have been wrapping my head around this for a while now and I have not found a solution so far.
I want to work with an arbitrary number of variables in mathematica and use some built in functions.
...
2
votes
1answer
97 views
Evaluating a function on permutations of its arguments
Say I have a function "temp" of $n+1$ variables, $y,z1,z2,z3,...,zn$. I want to test if my function has certain symmetries like swapping $y$ with square of any $z$, swapping any two of the zs, ...
5
votes
1answer
93 views
Reloading package after accidental Remove[] of symbol
I was using Needs["PlotLegends"] By chance I removed ShowLegend by Remove[ShowLegend]
How do ...
1
vote
3answers
238 views
How to create functions of arbitrary number of variables?
In the following code what would be the simplest way to generalize it to say some $N_f$ number of $z$ instead of just $z_1$ and $z_2$?
...
3
votes
1answer
123 views
Using external variable as a variable inside WhenEvent & NDSolve
I'm trying to use the new WhenEvent functionality of NDSolve in Mathematica 9, in order to perform an action when a variable in the system reaches a certain value. I would like this variable to come ...
0
votes
0answers
60 views
What's the best practice for nested local constants? [duplicate]
Possible Duplicate:
How to avoid nested With[]?
I have many situations where I have a constant that is local to a function, with other constants that are computed from it. I see that I can ...
4
votes
3answers
284 views
How to Clear variables with apostrophe?
An apostrophe ' is often used when we want to distinguish two variables. For example, if we already have a variable t and we may ...
27
votes
3answers
660 views
Is there an equivalent of MATLAB's Workspace window in Mathematica?
For example, in MATLAB, a panel is available where one can see straightaway which variables are used and their dimension sizes. Is such a feature available in Mathematica? I really find it hard to ...
2
votes
2answers
193 views
local variable naming & symbolic argument
I'm stuck here with my variable assignment in this scenario
...
0
votes
3answers
143 views
Better solution than returning a list of 3 values?
I have a function (using SetDelayed) that currently returns 3 values in a list. Later on I use the result of this list along with ...
4
votes
0answers
90 views
Context “Unique to This Notebook” makes variables black even if they're not defined?
I'm trying to use this technique to keep variables separated between different notebooks. It seems to be working fine, except that variables turn black as soon as they are evaluated — any ideas why ...
3
votes
0answers
58 views
What's reliable way of finding declared but undefined functions/symbols in several interrelated packages?
I have many packages some of which use some of others. I have many symbols defined in them. Is there a reliable way of finding declared/exported but undefined functions/symbols in several ...
12
votes
1answer
146 views
Is it possible to Clear all variables (but not functions)?
I have written a Mathematica script in which I define functions and variables. Here is a vastly simplified example:
...
12
votes
6answers
349 views
How to clear all variables except one?
I have a lot of variables: $a,b,c,d, \ldots $
I want to clear the values of all of them except $b$. It's really lengthy to write
Clear[a];
Clear[c];
...
Is ...
7
votes
3answers
393 views
Elegant manipulation of the variables list
I have a list of global variables (some of them are indexed variables), for example:
varsH = Hold[U0[1], U0[2], B0, V0[1], V0[2]]
Or (if it is easier to handle) ...
8
votes
3answers
317 views
Variable variable names
I have two variables, $ u \in \{0,40\}$ and $\gamma \in \{0,1\}$. I take $10$ values of $u$ and $5$ values of $\gamma$ and using their combinations as a pair of input parameters, I perform some ...
2
votes
1answer
186 views
Can I create a dynamic number of rows in TabView through an iteration?
I have written code, with the help of stackoverflow of course, and I want to make it user friendly so that other people in my lab can use it. I'm playing with DialogCreate and similar functions. I ...
2
votes
1answer
479 views
Constructing variable names from a string
I have groups of descriptive variable names and dont want to write explicit code for each group, e.g. (and this is a contrived simplification)
...
1
vote
0answers
291 views
Using constraints in Solve[]
I'm not sure if the title fits.
I'm basically just looking for a way to define a value and constrain it to $[a,b]$ when I use Solve later.
More specifically, I ...
10
votes
4answers
254 views
How to use pattern matching to assign values to Subscript[f,x_]?
I want to define two subscripted functions Subscript[f,1] and Subscript[f,2]. To keep the assignments local, I would like to ...
1
vote
1answer
162 views
How do I use a matrix that has a variable?
I seem to be getting an error whenever I try running this piece of code.
Matrix12[n_] := {{1, 0}, {0, {\[Kappa]1[n]}/{\[Kappa]2[n]}}}
I've already defined the ...