For questions relating to assignments to symbols, patterns, or expressions.
0
votes
0answers
24 views
Parallelize with assignment in table
I just realized that you can use multiple Kernals in Mathematica and was trying to embed it in my program. But i encountered a strange behavior with an assignment in a Table.
What i used to do was ...
5
votes
1answer
98 views
Assign variables automatically to a function
Lets consider that I've this function:
fn = a*x^2 + b*x + c;
The idea here is to assign automatically the variables a, ...
4
votes
2answers
147 views
How to replace a variable that was assigned a value before
Question
How to make the replacement $f[x] \to f[y]$ for an abitrary function $f$ if $x$ was assigned a value before?
Example 1
How can I make the replacement $x +1 \to y + 1$ if I have assigned ...
0
votes
0answers
12 views
How to assign values to a function at discrete points? [duplicate]
Suppose we are interested in a function f[x] that is defined only at discrete points:
x = {1.1, 2.1, 3.1, 4.1, 5.1}
We want to ...
8
votes
1answer
115 views
Different behaviours of Default Argument
I don't really understand the behaviour of Default Argument. If I execute this command in Mathematica:
In: {f[a], f[a + b]} /. f[x_ + y_.] -> p[x, y]
...
1
vote
1answer
99 views
direct assignment to the element in a Table
I have already asked a related question here why set values in this way doesn't work?
But I think I have to write the question which I encountered explicitly?
...
4
votes
2answers
146 views
why set values in this way doesn't work?
question is as follows
define a list
ttt={1,2};
and if I set values in this way
{ttt[[1]],ttt[[2]]}={3,4}
then the value ...
0
votes
1answer
58 views
How to work with Interpolated Functions? [closed]
I am just a beginner and struggeling with experimental data and further processing in Mathematica:
I first constructed a table from two columns (t20 and J20) in Excel:
...
11
votes
2answers
186 views
Triggering actions when a variable is set
Some built-in variables trigger actions when their values are changed:
...
3
votes
3answers
94 views
Can I put subscripted parameter values into a package?
When defining packages, can I put parameter values alone or along with functions into a package in subscripted form?
...
1
vote
1answer
75 views
Using With in combination with Graphics [duplicate]
Assume that we are given a symbol p={x,y} which should represent a 2D point. If x and y have ...
1
vote
2answers
107 views
How to mix Unevaluated property of function arguments with expression assignments?
This is a follow-up to my (solved) question How to distribute a generic function of two arguments (without evaluating the arguments)
Say, I have a binary function
...
13
votes
2answers
224 views
How to make use of NumericQ[x] = True (and use it safely)?
Basic Issue:
I'm trying to understand the proper use of NumericQ's "magical" capabilities. Please consider the examples below. Actual question and some links are ...
11
votes
2answers
175 views
Nested definition: How can I define a function with a passed-in expression?
Here's a simplified version of what I'm trying to do:
...
4
votes
2answers
260 views
How to store value in a For loop
I am using two For loops. When the inner loop finishes, I don't want to print but I want to store the result from the inner loop in some variable so that I can call ...
7
votes
1answer
149 views
8
votes
3answers
2k views
Assign the results from a Solve to variable(s)
I understand Mathematica can't assign the results of a Solve to the unknowns because there may be more than 1 solution. How can I assign the 4 values of following result to variables?
9
votes
2answers
254 views
Scoping in assigning a derivative
While answering another question, I stumbled upon a problem I cannot easily resolve.
To assign the derivative of a function to another function, typically one can do this with a ...
3
votes
1answer
110 views
Set promotes Rule to RuleDelayed?
In mentally building a model of how Mathematica works, I naively expected Set to create a Rule in a symbol's ...
10
votes
1answer
166 views
Does Set vs. SetDelayed have any effect after the definition was done?
I was always assuming that the only difference between Set (=) and SetDelayed (...
22
votes
1answer
410 views
How to augment the realm of functions Mathematica thinks it knows how to integrate symbolically
My question involves extending the functionality of Integrate over specific integrals in the most generic manner.
Specifically, is it possible to "hack into" ...
3
votes
1answer
76 views
Syntax Coloring for “Possible Unwanted Assignment” Issue
Apparently Mathematica's syntax coloring engine believes that the second assignment in the following code excerpt (concocted for illustration purposes only) is a "Possible Unwanted Assignment" since ...
7
votes
1answer
184 views
Assignment rule to distribute matrix-multiplication over custom notation
I'm trying to write some code to do basic algebraic manipulations in BraKet notation.
Thus far I have a function KetToVec which will convert any expression of the form a1 Ket[s1]+ b Ket[s2] +... to a ...
5
votes
3answers
591 views
Assigning values to a list of variable names
As part of a calculation I need to do something like this
Evaluate[{aaa, bbb, ccc}[[ index]]] = {1, 2, 3, 4, 5}
so if index is ...
5
votes
3answers
232 views
Delayed evaluation of assignment
I have a set of PDE's that depend on parameters. They depend on many parameters, but for simplicity we can here assume that they depend only on one, say a.
I want ...
17
votes
4answers
218 views
Setting parts of a list
Suppose I have list
a = Range[10]
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
in which I want to set some elements to be a list
...
11
votes
3answers
170 views
MapThread gives different results from ToExpression when trying to assign variables from a list
I have the following data set:
data = {{"Jakarta","Surabaya","Bandung"},{1,2,3}}
and I'd actually like to assign the numerical values to the categorical data so ...
15
votes
5answers
678 views
How to pass a symbol name to a function with any of the Hold attributes?
Given a function with the attribute HoldFirst, HoldAll or similar, and a variable, list, how ...
10
votes
3answers
267 views
Why does ++++x return an increment of 2 when the value of x is only incremented by 1?
This line returns 3:
x = 1; ++++x
However, the value of x after the increment is only ...
8
votes
3answers
219 views
How to write a function-defining function which stores the function arguments in a stack?
I have a function-defining function
SetAttributes[DefFn, HoldAll];
DefFn[f_[args___], body_] :=
f[args] := body;
I am trying to modify this function to record ...
13
votes
1answer
199 views
How to make a function like Set, but with a Block construct for the pattern names
How can we define a function that works like f[x_]=ComputeSomething[x] and treats x as a variable that does not have a value? ...
1
vote
1answer
138 views
Differentiation w/o assiging concrete values
v = Subscript[v, 0]*Sin[(Pi*S)/Subscript[S, 0]];
a = dv/ds v;
a = D[v, s]
returns
...
16
votes
1answer
354 views
How do you set attributes on SubValues?
SubValues, as discussed in a previous question, are declared as follows
...
16
votes
5answers
326 views
58
votes
2answers
2k views
What is the distinction between DownValues, UpValues, SubValues, and OwnValues?
When reading through the documentation, you often encounter the phrases DownValues, UpValues, ...
16
votes
4answers
493 views
How can I randomly generate a unique, unused symbol?
In a previous question on collecting terms for a multivariable polynomial, I answered with a solution that required a unused symbol to be used for a temporary substitution and back substitution.
It ...
15
votes
2answers
170 views
Clearing a specific definition
Consider the case where a symbol has multiple definitions attached to it,
a /: Subscript[a,2] := 1
a[b_] := 2
a[b_, c_] := 3
How does one clear (/unset/remove) ...



