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

6
votes
2answers
93 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$ ...
3
votes
2answers
98 views

Sections with unidirectionally shared variables

I have 2 sections is my notebook: ...
3
votes
2answers
57 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 ...
1
vote
4answers
117 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 ...
0
votes
1answer
89 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
77 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
71 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 ...
0
votes
2answers
77 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
48 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 ...
1
vote
3answers
99 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
39 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
89 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: ...
0
votes
1answer
50 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 ...
1
vote
0answers
42 views

Subscripts in variable names: Bug?

In the following plot, one of the two functions {-par, par} defined by ...
0
votes
3answers
94 views

Define a matrix depending on variable in Mathematica [closed]

I am translating my code from Python to Mathematica. I am trying to define a matrix, whose values depend on a variable chosen by the user, called kappa. In Python the code looked like that: ...
2
votes
1answer
57 views

Is there a shorthand for Optional with Condition?

I have a recursive function that does some work to an object for a repeatedamount of times. ...
0
votes
1answer
48 views

Weird subscript name in output [duplicate]

One of my first times using mathematica, I'm getting a weird Subscript(1,0) output when I try to solve a derivative. What is going on and how can I fix this?
0
votes
1answer
50 views

Simplify huge output or using the output without showing it in full [closed]

I'm trying to solve a system of differential equations. It works fine but Mathematica creates a huge output, which, when shown in full, results in a file size about 100 mb. Using Simplify doesn't work ...
1
vote
1answer
108 views

Iteration convergence of Newton approximations

I am trying to determine for which initial values Newton's approximation of specific functions (EX: f(x)=x^2 -1)converge and to what numbers it will converge to. *Where Newton's approximations are ...
0
votes
1answer
116 views

Plotting Complex Numbers - Functions of Complex Numbers [duplicate]

So I have to generate a few different plots with z, where z is a complete number... z[x_, y_] := x + y*I F[z_] := (25*Pi*z*I)/(1 + 10*Pi*z*I) First, I need to ...
0
votes
1answer
46 views

Calling a function on a variable with parameters [duplicate]

I have an equation that contains parameters. I want to use it in a function like NDSolve, but I can't seem to figure out how to do so. Here's an example: I define ...
3
votes
1answer
128 views

How can I overload a function with multiple bracket-slots so f[a][b] and f[a] can coexist?

Maybe this is not even possible: I want to create a function f that can have two input brackets like: f[a_][b_:1]:= a*b and ...
0
votes
1answer
70 views

How to specify the domain of a variable?

How can I specify for every expression the domain of a variable without using assumptions everytime i have to simplify it?
0
votes
0answers
34 views

Variables input generation for Minimization in High dimensional space

I'm currently doing optimization in a high dimensional space. I was thinking of giving FindMinimum (or NMinimize not certain ...
4
votes
3answers
188 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 ...
8
votes
1answer
170 views

Context of localised (dynamic) symbols

When you localise a symbol with Module, the created unique symbol is usually in the current context. There seems to be an exception to this which has further ...
10
votes
1answer
174 views

Copy Built-in function to new name

It is know that some built-in functions are system function and changing their properties may cause trouble. Suppose for example I want to change features of Cases: ...
0
votes
0answers
14 views

Use of placeholders in functions [duplicate]

I'm having some trouble with Mathematica's placeholders within functions. The function sel[lowerLimit_] should select all elements of x that are greater than the lowerLimit: ...
7
votes
2answers
300 views

Using up-values and down-values

I have a problem I'm trying hard to find a solution for, although I don't know if a solution exists. The following rules produce the result e[2].f[] ...
2
votes
0answers
23 views

Determining default value from previous arguments [duplicate]

How does one specify a default value for an argument which is dependent on the previous arguments of a function? For instance, consider the function ...
2
votes
1answer
101 views

Table of references [duplicate]

I have a list of variables (say a, b, c, d, e) that I want to assign in a single command. {a,b,c,d,e} = {1,2,3,4,5} would ...
0
votes
0answers
84 views

Numerical Integration/Function

I have a problem with a function defined numerically through an integral of the form: ...
4
votes
0answers
86 views

Using an external Pattern breaks Format

I noted while writing this answer that using an external Pattern on Format doesn't work: ...
12
votes
1answer
255 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? ...
-6
votes
2answers
111 views

Module function corrupts string? [closed]

I have the module who should replace some elements of a matrix with checkboxes ...
0
votes
1answer
67 views

How to assign the array data to variables?

A very basic question but puzzled me for long time on how to assign array to variables. For instance, we have array {{t1,x1},{t2,x2}...{tn,xn}} how to assign the first element to variable t and ...
0
votes
0answers
12 views

Watching variables during Notebook work session [duplicate]

One feature that I have always wanted but could not find out if it was supported and that is to actively watch variables and their values while working in a Notebook session. In fact, there are two ...
6
votes
2answers
125 views

Injecting list of controls into manipulate

I am trying to program a method to manually move around graph vertices, and then output the new coordinates. I'd like to turn this into a function that can be called with a variable number of ...
1
vote
2answers
2k views

How to tell Mathematica that certain variables are real/imaginary, integer-valued, etc

I'm trying to expedite some quantum mechanical calculations by running them through Mathematica. Expectation values and stuff like that. When I say, for example, ...
0
votes
1answer
28 views

Variable as Difference of 2 Variables

I would like to evaluate a function based on the absolute difference of two variables. An example: g=5*x-5*x*y-5*y diff=x-y D[g,x] D[g,y] D[g,diff] I cannot find ...
3
votes
1answer
83 views

Defining a function that prints both the name and value of a variable defined locally within the calling function

To save time when debugging with Print statements, I'd like to define a function -- call it PrintVal -- that prints both the name and value of a variable defined locally within the calling function. ...
1
vote
1answer
88 views

How to form a variable from matrix elements

I have matrix with n rows and 2 columns, say m = {{x11, y12}, {x21, y22}, ..., {xn1, yn2}. Now, I want to form three new variables for example: ...
1
vote
0answers
109 views

How to create a complex variable from dated list values

Can anyone help me to construct a variable "PI" from values of variable x. Variable x represents a group of two time series rj and ri on equal dates(joined two dated lists with states).Variable x have ...
2
votes
1answer
102 views

Equivalent command to the Maple indets command

This carries on the discussion here and here. I had mistaken Variable[] to give you ALL variables in an expression, but apparently, it is not meant for that. ...
0
votes
1answer
103 views

About Symbolize and Variables

I do believe this sort of similar questions had been asked many times, so I have read a LOT. For example this and this as well as many other related posts. But a glance at what my main question is ...
3
votes
1answer
92 views

Need some explanation of “Global`*”

When I start a new notebook, I enter Names["Global`*"] I get this {"list", "msgs", "rhs", "z"} Then I enter, ...
0
votes
0answers
22 views

SharedVariable in WebMathematica

How can I create a variable to be used and setted over all my WebMathematica kernels? Here is the case: Create a package with do data structure like: data = ...
0
votes
2answers
116 views

Variable Value as Range

Thank you for the help so far! I would like to assign +/i signs for the function and solution such as (+)(+)(-) and therefore (-). It is working for the first evaluation, ╬╗lower, but not for the ...
3
votes
2answers
154 views

Convert matrix rows into variables

Can anyone show me how to set all matrix rows to variables. For example, I have matrix w={{1,2,3},{3,2,1},{0,0,0}} and I need to set each matrix row to be separate ...