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

8
votes
1answer
146 views

Why does the global variable exist here, where it was declared only in Module?

Why does Mathematica choose the mechanism that makes the global variable a here while parsing? In ...
0
votes
0answers
46 views

Minimize variable domain neither real nor integer [closed]

In Mathematica, can I have a variable domain something like x ∈ {1, 1/k}, where k is a constant? In my problem formulation ...
0
votes
1answer
30 views

This vector definition with index in subscript is incorrect [closed]

I am trying to define a vector of values. Here is an example n = 8; Table[Subscript[ω, i], {i, 1, n - 1}] = Table[Sqrt[2], {i, 1, n - 1}] Yet this leaves me ...
7
votes
2answers
3k 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
1answer
29 views

Series Soln False error [closed]

When I try to define my equation : sys3 = {y'[x] == 2 y[x]/(1 + y[x]^2) - Exp[y[x]]/(1 + Exp[y[x]]), y (0) == 1} OR ...
1
vote
0answers
32 views

How to define a variable describing several options? [duplicate]

Plot[y=x, {x, -1, 1}, PlotPoints -> 24, MaxRecursion -> 0, ColorFunctionScaling -> False, BoundaryStyle -> None, MaxRecursion -> 0] I will ...
1
vote
1answer
79 views

`Quit` vs `ClearAll[“Global`*”]`

Quit erases all the definitions (by quitting the kernel), but so does ClearAll["Global`*"] (or other contexts). What's the ...
1
vote
1answer
66 views

How to extract all necessarily code for a function?

Many times when someone pastes a piece of code into SE there are missing values and symbols that the user left out. To prevent this I'm looking for a function that uproots other functions (extract ...
8
votes
2answers
524 views

Character to replace _ in symbol names?

In C, _ comes in handy when naming variables and functions, as a replacement for space. For example: ...
4
votes
2answers
300 views

How can I define variables that follow a naming pattern?

Let's say I have this enormous list of a million elements, and I want to access this list piecemeal in non-intersecting sublists of length ten. If ...
27
votes
5answers
2k 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. ...
1
vote
2answers
53 views

How do I tell if a function definition “contains” a symbolic expression?

Consider a definition like f[x_] := x[[1]] + x[[3]] + x[[1 + 2]] I want a "ContainsExpression" which I can use similarly to ...
149
votes
7answers
7k 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
41 views

How to erase definition introduced by using Set instead of Equal in Solve [closed]

When trying to solve a set of equations, I made a mistake by using = instead of ==. Now when I fixed the mistake, the equation ...
3
votes
1answer
73 views

plotting after solve does not display anything

I'm quite new to Mathematica language, I am trying to figure out where I am making mistakes in Plotting a specific function that depends to other variables: I want to plot ...
9
votes
3answers
444 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 ...
18
votes
5answers
481 views

How can one manually change the rule ordering

I have a function which has some general behaviour, but that should act on some specific kinds of objects in some other way. I know that Mathematica is supposed to automatically order the rules so ...
11
votes
4answers
896 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 ...
1
vote
1answer
47 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[...] ...
2
votes
3answers
70 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
95 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
171 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
71 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 ...
42
votes
5answers
21k 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
346 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
47 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
358 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
60 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
68 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
58 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
75 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,...
2
votes
0answers
61 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
102 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
107 views

Module, local variable

Lets say I define a Module, that internally use iterating in a Table or Do, say something ...
1
vote
1answer
56 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
46 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
211 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
318 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
116 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
37 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
239 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
108 views
3
votes
2answers
76 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
177 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
116 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] ...