# Questions tagged [variable-definitions]

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.

399 questions
Filter by
Sorted by
Tagged with
138 views

### How do I create a variable that uses I?

I'm planning on working with a set of non-linear differential equations. A few of the equations look like: Mathematica tells me that I is protected. Is there any ...
44 views

### Save nested Solve results into variables (edited)

I have some solve results stored in the ptes variable: ...
29 views

### Use ChoiceDialog to assign value to a variable within a function

This may be a routine answer that I have overlooked, but I am stumped... If I want to write a function using ChoiceDialog, how can I use what ChoiceDialog returns (true or false) to either set a ...
44 views

### Defining a function that outputs a matrix, and later finding its eigenvalues

I am trying to do the following: I have a simple 2x2 matrix that depends on three parameters (physically -- momentum coordinates kx, ky, kz). Then I want to replace each of these parameters by a ...
198 views

I'm trying to define a complex function to be able to do analytic calculations. Specifically, I want to define a function $A(x,t)$ in the complex plane with argument $\theta(x,t)$ and modulus $R(x,t)&... 1answer 93 views ### Problem with defining a simple linear operator I need to define a linear operator, which should have very simple linearity: myOp[Plus[f_, g_]] := myOp[f] + myOp[g] myOp[a_ f_[x_, t_]] := a myOp[f[x, t]] where ... 2answers 58 views ### How to define multivariable vector funtion? [closed] I would like to define a function of variables having two components as$u(x,y) = (f(x,y),g(x,y))$. I defined such a function as u[x_, y_] := {f[x, y], g[x, y]} ... 2answers 459 views ### How can I make assignments persist across sessions? Yesterday, I imported a large set of data into a Mathematica notebook and stored each imported list of numbers in a function. For example, I would map a list like ... 2answers 505 views ### Can one define 0 Log = 0? With reference to this post, can one define 0 Log = 0 in Mathemtica? 2answers 129 views ### VectorDensityPlot, [closed] I'm trying to plot the following function for two different values of variable m. However, it seems the second figure never appears. Weirdly, I noticed that real numbers are being attributed to ... 2answers 39 views ### How can you define a function with variables and put it equal to a function that is already defined? [closed] Lets say you have a function: f = x^2 + y^2 Now I want to define a new function of x and ... 0answers 34 views ### Is there a difference between these two ways to define a function? [duplicate] (I took this example from another question) f = 0; f[n_] := f[n] = DigitCount[n, 10, 1] + f[n - 1]; f I notice that this example defines f(n) in a ... 1answer 45 views ### Plotting a complicated function defined in terms of other defined quantities Perhaps this question will be too broad or poorly asked since it is about some very simple problems and I apologize if that is the case. So, I'm just trying to plot the curve of a complicated and ... 0answers 21 views ### Seeing definitions of built-in functions [duplicate] Possibly a very amateur question, so I'll apologise in advance. I'm reasonably new. I'm trying to write a Dot equivalent of ... 3answers 124 views ### Globally Defining a Variable that Depends on Arguments of Functions [duplicate] I have many delayed-defined functions of many variables, and all the functions share a term containing some of these variables. Thus, I would like to just call the term ... 2answers 89 views ### Changing the values of variables throughout a notebook I have a model with many parameters, and I'd like to see how the model changes when some of those parameters change. Right now many of those parameters are set to prescribed values, i.e., ... 1answer 56 views ### Factoring out a parameter I have some function: f[a_,b_,c_]:=Sqrt[a^2+b^2+c^2] Is there a way that I can factor out parameter (variable) b like this: <... 1answer 41 views ### Relations between Function Variables in Computations I have the relation λ=c/f, respectively f=c/λ and a simple function n[λ_]:=λ²+1. I'd like to differentiate the function with respect to f, then plot it as a function of λ again. For this, I can define ... 1answer 79 views ### How to define a variable to be a function of all the arguments but one? I have several variables (coordinates)$x_1, x_2, x_3, x_4, z$and a lot (21, to be precise) functions$g_i$which are assumed to depend on$x_1, x_2,x_3, x_4$, but not on$z$. I also have a ... 1answer 49 views ### Why does LinearModelFit give me an equation in$z$rather than$x$? I am working on a Mathematica notebook and making graphs for my lab. I can't make a graph for my linearized data as LinearModelFit gives equation in ... 1answer 70 views ### Using both subscripted and non-subscripted variables in an equation I'm getting started with Mathematica, as I have been using Maple in the past. Is it possible to define two variables$\alpha_1, \alpha_2$and then still use$\alpha$as a parameter of a function and, ... 1answer 65 views ### Question about ListPlot of variables [closed] My question is trivial but I don't seem to be able to get the answer. Suppose that I do a numerical computation (division of some numbers that come from the numerical solution of an NDSolve or ... 1answer 102 views ### Get the name of symbol inside a function [duplicate] I have a list t1Funcsv0={0.10000000000, 1.00000*10^-7} and I have a function ... 1answer 31 views ### Evaluation of parameter inside FindMaximum Why does this work: Table[ FindMaximum[x^2 - y^2, {y, 1}][], {x, 1}] While this does not: ... 2answers 165 views ### How to use a variable in a function that can't be clobbered by variable name collision? Not really sure what the right question to ask is. But here's what I'm having trouble with: ... 0answers 41 views ### How to define a variable$x$such that$Abs[x]<1$and use this globally without having to re-write it again and again? I am writing a code or a calculation of a very complicated function and my main variable is$x$such that$-1<x<1$. This assumption has to simplify my final answer a lot, but since the final ... 1answer 77 views ### Problem with local variables when using Module twice in the same code ... 0answers 56 views ### Assign a variable to an expression in Mathematica I have the following matrix {{a^2 + b + \[Sqrt](m + n) + 5, 23 x + 7 a}, {14 b, a^2 + b + \[Sqrt](m - n) + 5}} I want to replace the expressions ... 2answers 548 views ### Confusing behavior when passing a variable vs. inlining a function call Newbie question here. Consider the following two functions: ... 1answer 141 views ### Attempts at backwards compatibility I have written a package in Mathematica 11, and I would like to provide some backwards compatibility to earlier versions. An example is the function Echo. ... 2answers 105 views ### how can I define a symbol as a global real number? Say there is a complex number a=x+I, where x is a real number. Then b=Join[{a},{1+I}], and I ... 2answers 367 views ### When to name a variable with$

There are some symbols in the Wolfram Language that start with $, including$Abort, ...
125 views

### How to reuse variable - Error: Pattern appears on the right-hand side of rule [closed]

I do not know enough about Mathematica to understand why the following statement won't save the variable for me for later use: x_fake = Table[i, {i, 1, 100}] It ...
66 views

### Mathematica is picking up variable definition from other files

Mathematica is using definitions from other open files in the same folder. I want variables not defined in a particular file to be treated as undefined variables. I do not want Mathematica to pick ...
474 views

### Different strategies to get a clean Kernel. Quit, Exit, ClearAll, Remove, CleanSlate?

Often new users face problems with lingering definitions that, if unaware, may cause unexpected and frustrating behaviour. There are several answers that illustrate different aspects of the solution, ...
449 views

### FindRoot fails 100 iteration precision

I am attempting to find roots of a complex equation that involves exponential functions and small approximation values. I have had success using FindRoot for values ...
228 views

### Create local alias for variable

I have a function whose parameters are passed "by reference" Clear[foo] SetAttributes[foo, HoldFirst] foo[t_] := t = 10 Is it possible to create an alias for <...
70 views

### How to define the function [duplicate]

How to define this function?  A_{n,k}:= \begin{cases} 0, & \mathrm{if } \ k<0 \\ 1, & \mathrm{if } \ k=0 \\ (2k+1)\binom{2k}{k} \sum_{n\geq j\geq 2k+1} A_{j,n} \binom{j}{2k+1} ...
679 views

### Using loop index for variable names?

I am trying to generate different variables in function of a loop index. In example: generating a list with var1 = 1, var2 = 2, ... ...
134 views

### Using Association[] in an Immediate Function

I have an Association[] which is the result of an intensive computation. Its values include the variable x and I would like to ...
77 views

### How to set a particular element of a list to a number?

I have a list {a,b,c,d}, and I want to set the 1st element and the 3rd elements equal to 5 and 8, respectively, leaving 2nd and 4th as they are (...
237 views

### How to define the result of Solve as the variable [duplicate]

Consider the operation Solve[f[x,y,z] == 0, x] I want to put the solutions for x obtained by this operation as the new variable. I tried to use ToString, ...
99 views

### Writing a recursive block 'while' [closed]

I tried to write a program according to the definition using operator While, but it returns zero for each d an ...
53 views

### Using Variables[] as the argument of Plot[]

I want to use the Variables[] function to extract the name of the variable of a function, such that I can use it later, e.g. in a ...