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

learn more… | top users | synonyms (4)

0
votes
0answers
53 views

Creating a lazy evaluator of the lambda calculus

I have a sub project in my research to write a lazy evaluator of the lambda calculus. How should I approach this problem? I already have a implementation of the lambda calculus in another language. ...
1
vote
1answer
36 views

Mathematica does not replace \[ImaginaryI] inside Hold

Mathematica 10.1 does not replace I (i.e. \[ImaginaryI], the square root of -1) inside functions with the Hold attribute. Example: ...
0
votes
0answers
28 views

Replace instanced variables within module-return functions for dynamic Tooltip

Currently I am stuck with the issue of renaming an instanced variable like r1$38655 to a global one. The function is created within a "localizeAll" Module. Here's ...
1
vote
1answer
31 views

Replace symbols in output without evaluation

I found the Wolfram example for ExpandNCM but I want a more human-readable output form. I want to evaluate ExpandNCM, for example with ...
0
votes
0answers
62 views

Matrix iteration failing after second step

I am calculating 11x6 matrix using different logics as in below code. Problem is in Do loop in below code where I have two different criteria to update matrix "fd". I am expecting logic in IF which ...
0
votes
1answer
43 views

Replace element of matrix based on rule which invloves other element of same matrix

I am trying to replace 1s row of matrix d iteratively from right by multiplying last element in 1st row with (1-int*dt) to generate 2nd last element. The replacement continues till I reach the 1st ...
0
votes
0answers
49 views

How to replace a part of array based on certain rules which involves usage of other array

I am trying to replace outermost column of array "fd" in below code. fd is matrix of dimension (nas1,nts) which is initially filled with 1. I want to replace outermost column of fd with result of Max ...
0
votes
0answers
25 views

Convert the output of solve into equality [duplicate]

I know this is has been asked before but seriously, none of the ones I checked helped because they referred to a single variable assignation. Apologies if this is a duplicate. I have many variables ...
0
votes
0answers
27 views

Subtracting Series

When I input the following $\sum_{n=0}^{m+1}x[n]-\sum_{n=0}^{m}x[n]$ which in InputForm is: Sum[x[n], {n, 1, 1 + m}] - Sum[x[n], {n, 1, m}] it returns ...
0
votes
1answer
71 views

Replacement of terms/Pattern matching involving products of derivatives of a function

In delving into Ramanujan summation, I'm trying to get a hold of the relations of the form $$\sum_{n=0}^\infty f(n)=\dfrac{h\frac{d}{dx}}{{\mathrm{e}^{h\frac{d}{dx}}}-1}\int_{0}^\infty ...
0
votes
2answers
42 views

Different behaviour of Map and Inner in replace rules

Why does x[{1, 2}] /. {x[l_] -> Map[func, l]} {1, 2} not behave as expected, while for example ...
0
votes
2answers
48 views

How can I match some parts of an expression?

Suppose I have an expression like Abs[x+I y]+Sin[Abs [c+ I (d+e)]], and I want to replace all expressions in the form of ...
1
vote
3answers
126 views

How to do a Check for every element in the list?

I know how to do a Check for the list in general: ...
2
votes
4answers
199 views

How to switch from array to string?

Considering we have an array: a = {2/3, 4/5, 9/7, 3/7, 1/7, 1/9}; How can I get this to be: "2/3 4/5 9/7 3/7 1/7 1/9" ...
2
votes
1answer
45 views

Define (conditional) substitution rule for sum/difference of radicals

I want to tell Mathematica to simplify some expressions applying the following substitutions, conditioned on the fact that $a\geq 0,b \geq 0, a^2-b\geq0 $ $$ \sqrt{a+\sqrt{a^2-b}} \pm ...
3
votes
4answers
207 views
6
votes
4answers
288 views
1
vote
2answers
71 views
2
votes
3answers
110 views

How to delete a pattern from String?

Having a string like : "{Aaaa -> a, Bbbb- > b, Cccc -> , Ddddd -> c, Eeeee -> , Fffff -> e}" I want to delete the parts that contain ...
3
votes
1answer
97 views

How can I solve my easy system of equations?

I am new to Mathematica and am afraid this is a silly question. I have this very easy substitution, it has three equations on three unknowns {w1, l1, t1}. I want to ...
0
votes
1answer
42 views

How to manipulate string parts?

Let's consider I have following string: "{a-> POR, b-> D610, c-> 0, d-> \"300/7\", e -> \"1/400\"}" How can I run over and update anything that is ...
0
votes
3answers
71 views

How to iterate through a list of rules?

Let's consider I have a list of rules: {Aa -> 1/2, Av -> 2/5, Bx -> 3/7, Ce -> 4/9, ...} I want to find all keys that contain the letter "A" and ...
1
vote
1answer
24 views

Replace Coefficients of multivariate expressions by numbered constants

I have an expression which is a polynomial in Delta, xi and phi. The prefactors are huge ...
1
vote
1answer
46 views

Applying functions repeatedly on parts of complicated expressions

I am dealing with expressions like $$ \textrm{expr}=5D_{4,1}\langle12\rangle\langle23\rangle\big(-\langle15\rangle^2\langle24\rangle\langle34\rangle + ...
0
votes
1answer
23 views

How to apply substitution when expression contains powers of the quanity

An expression like: a = TrigToExp[ 3 + 4 Cos[u] + Cos[ 2 u]] produces a list of exponential factors: 3 + 2 E^(-I u) + 2 E^(I u) + 1/2 E^(-2 I u) + 1/2 E^(2 ...
7
votes
4answers
436 views

Strange answer from StringReplace

I have a list of strings and I would check if there is an empty string element, that's "", because I need to replace it with a "0". I try the following ...
1
vote
2answers
50 views

Problem with Replace function [closed]

I recently started using Mathematica. I'm not able to understand my mistake. I'm trying to implement the Frangi vesselness for the enanchement of vessels in biomedical images. I wrote these functions: ...
1
vote
0answers
38 views

Substitution does not work while substituting with a value from list

I am writing a program which iteratively solve and make substitution from a list. As I have shown in the code substitution works when I enter the value directly (Input 100). When I extract the same ...
7
votes
2answers
95 views

Why does ToRules return a Sequence?

Why does ToRules return a Sequence expression? Why doesn't it return directly what ...
3
votes
2answers
151 views

How to rewrite the rules in a list when they satisfy a given condition

I think the best way to state my problem is to illustrate it with an example. Assume I have the following toy-list of rules: ...
0
votes
2answers
56 views

For the same function, why does /. give a complex result?

I define a very simple function like this, g[k_] := 1. + 2 Sum[1/(1 + (2 n)^2), {n, 1, k}] g[50] give the result is: 1.70279. But g[n] /. n -> 50 give aother result: ...
12
votes
1answer
317 views

Is everything in Mathematica ultimately stored as a rule?

My current understanding about Mathematica is that everything, at the lowest level, ends up as replacement rules. First question: is this true? Second question: does Mathematica "gloss over" these ...
4
votes
3answers
157 views

Replace elements in matrix to make it symmetric using automated procedure

I am generating a matrix using (mat2 = Array[Subscript[a, ##] &, {4, 4}]) // MatrixForm but would like to force Mathematica to make it symmetric. Thereby I ...
2
votes
1answer
138 views

Replacing powers of $n$-th partial sums in the output of a function with $S[i]$ for $i = 1,\ldots,n$

I've written some simple code that, for various $N \geq 1$ and $k = 1,\ldots,N+1$ computes the $n$-th derivative of $\log S_N$ where $S_N(z) = \sum_{k=0}^N \frac{1}{k!}z^k$ as follows: ...
4
votes
2answers
134 views

Trying to get Arg[1 + I a] -> ArcTan[a]

Can Mathematica evaluate Arg[1+ I a] when a is a positive real in order to get ArcTan[a]? ...
0
votes
1answer
30 views

Force ReplaceAll to output vector of same length

I would like to do a replace in an expression... a = t; b = 1; a/.t->Range[1,5] (*returns: {1,2,3,4,5} *) b/.t->Range[1,5] (*returns: 1 *) but I ...
-2
votes
1answer
68 views

Transform differential equation to get equilibrium position

I would like to determine the equation in the equilibrium position. eq = 1/2 g l m Cos[θ[t]] == J (θ^′′)[t] ...
1
vote
2answers
107 views

How to select elements from a list by condition?

Considering I have a list: F = {f1, f2, f3, f4} I want to perform exponent on the list F = Power[#, 2]& /@ F Now I ...
0
votes
2answers
43 views

FilterRules with pattern for name [duplicate]

I have a list of rules and I want to filter it using a pattern for the initial string representing the name of the rule. So that in the example below it filters linearBool even if it is called ...
0
votes
1answer
51 views

How to speed up ReplaceAll in Table?

I am writing a code which solve a list of equations and then create a Table with resulst of equation solving. In applications where I use this code, I create a bunch of equations and my computations ...
0
votes
1answer
47 views

EdgeRenderingFunction For 2 Vertices in a Loop

Assume there is a set of rules: set = {"A" -> "B", "B" -> "A", "B" -> "C", "C" -> "D", "D" -> "A", "C" -> "C"}; which we want to graph using ...
1
vote
1answer
44 views
0
votes
0answers
105 views

A faster way to replace variables than ReplaceAll

I noticed that for large matrix, the rule /. is very slow. In the example below, the combination of memorization and the replacement "/.sol[n-1]" inside the definition of sol[n] turns the code ...
0
votes
1answer
73 views

Variable change

If I have the following Hamiltonian: ...
0
votes
1answer
43 views

Use of Replace function [closed]

I would like to replace in an expression two functions x[t] and D[x[t],t] by two variables x ...
0
votes
2answers
35 views

ReplaceAll with serveral variables. get all combinations

How can achieve something like this? a * b /. {a -> {1, 2, 3}, b -> {10, 100}} I want {10,100,20,200,30,300} or ...
9
votes
1answer
273 views

How can I replace the Greek symbols in an expression with their plain text names?

Suppose I have an expression with Greek symbols in it. How would I convert that expression to another expression where the Greek symbols have been replaces with their names in plain text? I've ...
0
votes
0answers
68 views

Replace Part of a matrix

I have to generate a ne numbers of matrices with 1 and 0 and then replace some elements. ...
1
vote
1answer
53 views

Don't understand why my Taylor expansion results in a message and an unexpected result

Trying to do something simple: Taylor expand a generic function of t around a point t and substitute ...