# Tagged Questions

Questions about Mathematica's rule-based replacement functionality, including functions such as Rule (->), Replace, ReplaceAll (/.) and ReplaceRepeated (//.).

41 views

### Replacing variable names in a notebook

I am working on a code that simply imports and graphs a function. If I preset the directory I would have something that looks like this: ...
171 views

### Change last column of a matrix

Given a (rectangular) matrix of integers, i.e. RandomInteger[4, {10, 3}] I want to apply the following rules only to the last column ...
41 views

### How to do replacements in Compile'd code? [duplicate]

I want to do something in the spirit of this code: ...
327 views

### How to replace the first occurance in an expression instead of replacing all?

Is there a function that replaces the first occurance of the expression instead of replacing all? For example, if I have HoldForm[x + 2 + 4 + x] /. x -> 4, is ...
944 views

### How to assign a list of numbers into letter grades

Here is my list: ...
227 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 ...
93 views

### Function returned an unexpected list

I was trying out a question in Wellin's Programming with Mathematica that says the following. Question: Given a set of points in the plane (or 3-space), find the maximum distance between any pair of ...
61 views

### Select a Placeholder in a Notebook?

How might I select the 1st Placeholder in a Notebook? SelectionMove Has no option. ...
69 views

### Add to the last digit a number

I have data from a Multimeter that has a precision of 0.6%rdg+4dgt. So i want to take the last digit of, say, 12.007 and add 4 to the last digit like ...
57 views

### Speeding up ReplaceRepeated while truncating to desired order

I need to program in an algorithm that recursively makes algebraic replacements which leads to an utterly complicated algebraic function of $x$, but whose final result is only needed at fixed order in ...
241 views

### Transformation of Derivatives under change of coordinates [duplicate]

I have an expression depending on the two variables z and t, and the derivative of a known function $f(t,z)$. Something like: $$myexp \ =\ t\ z\ \partial_z\ f(t,z)$$ Now I want to make a change of ...
86 views

### Using one complicated equation to reduce another

(Relative noob here so don't assume much!) I need to use a vector equation (with $N-1$ entries) in the general form $y_j(x_{i,j},x_{i,j+1},x_{i,j-1})=0, i=1...3, j=1...N-1; x_{i,0}=x_{i,N}=0$, ...
31 views

### How to prevent function from substituting the part of the parameter name if it has a subscript? [duplicate]

I have the following problem, when defining and using a function, that's supposed to have an outside parameter xmin: A[x_] := Exp[-x/Subscript[x, min]] A[5] ...
193 views

### How can I make a “self-referential” replacement operation self-contained?

Fairly often I find use for replacement rules that call themselves on the right-hand side of the rule, e.g.: ...
148 views

### How to ReplaceAll independent of depth?

I have a big list which in principle can be described as this more compact list : ...
84 views

### Unexpected behavior of rule-replacing with string concatenation [closed]

Here's the code. Clear[x,y,z]; {x,y,z} /. x_ :> ("^_^" <> ToString[x]) I get the result ^_^{x, y, z}, which is not ...
84 views

### How can I write a function which takes another function of a variable and the variable itself as arguments and gives a list of critical points?

This is an exercise from Power Programming with Mathematica by Wagner. I need a function which takes a function and a variable as arguments, like this: critpts[f_,x_]:= and then on the rhs I've got ...
1k views

### How to change element color in Periodic Table?

The command ColorData["Atoms", "Panel"] generates a periodic table. As I don't want to reinvent the wheel, I asked myself how to change the color of each cell ...