Questions tagged [assignment]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
19 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 ...
Kvothe's user avatar
  • 4,419
0 votes
1 answer
46 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 ...
blahblah's user avatar
1 vote
2 answers
48 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 ...
Giovanni Russo's user avatar
0 votes
0 answers
38 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 ...
holibut's user avatar
0 votes
0 answers
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: <...
user68119's user avatar
0 votes
2 answers
75 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 <...
Adriana LE's user avatar
0 votes
1 answer
57 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 ...
Amin Gholizad's user avatar
1 vote
2 answers
105 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 ...
John Taylor's user avatar
  • 5,703
3 votes
1 answer
134 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 ...
John Taylor's user avatar
  • 5,703
-2 votes
1 answer
158 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?
csn899's user avatar
  • 4,001
2 votes
3 answers
109 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 ...
sg1234's user avatar
  • 289
1 vote
3 answers
231 views

How can I permute two delayed variables?

Two variables with delayed expression are used for a random number generation: ...
Konstantin's user avatar
1 vote
2 answers
151 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 ...
Mam Mam's user avatar
  • 1,853
3 votes
2 answers
205 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 ...
Benigno's user avatar
  • 31
0 votes
3 answers
117 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", ...
Granger Obliviate's user avatar
1 vote
0 answers
35 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'...
Travis Bemrose's user avatar
0 votes
0 answers
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 ...
Richard Burke-Ward's user avatar
1 vote
1 answer
33 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 ...
Bruce Bartlett's user avatar
2 votes
1 answer
62 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 ...
Po1ynomial's user avatar
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
1 answer
66 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 ...
thomasweichhart's user avatar
3 votes
4 answers
464 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 ...
ions me's user avatar
  • 881
2 votes
1 answer
289 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: ...
Victor Nielsen's user avatar
1 vote
0 answers
89 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
0 votes
0 answers
35 views

ToExpression in nested Set/SetDelayed

Suppose we have the following definitions. ...
Math Gaudium's user avatar
1 vote
1 answer
47 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: ...
Oleh's user avatar
  • 81
0 votes
1 answer
59 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 ...
Evangeline A. K. McDowell's user avatar
3 votes
1 answer
111 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 ...
Neo's user avatar
  • 163
1 vote
0 answers
47 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", "...
1689vantil's user avatar
0 votes
0 answers
29 views

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

Consider the simple code ...
lineage's user avatar
  • 1,144
0 votes
0 answers
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 ...
Kombye's user avatar
  • 1
1 vote
1 answer
39 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 ...
Lucas Mumbo's user avatar
1 vote
0 answers
128 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 ...
erez's user avatar
  • 317
6 votes
2 answers
93 views

Error message not reproduced at reevaluation, SetDelayed cache?

Mathematica v13.0: nr:=HoldForm@Evaluate@Function[t,x@t][] then evaluate ...
Pierre ALBARÈDE's user avatar
3 votes
4 answers
401 views

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

I have the following code: ...
Rain's user avatar
  • 636
1 vote
0 answers
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 ...
mattiav27's user avatar
  • 6,687
0 votes
1 answer
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 ...
Daniel Bonilla Jaramillo Haase's user avatar
3 votes
2 answers
153 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 ...
Red Banana's user avatar
  • 5,329
0 votes
1 answer
133 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: ...
Alex97's user avatar
  • 410
1 vote
0 answers
153 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, ...
Robert's user avatar
  • 435
0 votes
1 answer
91 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 &...
drexalves's user avatar
0 votes
0 answers
117 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 ...
Nikolaos Petropoulos's user avatar
0 votes
0 answers
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: ...
Dan's user avatar
  • 47
0 votes
1 answer
78 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 ...
larry's user avatar
  • 725
0 votes
0 answers
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 ...
Just Some Old Man's user avatar
2 votes
1 answer
291 views

Cannot assign variable value inside Do Loop

This is more of a conceptual problem. Suppose I have three lists. x1 = {1, 2, 9, 10}; x2 = {5, 6, 7}; x3 = {9, 10, 13}; Now, I wish to keep only the first two ...
Epsilon's user avatar
  • 1,122
0 votes
1 answer
78 views

Avoiding For loops to perform an assignment to a variable with indices of user-choice [duplicate]

I am looking for an efficient way to perform the following operation without For loops ...
Saurabh Maiti's user avatar
0 votes
0 answers
55 views

Going between assignment rules and functions

I am trying to develop a model using Mathematica, and continuously run into difficulties going between the outputs of various functions (Solve, Differentiate, etc.) and back to functions (in the ...
P_sam's user avatar
  • 3
4 votes
2 answers
134 views

Assignment with Span to Indexed Variable

If I use span to assign a value to every element in a "column", it miraculously works: ...
Nicholas G's user avatar
  • 1,981
5 votes
4 answers
596 views

How can I list the common elements of two lists?

The elements of both lists are given as A={9,5,9,3}, B={9,9,5,5} In this case, how can I list the list {9,5,9} of the common elements of the two lists? (The order does not matter.)
Milk's user avatar
  • 1,688

1
2 3 4 5 6