Skip to main content

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.

Filter by
Sorted by
Tagged with
6 votes
1 answer
226 views

What is the difference between Clear and Remove?

I assume that there is difference between the commands Clear and Remove. But it seems to me that I am not aware of any caveats ...
MathArt's user avatar
  • 233
1 vote
1 answer
58 views

Import all files in NotebookDirectory, store each list in a variable with the file name without extension

I have many files stored in the notebook directory, which are called "lista.dat", "listb.dat", ... I would like to import all of them and save them as variables called "lista&...
Xorker's user avatar
  • 23
2 votes
2 answers
176 views

How to calculate a definite integral with a parameter

I am trying to calculate the following definite integral with the parameter H. So my result would like to be a analytical one with the parameter H. For example for the integral NIntegrate[ax, {x, 1, ...
Dinos Volanis's user avatar
0 votes
0 answers
43 views

Invalid variables error in SolveValues when using an array of variables

I was attempting to run some code similar to the simple example below. ...
VertexVexed's user avatar
0 votes
1 answer
71 views

How to set optional variables in Function?

When using Function, is it possible to set specific arguments to be optional? For instance, in f = Function[{x, y}, x + y]; Can ...
sam wolfe's user avatar
  • 4,863
0 votes
1 answer
57 views

Defining a function of a variable through another intermediate variable

The following is a really simplified version of what I'm trying to do. I have a variable fn defined in terms some other variable x. I then want to define a function of x through the variable fn. ...
Rudyard's user avatar
  • 471
2 votes
1 answer
74 views

Defining multivariable function from previous cell output

In the following, I would like to define a function $h(\theta, \beta, \alpha_1, \alpha_2)$. The function $h$ should be defined by the output of a previous function (which includes the partial ...
John Doe's user avatar
  • 229
1 vote
1 answer
58 views

How to simplify expression depending on former definition?

If a = x + y b = x - y u = a + b v = a This gives me for u/v the expression (2 x)/(x + y)...
user57467's user avatar
  • 2,728
10 votes
5 answers
328 views

Create a list of indexed variables and assign values in one line of code

It is easy to create a list of indexed variables F/@{1,3,6,8} I would like to assign values in the same line of code ...
Phillip Dukes's user avatar
1 vote
1 answer
89 views

How to save a definition in one file and update it easily?

When running a task which needs a long time for computation but returns a simple result, I often do this: ...
Crack-Hu's user avatar
1 vote
0 answers
36 views

Sending definitions from the subkernels to the kernel

Sometimes it is convenient to define an indexed quantity g[i] as in f[i_] := (Pause[5]; i^2); Do[g[i] = f[i], {i, 10}]; A ...
Davi's user avatar
  • 671
0 votes
1 answer
46 views

How to define the following rule for all objects in a compact way?

Consider the following symbolic definitions: ...
John Taylor's user avatar
  • 5,827
0 votes
1 answer
72 views

Interpolation error to generate a two variable function

I am facing some issues with performing an interpolation. From the image, you can find the values in three columns, the 1st column is x, the second column is ...
Pooja Bhattacharjee's user avatar
1 vote
2 answers
85 views

Changing part of a list of unequal arrays

I have {x, y, f(x,y)} data in multiple (n x 3) arrays with unequal length, which I read in from different files in order to later plot them using ListPlot3D. I ...
Jani's user avatar
  • 13
0 votes
0 answers
55 views

how to use subscripted variable such as a_i as the control of Manipulate?

I'd like to define a series of variables called $l_1$,$l_2$, etc., in Mathematica, using the "ctrl+_" shortcut. Moreover, I want to use these variables as the controls of a Manipulate[] ...
larry's user avatar
  • 735
2 votes
1 answer
80 views

How to directly define a function as the solution of RSolve

This is probably very simple, but I just cannot find this anywhere online. I have the code ...
Matthew Neil's user avatar
1 vote
1 answer
57 views

Function definition inside Module with local symbol

Usually if I want to define a function using an expression I do: expr=x^2; f[x_]=expr; which usually works and give f a defination. But now if I want to do the ...
Cheng Tao's user avatar
  • 151
0 votes
1 answer
37 views

What is the relationship between a list of symbols created by a specific name, and a expression with such a name?

I'm trying to create a list of symbols called "x" for calculating symbolic gradients of some functions, so I write: ...
Xudong's user avatar
  • 3
1 vote
1 answer
156 views

Doing algebra with differential operators

I'm doing some work on stochastic processes, where I use random functions which are defined by their properties over averages, i.e $$\langle f(t) \rangle =0 \\ \langle f(t) f(t')\rangle = \alpha(x,y) ...
J Pin's user avatar
  • 11
2 votes
0 answers
70 views

Argument value loss using Listable C-Compiled Function

In my recent studies, I have come across a very strange anomaly with C compiled functions. When I call a function that has the 'Listable' attribute while global variables are accessed through ...
Michael Haring's user avatar
1 vote
0 answers
112 views

checking if a variable is defined

How can I check if a variable is defined? Definition[foo] produces: Null, but: ...
Aharon Naiman's user avatar
2 votes
5 answers
276 views

Repeating definitons of variables

I have the piece of definitions y = 1; x = 2; n = 2; a := (y^(x - 1) + n)/(y^(x - 1) + y^(x - 2)) I want to keep defining y as a by doing: ...
CAN GÜLLÜ's user avatar
2 votes
1 answer
85 views

Defining function for decimal value k[0.5+0.5]

k[1 + 1] = 2; k[1 + 0.5] = 1.5; k[0.5 + 0.5] = 1; {k[2], k[1.5], k[1]} // TableForm 2 1.5 k[1] Can you explain this phenomenon? I think the output should be ...
imida k's user avatar
  • 4,295
1 vote
1 answer
91 views

How to avoid using the principal branch?

How can I make Mathematica to use $Log[-1]=i\pi+2i\pi*n$ with $n\in\mathbb{Z}$? Currently, mathematica set $Log(-1)=i\pi$ and when I try to redefine the value of $Log[-1]$ I get the message "Set::...
Yair's user avatar
  • 117
0 votes
0 answers
73 views

Can you dynamically create variable names in Mathematica? [duplicate]

I was wondering if there is a way of Mathematica to read a string or number and create variable with that name. For instance imagine that I have a file with the word data1. I would want to create a ...
Granger Obliviate's user avatar
2 votes
2 answers
156 views

The way of converting a string to a variable in a loop?

I have 60 txt files which I want to import them into Mathematica using a Do loop. Each file contains some numbers (more precisely, a list of numbers). I want to put ...
Wisdom's user avatar
  • 1,268
0 votes
1 answer
84 views

Global order setting

I'm working on mathematical models using many alphabets and Greek characters as parameters or variables. However, The outputs show them in undesired order. Here are some examples: ...
Jack's user avatar
  • 1
2 votes
2 answers
237 views

How to implement Newton's Identities

I need to produce identities related to Newton's Identities of arbitrary order. More specifically, I need the identities in the following image for an arbitrary n: What I can't quite wrap my head ...
Wynne's user avatar
  • 1,526
1 vote
1 answer
155 views

My ParallelDo does not work

I have to do a lot of calculations that take lot of time, and using a Do loop is simply too long. It is the first time I am using ...
Eurabio's user avatar
  • 33
1 vote
1 answer
71 views

Initializing a system of abstract functions with a for loop [closed]

I am trying to initialize a collection of abstract functions $\theta_k(t)$ in a variable $t$ where $1\leq k\leq n$. I cannot define them explicitely; the entire point is that I want to numerically ...
gdd's user avatar
  • 133
2 votes
1 answer
109 views

SystemModelLinearize

The following are the state matrices A and B obtained by linearization using SystemModelLinearize ("DocumentationExamples. Modeling. Generator" is the circuit given by the official routine). ...
chen chen's user avatar
  • 165
0 votes
0 answers
57 views

Strange behavior with setting multiple values simultaneously

I'm having some strange behavior when trying to set multiple variables using {x,y,z} = {1,2,3}. When I enter "{a,b,c,a',b',c'} = {1,2,3,4,5,6}", it sets a,b,c,a',b',c' to 1,2,3,4,5,6 as ...
Will Chen's user avatar
  • 101
0 votes
0 answers
39 views

save function only for particular arguments to file

Define f[2] = 3 f[3] = 5 I know how to save the function to file: ...
hgrie's user avatar
  • 1
2 votes
2 answers
483 views

How can I make 10 variables from a for loop?

I used a for loop to make 4 variables: For[i = 0, i < 4, i++,bi=0] But when I write b0 or ...
Ahmed's user avatar
  • 369
1 vote
1 answer
83 views

How to define functions using $Z_2$ coefficients and $Z_N$ variables, e.g, realizing $1+1=0$?

A minimal example is to realize the following: $x+x = (1+1)x = 0$, and $x^{N+1}y^{N+1}=xy$, where $N$ is a given positive integer.
SimMach's user avatar
  • 113
0 votes
0 answers
52 views

Reusing local variables through Reduce and ToRules

Problem: I am interested in solving a system of linear equations through Mathematica. In my current test scenario, I am having trouble using the Reduce function followed by the ToRules command. I ...
Axion004's user avatar
  • 111
0 votes
0 answers
84 views

Getting .wl file without appending global' before variable names

I have a .wl file created using mathematica that contains: list = {{a->4, b->5}} When I read it in using Get["file.wl"] it reads in as: ...
David's user avatar
  • 159
2 votes
1 answer
198 views

Can you use superscripts as variable and function names?

I want to express the following function: $z^{(1)}=w^{(1)}a^{(0)}+b^{(1)}$ I have read in Mathematica documentation that Symbolize can be used to define variables ...
M.E.'s user avatar
  • 333
1 vote
0 answers
90 views

Why =. is not clearing the value of a variable in this case? [closed]

I am reading "Mathematics and Algorithms" as part of the Wolfram Tutorial series. In "Values for symbols" section of the "Algebraic Calculations" chapter it is described ...
M.E.'s user avatar
  • 333
6 votes
3 answers
171 views

How to define variables $a$,$b$,$c$,$d$ are all elements of set $\{2,3,5,7\}$?

I would appreciate it if somebody could help me with the following problem: I want to create a Wolfram Language expression that states that all $a$,$b$,$c$,$d$ variables are elements of the set $\{2,...
Young's user avatar
  • 259
5 votes
3 answers
174 views

Get the symbol name of the function's nth argument

I tried this: Plo[fun__] := SymbolName @ Part[List @@@ Unevaluated @@ {Hold[fun]}, {1}, 2] SetAttributes[Plo, HoldAll] On ...
user2679290's user avatar
0 votes
0 answers
67 views

How to define variables properly in mathematica, a variable with two name [duplicate]

I wanted to define a variable in the name "beam_frequency", this is quite possible in other programming languages like python and Matlab. How to define two pair variable name in Mathematica ...
Nanavanalla's user avatar
2 votes
1 answer
115 views

Implement recursion one step at a time with a function of more than one variable

i am trying to implement a recursive difference equation step by step, by implementing rules, similar to Rojo's method in this thread: How can I evaluate only a single step of a recursive function? ...
StevieP's user avatar
  • 23
8 votes
1 answer
118 views

Very simple, unexpected Low Performance of set(=)

...
imida k's user avatar
  • 4,295
6 votes
1 answer
457 views

Is K is a function? [duplicate]

Some of the capitalized single letters are functions. Starting a fresh kernel and typing in the 24 capital letters, the following letters turn black since they are special functions, ...
Kai's user avatar
  • 2,099
0 votes
1 answer
89 views

How to define prefix that can turn numeric?

I put these prefix in my init.m file. First I Unprotect all these symbols, set values and then ...
hana's user avatar
  • 2,390
0 votes
0 answers
187 views

Global assumption non zero

I would like to define globally an assumption stating that I have a nonzero real vector $v$. For now, I put : $Assumptions = Element[v,Vectors[{100},Reals]] but $v$ ...
Smilia's user avatar
  • 592
0 votes
0 answers
111 views

See variable as byte

I see variable v is occupying 112 bytes of my RAM. v = {3, 5, 7}; ByteCount[v] 112 Then how to see the content of the 112 bytes?...
imida k's user avatar
  • 4,295
0 votes
1 answer
255 views

How to convert mathematica root expression to readable one? [duplicate]

I am trying to find out at what regions a function is monotonically decreasing. The function is a function of X and has two more variables epsilon and B with the constrains 0 < B, 0 <epsilon< ...
TTT's user avatar
  • 57
0 votes
0 answers
37 views

How can I prevent functions and variables from being automatically cleared when I close Mathematica? [duplicate]

The following happens with every notebook I make: I define functions and variables. When I quit Mathematica and reopen the notebook, all of those definitions have been cleared. The functions and ...
nmehndir's user avatar

1
2 3 4 5
11