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.

learn more… | top users | synonyms

1
vote
1answer
32 views

How to unshadow a chosen definition for a function

I want to use the package NCAlgebra. However after successfully installing the package and trying to write some code, basic functions like SetNonCommutative[...] ...
1
vote
3answers
61 views

How to make a list (of data points) whose name is the same as the file name from which the data is imported [duplicate]

I have a set of files, e.g. file1.dat, file2.dat,... containing data (list of data points to plot, manipulate...) I want to do the following ...
2
votes
1answer
80 views

Clearing a global variable from inside a Module

This is a highly simplified version of a initialization problem I have with a complicated program with many (about 100) modules. If one enters: X=42; Clear[X]; the ...
1
vote
5answers
168 views

Do not expand matrices in Mathematica calculation

Here is an example of a problem I'm having. Consider that I have defined: omega={{p[t]},{q[t]},{r[t]}} x={{a},{b},{c}} R={{1,2,3},{4,5,6},{7,8,d}} What I would ...
1
vote
0answers
75 views

Coupled ODEs with boundary conditions - DSolve Error [closed]

I'm relatively new to mathematica and I can't find the error here. I suspect it has something to do with the fact that vx, vy, vz aren't blue on my mathematica - as in, they already have some assigned ...
1
vote
1answer
69 views

Variables input generation for Minimization in High dimensional space [duplicate]

I'm currently doing optimization in a high dimensional space. I was thinking of giving FindMinimum (or NMinimize not certain ...
37
votes
5answers
18k 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?
1
vote
2answers
331 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 ...
2
votes
0answers
38 views

Share variables among notebooks with different Kernels

So I have a server running in another notebook with a secondary kernel. I run my main notebook and launch the server notebook, but I have configured the variables in my main one, and can't find a way ...
6
votes
1answer
329 views

What does it mean when a function is defined with two pairs of brackets

I have noticed a function defined as such: f[x_][y_] := expr; How is the argument y in 2nd pair of brackets being used? What is the difference from defining a ...
2
votes
0answers
55 views

Changing variables in a series expansion

I want to compute the Taylor expansion of some pure function f[x_], but then perform a change of variables in the resulting expression. So, for example, the output ...
1
vote
0answers
65 views

Binding a variable to an unbound variable [closed]

I'm trying to do something like the following: (minimal example, f2 unbound) ...
3
votes
1answer
54 views

Setting a One Dimensional Function Equal to a Constant over a Specific Range

I am trying to take the output from NDSolve and create a variable equal to the solution except for a certain range of values. Here is the code I am trying to use ...
0
votes
1answer
58 views

How to implement the for loop to replace text strings or texts?

I wonder define a bunch variables named like $X_1$, $X_2$, $...$, $X_n$. Is there some smart way to declare them instead of by pure typing. One trick I can image is to use the for loop,...
10
votes
4answers
823 views

Subscripts - Why do I see the error “only assignments to symbols are allowed” when using a Module and not otherwise?

When I type Remove["Global`*"] foo[] := Module[{Subscript[a, 1] = "x"}, 0]; foo[] I get the expected error "only assignments to symbols are allowed". I ...
2
votes
0answers
60 views

Follow-up to “How to differentiate formally?”: Efficiency concern

In link to "how to differentiate formally?" and particularly to the answer by @Jens, I want to do something like this: ...
1
vote
1answer
71 views

Converting the subscript of matrix name to a variable

I want to change indices of matrix name during loop for creating different matrices. For example; ...
3
votes
2answers
91 views

Module, local variable

Lets say I define a Module, that internally use iterating in a Table or Do, say something ...
1
vote
1answer
49 views

Create a list of variables of a function

How can I create a list of variables of simple functions with arguments? These functions will be defined by the user, to be manipulated with some code later. ...
2
votes
1answer
43 views

Definition of a function depending on a sequence

let $a_{n}$ is a given fixed sequence, say $a_{n}:=1/n$. I would like to define something like $$D_{j}:=\sum_{k=1}^{j}\frac{1}{j!}BellY[j,k,\{a_1,a_2,\dots,a_{j-k+1}\}].$$ Function BellY is ...
3
votes
3answers
206 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 ...
2
votes
4answers
307 views

Defining a General Complex Number

I am trying to compute the Complex conjugate of two complex numbers multiplied together. However, when I go to define my complex numbers as $a+b I$ and $c+dI$ it does not like $b$ and $d$ because they ...
6
votes
2answers
105 views

Force evaluation of the right-hand side of a local variable definition

One can do expression = a + 1; f[a_] := Evaluate[expression] but how would one do something like this ...
0
votes
1answer
34 views

Variable Definitions and Random Numbers [closed]

I have currently created the following matrix: m={{RandomReal[{0,1}],RandomReal[{0,1}]},{RandomReal[{0,1}],RandomReal[{0,1}]}} In other words, a $2 \times 2$ ...
4
votes
3answers
222 views

Using Block with a list of variables

I have a list of variables var={v1,v2}; which I want to protect/localize during a particular operation. I have decided that I want to use ...
3
votes
2answers
105 views
3
votes
2answers
69 views

How can I adjust the global input variable of a function to the value of a local variable within the function

I am trying to define a function f[l_] that will perform an operation on whatever input variable I use (normally I use l which ...
7
votes
2answers
171 views

How to name a variable with the value of another variable?

A simple but very important (at least for me) question. In some languages for defining a variable, for example, we can do: i=10 "d"&i=30 So I have defined the variable d10, and... d10=30 ...
0
votes
1answer
98 views

Variable dependency…easy one

I'm brand new to Mathematica...should be an easy one. Instead of writing u[x] everywhere in the code, how do I assign the dependency early on like this: u=u[x] ...
3
votes
2answers
107 views

How to use locally scoped dynamic variables in Manipulate for expression and control parameters

I have a Manipulate that has dynamic variables that I want to use in the displayed expression and use in the parameters for the manipulate controls. I only ...
1
vote
1answer
115 views

Adding letters and numbers to create a variable name [duplicate]

Let's say I have several variables, named R1, R2 and R3. I wanted to have a function ...
1
vote
1answer
54 views

How to set the values into some variables from different lists [duplicate]

I have a list of Values and a list of variables. I want to set the Values into Variables. Assume the following code: ...
4
votes
3answers
1k 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 ...
11
votes
4answers
1k views

Preventing Superscript from being interpreted as Power when using Ctrl+^ shortcut?

I have very strong desire to use superscript as the index of the variable. However, it looks like that the Mathematica automatically recognize the superscript as the power and I got message that my ...
0
votes
2answers
81 views

How to define $x^n$ where $x=\pm 1$ and $n\in\mathbb{Z}^{+}$?

I do not know how I can define $x^{n}$ in Mathematica, where $x=\pm 1$ and $n=1,2,3,\ldots$. For even values of $n$ we simply have that $x^{n}=1$. While for odd values of $n$ we have that $x^{n}=x$. ...
1
vote
1answer
60 views

Define operator with special characters [duplicate]

I have looked here which describes how to define operators. I was wondering whether there was a way to assign thes operators to special characters? eg Let $\odot:=(a+b)(ab),$ so ...
8
votes
3answers
4k 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 ...
1
vote
3answers
172 views

How to replace element of list by index

I'd simply like to replace the value x at index [[j,i]] in a two dimensional table with the value ...
2
votes
1answer
204 views

How to define a variable as a function of another variable?

I want to define a variable q which is a function of t. And I want to define another variable ...
2
votes
1answer
46 views

Strange behavior when defining a symbol/function pointwise

I am well aware of the fact that floating point number have finite precision, so one needs to be careful when comparing them. Still, I find it disturbing/surprising that the following input into ...
5
votes
1answer
93 views

Naming conflicts with Dummy variables in several packages conflicts

I'm using several packages in a notebook. In each packages there is functions defined with dummy variables. When I load the several packages in my session, i've got a warning message: ...
12
votes
1answer
289 views

Orderless pattern matching

The MMA docs state that "In matching patterns with Orderless functions, all possible orders of arguments are tried". Why then does the following not work? ...
138
votes
7answers
6k 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: ...
0
votes
1answer
56 views

Setting the solutions of an equation as a variables [closed]

This is probably a simple question, but i couldn't find a solid answer. So i have an equation Solve[{F[x, y] == 0, G[x, y] == 0}, {x, y}] but i want to use the ...
4
votes
0answers
87 views

Using an external Pattern breaks Format

I noted while writing this answer that using an external Pattern on Format doesn't work: ...
3
votes
2answers
2k 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
0answers
53 views

Subscripts in variable names: Bug?

In the following plot, one of the two functions {-par, par} defined by ...
8
votes
1answer
116 views

Maximum number of literal values for SetDelayed?

Under what circumstances should I expect Mathematica to turn a delayed assignment into an immediate assignment? I have put together a minimal example (available here) which demonstrates this behavior. ...