# Tagged Questions

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

96 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 ...
76 views

### Select a Placeholder in a Notebook?

How might I select the 1st Placeholder in a Notebook? SelectionMove Has no option. ...
73 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 ...
60 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 ...
417 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 ...
97 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$, ...
34 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] ...
199 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.: ...
157 views

### How to ReplaceAll independent of depth?

I have a big list which in principle can be described as this more compact list : ...
98 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 ...
2k 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 ...
230 views

### Replace all symbols in a matrix with their numbered forms

I have a matrix made mostly from "x" with a few 0's thrown in: ...
109 views

85 views

### Pattern evaluation in nested function call

I'll put the question right here, but will add some context below in case someone wonders why the heck I'm trying to do this. Why is it that I have to do two passes to get the value of the arguments ...
122 views

### Matrix/tensor addition behaving funny under replacement?

I have two matrices I want to add, and one of the matrices is a tensor product of two vectors. I've used a SetDelayed to define the summed matrix, because I want to evaluate it for different values of ...
122 views

### ReplaceAll performance problem: packed arrays on the LHS are unpacked when the RHS is too long

The following is one of the most mysterious performance problems I encountered and came up while extending the booleval function mentioned here. I am looking for a ...
181 views

### Replacing High Densities of 1.s in Very Large Binary Arrays

I am working with very large binary arrays on the order of {100,100000}. It may look something like this. ...
133 views

### Replacing Patterns In a List of Varying Length

I am working with an array of data that may look something like this. ...