Tagged Questions

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

82 views

Replacing negative components of a matrix with zeros [closed]

How can I replace the negative components of a matrix with zeros?
54 views

Extract solutions of linear system to variables

I need to output the answers from solve into the variables named just as they were named in the solve equations. I have checked out this thread Assign the results from a Solve to variable(s) but ...
26 views

Possible incompatibility between ReplaceAll and LaplaceTransform

I have a large symbolic expression containing many terms of the form, LaplaceTransform[u2[z], z, s], with various functions for the first argument. I wish to ...
67 views

Replacing terms in a sum according to a condition

If I have a generic expression such as ...
32 views

How Can I combine the equations' results in a table without “x->” [closed]

For example: I have a series of functions: F[x_,o_]=x+o And I want to combine the result into a table with o=0.3,0.6,0.9.. ...
61 views

105 views

Condition and RuleDelayed

On this site I found, for example here, some very interesting questions and answers on the use of delayed rules with conditions. I would very much like to understand these answers, but so far I failed ...
121 views

Why is a longer pattern matched rather than a short pattern?

I was reading the Mathematica V5 Book and am a bit perplexed on the behavior of a particular pattern matching example where it seems to be choosing a longer pattern rather than a shorter pattern. The ...
25 views

Simplifying self-reciprocal rational function [duplicate]

I have trouble transforming self-reciprocal rational functions in one variable like ...
104 views

How can I pass replacement rules to a package-defined function and have it understand their context?

I am writing a package where I would like to be able to pass replacement rules to a function inside the package and have the function manipulate its symbols using those replacement rules. However, I'm ...
62 views

how to replace one calaculation result to another one in a loop?

I am doing the calculation in a loop. I gain a digit for rzin in ...
194 views

Executing: ...
49 views

How to substitude a^n->D[u[t,x],{x,n}] for n=0,1,2,

I have expression which have terms a, a^2, a^3, ..., How can I replace a^n -> D[u[t,x],{x,n}] for n=0,1,2,....
34 views

Replace variable with other variable containing a constant in differential expression [duplicate]

I have the following differential expression: ...
125 views

Symbolic differentiation [closed]

I have two symbolic differential equations and I want to used them in another equation as follows: ...
238 views

ReplaceAll with Associations instead of Rules

I have just noticed that x /. <|x -> 123|> evaluates to 123 In other words, the association seems to behave as a ...
91 views

Check an Option without Evaluation

Consider the following: ...
46 views

ReleaseHold NIntegrate after Replace variable

I would like to calculate the sum of square of two integral(Ex and Ey). I first hold this two integral because two variables(tx, ty) are not specified.Then, I replace tx,ty and releasehold $Ex^2+Ey^2$....
119 views

How to force a replacement in an order that I want?

This is a follow-up to this question. I have a big sum, with lots of terms of the form ...
59 views

How do I use Replace All? [duplicate]

I have an expression: a + b 2^(1/2) + (c + d 2^(1/2))*I I want to replace each occurrence of 2^(1/2) with ...
72 views

Replacement producing unexpected result

If I use a replacement rule like ...
34 views

TensorContract with KroneckerProduct instead of ordinary Times

Is it possible somehow to contract two tensors, say A={{a1,a2,a3},{a4,a5,a6}} and B={b1,b2,b3}, where the elements ...
176 views

What kind of patterns in a list of rules would benefit from being Dispatched?

I have a long list of rules for manipulating expressions. They are of the form: ...
121 views

Function not returning number [closed]

I am quite new to Mathematica and I guess this question is really basic, but I can't figure it out myself. I'm making a simple notebook that plots a Hamiltonian function, a plane of constant energy, ...
682 views

How to replace a space by a comma

in this expression = "{1 2 3 4 5 6 7 8}", I want to replace each space by a comma , to get ...
60 views

Can't operate on vector within a list of rules

I'm trying to set up a list of rules which includes the following: ...
When I have a complicated expression that depends on some variable, say, $f$, the following usually works ok: Expression ./ { f-> x^2 } But if $f$ is a ...