517 views

Replace expression, but only "outside" of a function [duplicate]

I have a horrid expression, which is basically a sum of exponents with coefficients. Here's a taste: What I want to do is to replace ks with another expression, ...
• 6,976
1 vote
33 views

Substituting variables in only certain environments? [duplicate]

I was integrating a function and got something essentially like E^(mu beta) * (1/beta) There beta is defined as ...
• 289
2k views

How to perform a depth-first preorder traversal of an expression?

Mathematica provides functions that perform a depth-first postorder traversal, or which use such a traversal, including: Scan, ...
• 264k
2k views

ReplaceAll is not working correctly

The line of code -E^(-I k) x /. {-x -> -x, -E^(-I k) x -> -E^(I k) x} is not properly replacing the exponential of (-I k) with the exponential of (I k), as ...
• 1,724
447 views

Pattern to match L, but not L[_]

I have an expression where I want to replace L but not L[_] For example, the following doesn't work and ...
• 947
768 views

Why does {2, 9, 3, 16, 81, 0.09} //. {x_Integer -> Sqrt[x]} evaluate infinite times? [closed]

Here is my code. {2, 9, 3, 16, 81, 0.09} //. {x_Integer -> Sqrt[x]} The pop-up message ReplaceRepeated::rrlim suggests ...
• 1,601
247 views

How to define a Rule to match a Head except if it is a Part of another?

I have an expr which has List at various levels and I want to display them nicely as a column inside a frame but my problem is ...
• 8,105
437 views

Replace x, but not x[a] [duplicate]

I want to replace all occurences of the symbol x with x[a], as long as it is not in the form ...
• 753
631 views

Embedding StreamPlot in Graphics3D

I am trying to visualise the action of the infinitesimal generator of a Lie group on the solution of a 2-ODE system drawn in the 3D space (t,y1,y2): t is time and y1,y2 are the two dependent variables....
• 445
138 views

What is the potential usage of ReplaceAllUnheld in Developer Utilities Package?

There is a function ReplaceAllUnheld metioned in the doc Developer/ref/ReplaceAllUnheld. I am curious about what is the ...
• 15.6k