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

learn more… | top users | synonyms (4)

2
votes
1answer
77 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 ...
0
votes
1answer
31 views

Using NDSolve initial conditions as parameters for a function and then a replacement rule

I am trying to make a function based on two initial conditions of a set of differential equations: ...
0
votes
1answer
59 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 ...
-2
votes
1answer
85 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] ...
2
votes
0answers
53 views

Optimization of recursive functions by using the //. operator

In some cases, recursion in Mathematica (without storing values) is not very efficient. For example, the recursive implementation of Fibonacci numbers (version which doesn't store the values) : ...
2
votes
0answers
117 views

Is this a bug in NCAlgebra library?

In course of my work with NCAlgebra package for Mathematica, http://math.ucsd.edu/~ncalg/ , I encountered unexpected behavior of replacements. I am using ...
2
votes
0answers
111 views

Generalization of a rule to N arguments

I am trying to apply a series expansion on a function x[t1,t2,...tn], with an expansion parameter a. For ...
1
vote
0answers
41 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 ...
1
vote
0answers
99 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
0answers
102 views

Speed up replacement using Rule Dispatch Associtation

I knew that this has asked many times, but I hope there is something more could be done to speed this up. The expression kappa is here. ...
1
vote
0answers
45 views

Question on Function in Replacement Operation

I am trying to create a replacement function which, depending on the input, gives an additional minus. In my example I have an undefined function a with two ...
1
vote
0answers
132 views

Replace part in a matrix that matches specific pattern

I have the following problem. Given a matrix L which looks as follows, Matrix L is a link, route matrix. Further, I got the following vector (d), which indicates the demand per vertex combination. ...
1
vote
0answers
54 views

Hashing by Equals instead of SameQ

I have some numerical code involving complex numbers representing points on a plane. Some of these are equal but not identical, ie ...
1
vote
0answers
44 views

How to apply an rule to factors matching a certain form

Suppose we have many expressions involving irrational ArcTan expressions (such as ArcTan[Sqrt[3],5]) along with other irrational factors (such as ...
1
vote
0answers
78 views

How to simplify expressions

I read several similar posts but I have not found a solution yet. However, I think that my problem should be quite easy. So here we are. Relations ...
1
vote
0answers
186 views

Variable scope in nested NMaximize, NMaxValue

I'm trying to use NMaxValue inside other statements (FindRoot and NMinimize). Those statements should bind variable names, but I'm getting weird warnings which seem to indicate that the variables ...
0
votes
0answers
67 views

Replacing function in Sum

I have this expression, which, after execution, gives these $F[s,r]$ in output. $$ S_{1,1}=\sum _{s=1}^{16} \sum _{r=1}^{16} F(s,r) \text{Tr}\left[G_r.G_1.G_s.G_1\right] $$ Here is a piece of ...
0
votes
0answers
37 views

Mathematical symbol and name for Symbolic Replacement

(Originally from math.SE, but might be better here) I'm searching for a mathematical symbol, that describes the symbolic replacement done for instance in Mathematica: ...
0
votes
0answers
67 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
0answers
55 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
33 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
0answers
122 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
0answers
67 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. ...
0
votes
0answers
126 views

Writing rules for Einstein summation

I'm trying to write a list of rules for tensor manipulations and in particular, Einstein summation convention. What I've tried, so far is to write something that would take a generic functions with ...
0
votes
0answers
57 views

How to solve ReplaceAll problem inside Manipulate

I'm running into some trouble when I try and use Manipulate (code included below). Instead of letting me manipulate the plot, I get an empty plot and this: ReplaceAll::reps: ...
0
votes
0answers
37 views

How can I replace an expression by another

I'm trying to replace a expression like this: (s[e,f] - I*phi[e,f]) -> M[e,f] Can anyone help me?
0
votes
0answers
47 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: ...
0
votes
0answers
92 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$, ...
0
votes
0answers
129 views

Back Linear Substitution

I have an equation set Ax=b and A(n*m),n<m . To lower down the dimension, I express some vars by other vars, which gives ...
0
votes
0answers
187 views

Alternate method of conjugation using replaceall

Mathematica really struggles to simplify complex conjugates of complicated expressions - even given assumptions for every symbol in the expression being real. Often times I've found that I can ...
0
votes
0answers
59 views

How to make this particular replacement involving exp

I apologize if similar questions have already been asked, but I have some difficulties with replacements in Mathematica and I would like to make a substitution like ...