Skip to main content

All Questions

106 votes
5 answers
6k views

Replacement inside held expression

I wish to make a replacement inside a held expression: f[x_Real] := x^2; Hold[{2., 3.}] /. n_Real :> f[n] The desired output is ...
Alexey Popkov's user avatar
18 votes
1 answer
607 views

Why is ReplaceAll behaving like this?

I'm learning to use the ReplaceAll function and I found the behavior of which is quite confusing. For Sqrt[f[x, y]] /. f[___] -> u Mathematica returns <...
user2256793's user avatar
17 votes
2 answers
952 views

Transform an expression into a graph that can be plotted with TreeGraph (not TreeForm)

I would like to plot an expression (like TreeForm does), but using the new TreeGraph functionality. ...
scaramouche's user avatar
6 votes
1 answer
681 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....
pdini's user avatar
  • 485
17 votes
1 answer
324 views

When is the righthand side of a RuleDelayed evaluated?

The documentation on RuleDelayed states that lhs :> rhs represents a rule that transforms lhs to rhs, evaluating rhs only after the rule is used. Consider the ...
Fred Simons's user avatar
  • 10.2k
10 votes
2 answers
1k views

What is the Difference Between Rule (->) and RuleDelayed (:>)?

I am new to Mathematica so this question may seem rudimentary. Sorry for that! :) I want to implement the well-known property of Kronecker's Delta $$\Sigma_{i=1}^{n} a_i \delta_{ij}=a_j,\quad 1 \le ...
Hosein Rahnama's user avatar
5 votes
4 answers
1k views

Replace every Minus to Plus in Expression

Thought this is a rather simple thing, but I was not able to find a solution. I have a polynomial expression like: ...
Mario Krenn's user avatar
  • 2,182
7 votes
2 answers
231 views

Efficient Search for specific Terms in symbolic Expression

I have a large symbolic expression with six variables a,b,c,d,e,f per term, roughly like this: ...
Mario Krenn's user avatar
  • 2,182
5 votes
5 answers
442 views

How to subtract these two equations?

There are two equations: eq1 = x1^2/a^2 + y1^2/b^2 == 1; eq2 = x2^2/a^2 + y2^2/b^2 == 1; How to get this result by subtracting two equations? the result ...
csn899's user avatar
  • 4,521
5 votes
1 answer
87 views

Substituting elements of lists into an expression

Suppose I have the following lists, as = {1, 2, 3, 4}; bs = {10, 20, 30, 40}; and the following expression: ...
Wiliam's user avatar
  • 3,096
5 votes
2 answers
306 views

Replace a randomly chosen part of an expression

Given an arbitrary Mathematica expression, how can I choose a random part of the expression and replace it with another symbol of my choosing? For example, given $a x^3 +2y\cos(x)- \tanh(x^{y+3})/(x^...
flinty's user avatar
  • 25.6k
3 votes
6 answers
301 views

Making strict replacements in Mathematica

My question is quite a simple one, but I have not been able to find a solution yet. Say I have terms of the form e.g 1/n1/n2/n3/n4 and ...
CAF's user avatar
  • 510
2 votes
0 answers
93 views

Don't simplify integer square roots

How can I rewrite an expression like $\frac{1}{2\sqrt{3}}$ as $\frac{1}{\sqrt{12}}$? This works in principle, but gets immediately simplified back to the original expression ...
infinitezero's user avatar
  • 1,419
2 votes
2 answers
1k views

Replace doesn't replace the denominator [duplicate]

I have the following expression in Mathematica -((E^(2 - 2 Sqrt[(x[1] - x[2])^2]) (x[1] - x[2]))/Sqrt[(x[1] - x[2])^2]) I want to replace anything of the ...
dbm's user avatar
  • 1,249
1 vote
2 answers
106 views

Symbolic derivative of transposition

I have an expression: expr = Transpose[x]+Transpose[f[x]]+Transpose[x+f[x]] I want to differentiate this expression and desired result looks like this: ...
ayr's user avatar
  • 2,444

15 30 50 per page