# 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.

448 questions
Filter by
Sorted by
Tagged with
184 views

### KeyExistsQ[] but for functions?

Is there a good way to check if, say, f[5] has been defined if f is a function, similar to ...
51 views

### Defined function keeps the variable

I'm a beginner at Mathematica, and I have a problem finding the roots of a function for a specific variable (using Jens' findAllRoots function). Due to the nature of my problem, I need to compute ...
444 views

### Create variables in a for loop

I am very new to mathematica, but it would be much easier for me to use For loops in order to create variables. My train of thought was simple, but apparantly does not work. Let's say I defined these ...
833 views

### When is a symbol a Symbol? Is there an easy Mathematica way to test if an object is a symbol sort of like a SymbolQ?

Yes I know there is no built-in native function called SymbolQ (but JavaScript does). However, could one be simulated to work for most cases? I often rely on ...
47 views

### How to Append the value of a variable and not the variable itself

So lets say I have a = Some complicated code that changes list = {} AppendTo[list, a] Obviously it would give me ...
28 views

### Referencing data in sets of sets

Given a data set how to assign definitions to the subsets. For instance given the data data = {{0, 1, 1}, {0, 1, 1}, {1, 1, 0}, {0, 1, 1}, {1, 1, 0}} if {0, 1, 1} ...
97 views

### Is there something wrong with DistributeDefinitions?

I have the following code, which fails to distribute the DownValues for the symbol f. Could anybody please explain what is wrong. ...
92 views

### Subscripts use to make expression readable [duplicate]

I am trying to write a function in mathematica which depends on different parameters. For example $$f(x_1, x_2, x_3, x_4, x_5)= 2x_1+\sin(x_2)+x_3*x_4-x_5^{-1}$$ (My actual function has 12 such ...
300 views

40 views

### Problema simulating FindRoot

I am writing a procedure that simulates the findRoot built-in function using the same code that appears at chapter 6 of $\textit{Programming in mathematica}$ by Paul Wellin. The code is the following....
55 views

### syntax error when defining a list of matrices: "...cannot be followed by.."

I am literally just defining a list of matrices, but seem to run into the following error when adding the last matrix. (so to be clear, I get no error when I take out the last matrix entry). What's ...
43 views

### Assign variable to solve [duplicate]

I would like to assign my result from equation. I tried /. and := but it gives me empty variable. How can i fix it?
50 views

### Getting a stored variable from its value

Given a numerical value, is it possible to check whether that value is stored in (or defines) some variable in the notebook? Maybe if I could list all of the defined variables, then I could simply ...
129 views

### Mathematica Won't Recognize a MeshRegion

I've implemented the code in the top answer of this question on the Plateau problem in differential geometry, and it works with the example shown in Example 1, so there is nothing wrong with the code. ...
54 views

### How to define an Intermediate Variable [duplicate]

I want to find the relationship between several parameters. But I don't know how to define an Intermediate Variable. For example: I want to know the relationship between x and {y,z} which will satisfy ...
31 views

### Avoid an Error Message when Importing

Consider the following code Button["Import", file = SystemDialogInput["FileOpen"]; data = Import[file], Method -> "Queued"] which yields a button which, ...
78 views

### Automatically generating and labelling controls in Manipulate

Consider the following code ...
81 views

### Issue with Solve, NSolve, FindRoot

I have this code that I've been trying to get working for some time. I asked some questions before which helped but still struggling! ...
35 views

### Issue with variables/functions in solving equations

I've been posting some questions all around issues with defining and using variables/functions in Mathematica. Based on the answers/comments I got I still cannot make this simple code work... Why is ...
74 views

### Table of Variables within Manipulate

Given a certain number n, I want to define n controls within Manipulate with the correct ...
342 views

### ParallelSum vs. Sum: New functions also defined in other Kernels?

Set-Up: While I had tested a few toy examples that ParallelSum produces the result faster than the Sum, here I encounter one example in my code that the ParallelSum produces either wrong/incorrect ...
98 views

### Store boolean expression into a variable

My purpose is to use a boolean expression as a requirement that a pattern must comply. The requirement is c1 == "a", and I am using it to select a string from a ...
618 views

### Do Table iteration variables need to be localized using Module?

Lets say I define a Module, that internally use iterating in a Table or Do, say something ...
104 views

### Is it possible to use a previously defined value in subsequent definitions of a Block?

Is it possible to use a previously defined value in subsequent definitions of a Block? According to syntax coloration, this should work as expected, that is, ...
51 views

### Variables for multiple data files plotting using same Mathematica notebook

I am not an expert in mathematica, I have this following code. As you see I import a text file under the name "MyPoint1", plot with "pAll" then I do some more calculation with more variables and ...
87 views

### Defining list of new variables at once (in a loop?)

I have a list of solutions Subscript[x, 1][t], i = 1,...,n (n given). I would like to use these variables to define new variables such as: ...
134 views

### Is there a way to use a subscript as variable? [duplicate]

I'm really new with Mathematica, and I could not find a previously question similar to this one. Is there a way that Mathematica can be made to recognize and treat a subscript letter as variable so ...
54 views

### Assign dynamic string in a list to variables in functions

I have 2 lists: ...
16k 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: ...
241 views

### Put local variables for Block in a variable

Is is possible to assign {x = 2, y = 3, z = 4} to a variable var so that one can write ...
79 views

### How to access all instances of a defined function

This should have a simple solution, but for some reason I cannot find how to do this. Let's say I have a "function" where I have defined values (in my actual example I have many instances of this, ...
39 views

### Series expansion of explicit functions

For the following input, zv[u_, v_] := v + zv1[ u, v]/u; mvu[u, v] := D[zv[u, v], u]; Series[mvu[u, v], {u, 0, 1}] the output is ...
39 views

### unknown variable in a recursion relation

I have a code as follows ...
46 views

### Reversing the flow of the equation sign. Compacting an equation. Choosing which variables to show

Here's a simple example of what I'm trying to get at with that mysterious title. I start off with a Hermitian matrix that I derived analytically ...
140 views

### Properly defining and plotting a function that requires NSolve`

I want to defined a function that solves some equation numerically: ...
82 views

### Variable substitution like usual maths

So... I'm trying to get some simplifications on equations using own defined variables, but the tries I gave didn't result on what I wanted. The problem: I have 2 variables defined as: ...
I have some vector $K = [K_1, K_2,...K_n]$ which is a function of variables $(x,y)$ i.e. $K = K(x,y)$ I want to symbolically calculate the partial derivatives e.g. $\partial_x K$, \$\partial_x \...