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
7 votes
4 answers
276 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
83 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
35 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
  • 651
0 votes
1 answer
44 views

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

Consider the following symbolic definitions: ...
John Taylor's user avatar
  • 4,642
0 votes
1 answer
67 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
80 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
45 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
  • 695
0 votes
0 answers
19 views

Specifying and assigning arguments of a function to be real

I have the following complex matrix that I wish to integrate (element-by-element) ...
kowalski's user avatar
  • 375
2 votes
1 answer
71 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
51 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
35 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
90 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
69 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
80 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
274 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
83 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,047
1 vote
1 answer
80 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
70 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
135 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,258
0 votes
1 answer
82 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
218 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,516
1 vote
1 answer
118 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
68 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
108 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
  • 143
0 votes
0 answers
44 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
36 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
473 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
79 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
47 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
73 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
  • 139
2 votes
1 answer
169 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
  • 323
1 vote
0 answers
86 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
  • 323
6 votes
3 answers
162 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
169 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
102 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
116 views

Very simple, unexpected Low Performance of set(=)

...
imida k's user avatar
  • 4,047
6 votes
1 answer
342 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,079
0 votes
1 answer
82 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,688
0 votes
0 answers
147 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
109 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,047
0 votes
1 answer
197 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
  • 55
0 votes
0 answers
36 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
2 votes
2 answers
257 views

Why is the parametric plot failing?

I tried running the following code but it doesnt seem to be working, it seems to be stuck on running. I think it's got something to do with the way I am defining functions with a variable integration ...
valcofadden's user avatar
8 votes
0 answers
171 views

Defining a SparseArray functions in Mathematica 13

I am defining a sparse array as a function of argument x, i.e. f[x_] = SparseArray[{1->x}, {3}] In Mathematica 12 this works perfectly, I can pass arguments and ...
Alik's user avatar
  • 81
0 votes
1 answer
64 views

Part of array as a blank variable [duplicate]

I have a little question. Let me define the function: f[k_]:=k So 'k' in the argument of 'f' is a blank variable. Is there a way to define a part of array as a ...
Lorenzo Bagnasacco's user avatar
0 votes
1 answer
94 views

Errors appear after integration of an interpolating function

I have a little question about integration of an interpolating function. There is an error in assumptions of the integral. I have a function that was obtained with an interpolation method: ...
Lorenzo Bagnasacco's user avatar
1 vote
0 answers
113 views

Plot implicit function with intermediate variable

Cross-posted in Wolfram Community. Here, I intend to plot a 3D picture of with two implicit functions where $x, y, t, \xi, \eta$, are variables. Of course, these variables can be constrained to ...
InFei's user avatar
  • 115
1 vote
1 answer
170 views

Numerical integration in one variable, of a multivariable interpolation function

I create the following set of data: newmatrix = Flatten[Table[{t, v, new[t, v]}, {t, 0, 2 Pi, Pi/4}, {v, 0, 1, 0.01}], 1] where ...
Lorenzo Bagnasacco's user avatar
1 vote
1 answer
86 views

expression evaluation for Compile[] too time consuming

I need to use Compile[] for a very large expression to be integrated. But for Compile[] the expression has to be evaluated, and this takes endless time. The expression is composed of several functions ...
lxndr's user avatar
  • 135

1
2 3 4 5
11