# Tagged Questions

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

118 views

### Maximum number of literal values for SetDelayed?

Under what circumstances should I expect Mathematica to turn a delayed assignment into an immediate assignment? I have put together a minimal example (available here) which demonstrates this behavior. ...
280 views

### Is there a way to simplify a symbolic expression at assignment, once-for-all?

I have a series of symbolic function calls that could be greatly simplified using some assumptions. I think I would like for these assumptions to be used in the definition of the function so that they ...
39 views

### Out[x] not the same as assigned expression [duplicate]

There seems to be a difference in the way Mathematica assigns a value to a variable and the way it assigns a value to the next Out object. I don't understand why this is happening. For instance, take ...
79 views

### Is it possible to assign a value where the target is itself a variable

If I have a variable x := "a". Is there a way I can use it to assign a value to a, by just referring to ...
97 views

### Problem with Simplify, Sqrt, and Set: What's going on?

I am having some trouble getting Mathematica to simplify an expression of the form Sqrt[x]*Sqrt[1/x], where x>0. The problem is that x is assigned to some complicated form by the time Mathematica ...
24 views

### Assign to variables inside Array, rather than changing array entries [duplicate]

I am generating an Array with symbolic coefficients: coefficients = Array[c, 3] > {c[1], c[2], c[3]} I would like to assign a value to each of these generated ...
121 views

### Why is it not allowed to define vectors of variables in a scoping construct?

The following command assigns 1 to a, 2 to b and 3 to c: ...
70 views

### How to assign the values for the Table list?

Now, I want to assign some values for a Table list and I find that If {mat[1], mat[2], mat[3], mat[4], mat[5]}={4,23,3,12,1}; it is no problem. But, if we use ...
688 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 ...
95 views

### Simultaneous use of Set AND SetDelayed

Tha Mathematica documentation gives a good example of the simultaneous use of Set and SetDelayed in dynamic programming for the Fibonacci sequence under "neat examples" for SetDelayed ...
64 views

### Refercing generic derivatives

I have a list of rules to the values of the derivatives of a generic (real valued, 3 variables) function, for example: df/dxdydz(0,0,0)-> 0.7. I would like to be able to generically reference this ...
643 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 (...
342 views

### Altering values in Manipulate with dynamically generated controls

I have a Manipulate whose controls are generated based on a parameter in a containing Manipulate: ...
90 views

### Assigning to the “local” version of a symbol

Compare Manipulate[c[1] = 1; c[1], {c[1], 0, 1}] with Manipulate[Do[c[i] = 1, {i, 1}]; c[1], {c[1], 0, 1}] The first case ...
138 views

### DownValue assignment using Apply

Why does assigning a DownValue using Apply, e.g., ...
525 views

### Is there any way to assign multiple values?

I am looking for something like "byref" assignment in programming languages. Let's assume I have: x1=x2=....=xn if I want to change their values ( say to 3 ) I need to set all of them like: ...
633 views

### Modifying parameters: Set::setps in the part assignment is not a symbol [duplicate]

Ok, this will probably be a silly question, but I can't get my head around it. I'm making a simple module that, given a list and two integers, will swap the position of the elements in the list.(...
2k views

### Assign output of solve to variables [duplicate]

I have this input: Solve[x^2 + 3 x + 2 == 0, x] which gives this output: {{x -> -2}, {x -> -1}} I want the first x ...
218 views

### Trouble to assign solution of differential equation to a function

I have written a function to Solve the following differential equation where the number n (called in my code Nphoton) is a variable. Nevertheless I have troubles to assign the solutions ...
49 views

### How do I assign a formula to a variab [duplicate]

I want to compute equations and assign them to variable. This is a wxMaxima program that calculated symbolic PID gains for an integrating first order system ...
73 views

### How to get Symbol[“x”]=3 to work [duplicate]

This is probably a really simple one, but I'm stumped. I want Symbol["x"]=3 to work just like x=3. However I can't figure out ...
96 views

### Edit built in symbol

I would like to add new attributes to built in symbols (e.g. ElementData or PolyhedraData) so that I can still call the symbol ...
370 views

### Implementing key-value associations in Mathematica 9 with inexact numbers for keys

I'm not sure of what type of problem my issue falls into, so I haven't been able to search forums with any success. If this has already been solved then my apologies! Essentially I'm trying to set a ...
322 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 <...
2k views

### How to implement the Observer design pattern?

As a programmer with a history with procedural languages, the Observer design pattern inmediately springs to my mind when attacking certain class of problems, mostly UI/notifications related. A two-...
530 views

### How to copy a function by value?

I need to change a function symbol multiple times by assigning another symbol to it, but when I'm trying to do that the symbols overwrite each other. I'm assuming this is because the assignment is by ...
150 views

### Evaluating an expression assuming a value for a variable only in the local context

Imagine we wish to evaluate some expression like NIntegrate[x^2*q,{x,0,100}] assuming some value for q like ...
84 views

### Questions regarding DictionaryLookup of Mathematica

a. Make a function longest[lang_] that gives the length of the longest word in the dictionary of lang. You should get ...
162 views

### Few quick Mathematica questions about Dictionary

a. Get the list whose elements are of the form {language,number of words in dictionary) I tried this, and it gave me the number if words in dictionary, but I don't know how to get the language part: ...
62 views

### Set-generating macro unexpectedly reaches recursion limit

One moment I decided to assign symbolic names to all special spaces since they all look the same when put literally in FrontEnd editor, more or less like "" or <...
39 views

### How to assign a list of subsript?

I want to assign Subscript[C,i] by mapping a specific list. For example, the list is {1,2,3,4}, and I want to assign 1 to C1, 2 to C2, 3 to C3 and 4 to C4. How should I do? Many thanks:)
168 views

### Bare symbol invocation fails but not if used with an argument

How to achieve the following behavior on a symbol f? Background: The main goal is to use the symbol to tag an abstract data structure where downvalues are used to store information. Only defined ...
163 views

### Unset while running recursion

I am trying to run a recursive definition while at the same time clearing previously found values, so my memory is not completely consumed. I found this: How to clear parts of a memoized function? ...
95 views

### Circumventing the default scoping: Assign a variable inside a function [duplicate]

I'm currently trying very hard to assign a variable inside a function. Therefore I'm using a function like this, which should reassign a predefined variable. ...
74 views

### Replacing multiple instances of a symbol with different variables and assignments

I have an expression of the form: expr=x+y+n+Sin[n]+n^2 I would like to replace each of the variables n with a different ...
190 views

### Associate the elements of a table

I have a table form as: table = {{a, 6}, {b, ff}, {c, 2}} I want to associate the first element of each pair from the table to the second element of the pair as ...
72 views

### storing rescaled images in new variables

I'm trying to assign random image files that undergo rescaling to a list of variable names. The images I'm trying to assign are the result of mapping the ImageResize function of two arguments to the ...
144 views

### Automatically assign solutions to equation as constants

Consider the following code: ...
492 views

### Understanding Function and Variable in Mathematica for beginner [closed]

I'm reading the book of Leonid Shifrin, and I love the way the book explains the core in Mathematica. As everything is an expression, now I understand that, there ...
140 views

### Using a variable to tell Mathematica which existing variable to manipulate

I have an estimation routine I have coded up, I want now to do some tests on it where I pick a particular parameter and run the estimation for differing values of that parameter. What I want is to be ...
235 views

### Assign variable's value programmatically [duplicate]

Not easy to explain what I'm looking for, so please sorry if I'm not so short. Having many variables to be managed in several different combinations, I need to automate the assignment of preset ...
152 views

### Assign one button to two variables

I am trying to use the one button to assign to two variables. Here is an example of how I want it to work. expression: ...
1k views

### Integral of Lorentzian yields different results depending on when parameter assigments are made

I'm evaluating the integral of a Lorentzian, which I know equals one. First I define the function and evaluate the integral in two slightly different ways. Surprisingly, I do not get the right answer ...
361 views

### Getting mesage: Set::setps assignment is not a symbol

Please, tell me what is the issue with the following code? Dimensions[Subscript[R, 2]] {201, 161, 53} ...
190 views

### Two quick Mathematica Questions about the dictionary

Question1: Get the list of pairs of the form {language,number of words in dictionary}. Call this list langlength What I did was this: ...
1k views

### Clear and Unset doesn't free memory

Example: Try this example only if you have > 4G ram d = 2000; f[x_, y_, d_] = Sum[Subscript[a, i, j]*x^i*y^j, {i, 0, d - 1}, {j, 0, d - i}]; Then ...
323 views

### How to ignore list elements when extracting with pattern matching

If I have a simple list, say {1, 2, 3}, and I want to extract a subset of the elements, what is the correct syntax? e.g. { i, _, j } = {1, 2, 3} I want i = 1 &...
76 views

### Extracting function variables from a list [duplicate]

Evaluating the following func[x_, y_] := x^2 + y^2 listn = {{a, b}, {c, d}, {e, f}}; Map[func[##] &, listn, {1}] yields {func[{a, b}], func[{c, d}], ...