# Questions tagged [assignment]

For questions relating to assignments to symbols, patterns, or expressions.

303 questions
Filter by
Sorted by
Tagged with
157 views

### Transform a list of rules into a list of function definitions

I have a list of rules obtained by solving a system of equations, e.g. {f[x] -> a + 3 h[x], g[x] -> 2 a + c + 6 h[x]}. I wish to convert this list of rules ...
114 views

### Assign condition to variable

I would like to integrate the output of a Solve. But Solve gives me an expression with some conditions. I would like to assign this condition to variables. For example: ...
• 133
41 views

### Why am I getting this error? Set::setraw: Cannot assign to raw object 73

Here is my code. I tried all modifications to this code but I'm not able to resolve the problem. Can anyone tell me why am I getting this error? ...
1 vote
164 views

### How can I express these two sets and find their intersection by Mathematica?

My code: M = Interval[{-1, 2}] N = Reduce[ForAll[{y, x}, x \[Element] M, y == 0.5*x^2 - 1], Reals] Intersection[M, N] Gives an error message : Set::wrsym: Symbol ...
• 45
22 views

### How do I make a formatting rule for a pattern not containing a symbol to attach a rule to

I can define a formatting rule such as Format[ex[ls_List], TeXForm] := "grgr" But when I want to define such a formatting rule for a general patter, for ...
• 4,651
48 views

### Problem with SetDelay [duplicate]

I am trying to do some calculations on very long and difficult equations. Ultimately, I want to create a function to NIntegrate my result, but I want to set it as SetDelay (to be evaluated after ...
• 133
1 vote
57 views

### Multiple assignments of items of a list [closed]

Suppose to have a list of items and two lists of indexes that are parametric and for example are: l={2,3,5,7,11,13,17} i1={3,4,7} i2={4,7,3} I need a clever code ...
39 views

### Formula to resolve max size of subset of set of strings

A set made up by strings, each string contains m characters, character is either ‘0’ or ‘1'. Now, what is the max size of the subset, which in the subset, each string has at least n characters differ ...
32 views

### How to find clear solution for iterative problem by condition $<v_k ,v_n>=0$ If $k!=n$

I want to find x[n] by v[n] values without x[n] in solution by iterative below problem: <...
84 views

### Understanding SetDelayed, ":=" [closed]

Consider the example below, p = {1, 2, 3}; x = {x1,x2,x3}; fun[x_] := {{1, 0, 0}, {0, 1, 1}} . (p + x); fun2[x_] = {{1, 0, 0}, {0, 1, 1}} . (p + x); I expected <...
67 views

### Delayed evaluation of nested functions

i am new to Mathematica. Here is the situation: I have a exponential function of n,t that I want to calculate integral over t ...
1 vote
107 views

### Replacing Kronecker delta times expression with the expression with inserted index

Consider the following symbolic expression: expr = f[a,b]*g[c,d]KroneckerDelta[a,m]KroneckerDelta[d,k] + KroneckerDelta[a,p]f[x,a]+const Could you please tell me ...
• 5,913
137 views

### How to assign the following rule?

Consider the following object: function[x,a,b]. It is a symbol carrying one "coordinate" x and two indices a,b. I ...
• 5,913
235 views

### How to assign values to x1+x2, x1x2? [closed]

x1 + x2 = -((2 a^2 k m)/(b^2 + a^2 k^2)) Enter the above content and an error prompt will pop up How to assign values to x1+x2, x1x2?
• 4,824
111 views

### SetDelayed assignment not producing expected result when using ReplaceAll

In Mathematica, I am surprised that the following code does not do what I expect (what I expect is in comments after each evaluation). The problem seems to be due to the fact that when I define test ...
• 297
1 vote
232 views

### How can I permute two delayed variables?

Two variables with delayed expression are used for a random number generation: ...
• 926
1 vote
154 views

### Associating a string variable with a numeric variable

There is a translation operation from a numeric variable to a string variable: a[i_, j_] := Symbol["a" <> ToString[i] <> ToString[j]] How ...
• 1,883
206 views

### About how to speed up in assignment

I would like to know if there is a way for increasing the speed of the following computation: I have a list, let's call it list, and another list of values, val. I ...
• 31
120 views

### Conflicting variables

So, I read a set of variables and respective values from a file and store them in a variable specs = {{"Type", "KP", "fp"}, {"LP1", 2, 2000}, {"Type", ...
1 vote
36 views

### Hold around SetDelayed with Graphics [duplicate]

Minimum Working Example I've defined my own plot function, which does a lot of stuff to the inputs before passing it into the Graphics function. Because of that, I'...
56 views

### Define a function using output of another function [duplicate]

I am away from my computer and therefore unable to experiment, but I am keen to scribble down a few Mathematica operations in note form ready for my return. So, forgive the simplistic question… Say I ...
• 2,335
1 vote
34 views

### Using plot on named expression and explicit expression produces different results

There is some strange behaviour in Mathematica which I don't understand. If you call a function like ContourPlot on two identical expressions (one a named expression, and the other the same expression ...
64 views

### How to assign a value for specific Indeterminate expressions?

I wanted to form a list as follows j=1; Table[(i-1-j)^k, {i,2j+1}, {k,-j,j}] However, an error message occurred since the list included none positive powers of ...
• 153
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 ...
• 101
77 views

### Error: Invalid integration variable or limit(s) in {-6.28293,0,\[Pi]/2}

When i try to evaulate h at vaule (for example 0), i get a result. When i directly plot the output of h, it also works, but when ...
480 views

### Define a delayed function depending on a global variable as though the variable's contents was pasted

Problem Say I previously defined a variable (maybe through some extensive calculation) thing = (a+x)y Then, I want to use that expression elsewhere. In general, I ...
• 1,055
339 views

### How to assign a value to something inside a module globally? [closed]

Let's say I created a function that calculates something inside a module. How do I assign that result to a global value? Let's say I have this: ...
1 vote
92 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 ...
• 333
38 views

### ToExpression in nested Set/SetDelayed

Suppose we have the following definitions. ...
• 487
1 vote
52 views

### Manipulating the list with variables

I am trying to find the maximum element of the list for a given value of variable $c$. The example of the list is as follows: ...
• 81
63 views

### Symbolic re-assignment of products

Suppose I have some symbolic tensors $X,Y$ and I want to assign X.Y into something else without specifying what $Y$ is. For example, I may want $Y$ to serve as ...
116 views

### Problem with parametric integral with variable bounds

d[p_, B_] := \!$$\*SubsuperscriptBox[\(\[Integral]$$, $$-B$$, $$+B$$]$$Cos[ p\ x] \[DifferentialD]x$$\) Plot[d[x, 2], {x, -10, 10}, PlotRange -> Full] I ...
• 163
1 vote
48 views

### The assignment problem in Plot function [closed]

I used Mathematica to plot a system of equations: Plot[{y = 2 x - 3, y = x/2}, {x, -5, 5}, Axes -> True, AxesLabel -> {"x", "y"}, PlotLabels -> {"2x-y=3", "...
• 377
29 views

### Set keeps RHS unevaluated when RHS is a Module variable [duplicate]

Consider the simple code ...
• 1,164
59 views

### Assign different type of balls into output containers with constraints

The problem is to asssign all differend kind inputs to outputs. For example colored balls. On the input we can receive max 5 different type of colored balls any with amount. The amounts for the inputs ...
1 vote
40 views

### Delay evaluation of Chop until its argument has no symbols? (== has this behavior, Chop does not)

With Equal (==), if a and b are undefined symbols, a==b does not evaluate. This way we can ...
• 578
1 vote
179 views

### several actions inside If condition [closed]

Trying to write code with If, if it is correct to perform a number of actions. I am a beginner user in mathematica and not sure the form of writing are correct. What I'm asking in simple, this is the ...
• 317
93 views

### Error message not reproduced at reevaluation, SetDelayed cache?

Mathematica v13.0: nr:=HoldForm@Evaluate@Function[t,x@t][] then evaluate ...
423 views

### Defining a function iteratively without Mathematica getting stuck in a recursion loop

I have the following code: ...
• 656
1 vote
45 views

### How can I access to the needed part of this expression? [duplicate]

I have defined a list like this: F[1][t] = ConstantArray[a1, 10] Now I want to assign to some of the elements the value 1; I ...
• 6,767
55 views

### Program works, but then fails when I write it inside Module [duplicate]

I'm new to Wolfram Language; I'm trying to get used to it by writing a bunch of code and programs, being one of them the algorithm for the bisection method. When I write the algorithm outside of a ...
157 views

### How to make c[n_, x_, y_] := ToExpression["p" <> ToString[n]] = {x, y} work?

I am trying to do the following: c[n_, x_, y_] := ToExpression["p" <> ToString[n]] = {x, y} That is: Evaluating ...
• 5,441
156 views

### Forcing mathematica not to substitute some terms in an expression

I have an expression c which should be defined before the function and a function f defined as follows: ...
• 420
1 vote
181 views

### Extracting expressions from LHS of an assignment

I need to list all variables in a notebook containing several Set assignments, lhs=rhs, and equations, ...
• 435
93 views

### NIntegrate seems to not recognize multiplication of Piecewise function and f[t_]:= function, Why?

Considering inputs: vti={0, 1.5, 2.4, 5.0675, 7.735, 10}; Vscc=1.5; PSA=0.025; f=0.6; m=10; I defined a function "pwtemp2", using "FC1" and &...
121 views

### Can't create matrix function of symbolic functions and assign values to elements

So I have a problem regarding the symbolic matrix value assignment. Say I create a matrix function as: P[t_]:= {{P1[t]}, {P2[t]}, {P3[t]}}; Then I want to assign ...
55 views

### How to use Mathematica to return value from for-loop [duplicate]

I tried to use Mathematica to implement random generator. The pseudo code I use is as following: ...
• 47
96 views

### any way to store the values of the controls of a Manipulate so that one can reuse them in the future excutions

I’m using Manipulate[] to adjust several parameters, which will eventually generate some figures. After I get the desired view, I’d like to store the set of control parameters so that I can reuse them ...
• 735
57 views

### Block Behavior, but for Function Assignment instead of Variable Assignment

We can define a function using a variable b that does not appear as an argument, and then using Block, change the output of the ...
• 1,627