# Tagged Questions

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.

59 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 ...
63 views

### Subscripts in variable names: Bug?

In the following plot, one of the two functions {-par, par} defined by ...
200 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: ...
75 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. ...
89 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?
60 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 ...
155 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 x[...
167 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 ...
64 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 ...
228 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 ...
143 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?
75 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 yet)...
242 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 ...
321 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 ...
193 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: ...
16 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: ...
353 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[] ...
25 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 ...
108 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 ...
93 views

### Numerical Integration/Function

I have a problem with a function defined numerically through an integral of the form: ...
88 views

### Using an external Pattern breaks Format

I noted while writing this answer that using an external Pattern on Format doesn't work: ...
311 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? ...
158 views

### Module function corrupts string? [closed]

I have the module who should replace some elements of a matrix with checkboxes ...
82 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 ...
187 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 ...
9k 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, ...
29 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 ...
128 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. ...
95 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: ...
120 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 ...
155 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. <...
129 views

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 ...
114 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, ...
120 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 ...
193 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 ...
2k views

### Assign output of solve to variables [duplicate]

I have this input: Solve[x^2 + 3 x + 2 == 0, x] which gives this output: {{x -> -2}, {x -> -1}} I want the first x ...
263 views

### Find all heads a function is defined on

So say I've got a function g defined as follows: g[x_Integer] := x + 1 g[s_String] := s <> "!!!" How would I write a ...
327 views

### Is garbage collection broken in version 10.0.0?

Bug introduced in 10.0.0 and fixed in 10.0.1 In version 10.0.0 under Windows I am observing the following behavior: ...
189 views

### Local variables whose definitions depend on each other [duplicate]

Consider the following (pseudo-)function definition: f[l_] := Let[{ a = Length[l], b = First[l], c = b/a, }, c*10] So for ...
83 views

### Store matched variables

Edit: I am matching and replacing a particular expression. At the same time... I want to store matched variables for later use. I got it to work with messed up code involving ...
238 views

### Solving equations with QuantityVariable

I'm trying to understand how to easily solve equations that use QuantityVariable. Why does this fail? ...
39 views

### Why would this function work only when I make a copy of the variable? [duplicate]

Why would this function work with a copy of the function variable: ...
195 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 ...
43 views

### Reducing Output length by introducing new variables [duplicate]

I have outputs like "expression/(1+3*c^2) +anotherexpression/(1+3*c^2)" and so on. Is there any way to set 1/(1+3*c^2)=A where A is a new variable so that the output reads like "A*expression+A*...
351 views

### specifying a list (vector) of arbitrary length

When trying to do symbolic calculations in mathematica involving a space of dimension n, which is arbitrary but fixed, I'd often like to work with vectors that have ...
140 views

### How do I constrain variables to a user-defined domain in ArgMax?

I am trying to ArgMax a function over x, but x is only defined between ...
2k views

### Best practice of passing a large number of parameters to functions

I have a number of functions that all take a large number of parameters. I am wondering what is the best practice of passing these parameters to those functions. I could, of course, simply specify ...
160 views

### Multiple down-values with exactly the same lefthand side

I was working on an answer to this question, when I was sidetracked by what I bring up here. I wanted a function, which when given a string representing a binary number, would convert the string to a ...
I want to create a function that will take a variable $x$ and reassign the value $x+2$ to $x$. So f[x_]:= x += 2 However: ...