Skip to main content

All Questions

Tagged with or
Filter by
Sorted by
Tagged with
2 votes
2 answers
22 views

why replacement does not work with centerdot [duplicate]

a ** ad ** ad //. a ** ad -> 1 + ad ** a this replacement works to move all the ad to the left of the a terms. ...
Luca's user avatar
  • 312
0 votes
0 answers
28 views

ReplaceAll (/.) not working as expected in Module [closed]

There is a difference between the following two expressions. Expression 1: ...
Jason Yan's user avatar
0 votes
0 answers
71 views

Puzzled about matching cases and patterns

I am puzzled why this does something sensible: ...
Craig Carter's user avatar
  • 4,839
0 votes
0 answers
37 views

Machine precision in ReplaceRepeated

I am relatively new in Mathematica and facing the following issue. I replace the parameters in an expression with a list of values using the function ReplaceRepeated and am getting the error: General::...
KB24's user avatar
  • 1
6 votes
5 answers
291 views

Trying to substitute an element of a given type by an integer

I have two lists: a = {{0}, {0, 0, 0}, {0, 0, 0, 16, 12}, {13, 7, 11}, {14}} b = {0, 2, 0, 2, 2, 2, 0, 0, -1, 2, 2, 2, 2, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0} The ...
David Fígols Olaria's user avatar
2 votes
1 answer
79 views

The arrow inside string [closed]

In Mathematica, if using ->, it gets automatically replaced with a nicely looking arrow. However, if using "->", ...
John Taylor's user avatar
  • 5,963
1 vote
0 answers
43 views

How to Substitute a Metric into a Variation of the Action in Mathematica to Obtain Field Equations?

I have already calculated the variation of an action for a modified gravitational theory, and now I want to substitute a specific metric (e.g., the Schwarzschild metric) into this variation in ...
Elena Margalejo's user avatar
0 votes
2 answers
81 views

Why is ReplaceAll unable to replace square root? [closed]

The following is my code. ...
kile's user avatar
  • 1,892
2 votes
1 answer
184 views

JordanDecomposition gives out different answers on symbolic and numerical calculations

Numerical substitution before or after performing the JordanDecomposition yields different results. Here is the source code to reproduce the error: ...
Yu-Sen Zhou's user avatar
3 votes
1 answer
85 views

Replacing d[r]/dt by 0 in expression

The purpose is to recognize d[r]/dt in the expression below, and to make the expression zero. It seems impossible because there is no Time[Power[dt,-1],d[r]] in the expression at the left hand side in ...
Soon's user avatar
  • 800
1 vote
1 answer
77 views

Replace complex pattern in big expression in a non-sensitive way

Assume this big expression ...
Smilia's user avatar
  • 613
2 votes
2 answers
122 views

Ask Mathematica to prioritize writing an expression in terms of another

I have an old reference text with tables of solid spherical harmonics expressed in cartesian coordinates. (Edit: Here's a digital version of said table, for the curious.) In an attempt to replicate ...
sbernierjhu's user avatar
0 votes
0 answers
64 views

How to Replace the expression with unknown parameters?

I do not want to do Derivative, because it will be very slow after million times. My expression is just the Exponential as following, ...
sss668800's user avatar
1 vote
1 answer
76 views

How can I write a single pattern for replacement for a nonlinear change of variables

I have a polynomial in say a,b, and c, and I want this to be in terms of x,y, and z where a^(i_)*b^(j_)*c^(k_) ->x^(i+j+k+1)*y^(i+k+1)*z^(k+1), but if I try to ...
Matthew Crawford's user avatar
1 vote
0 answers
67 views

How can the reverse of a rule which contains two arguments be defined in Mathematica? [duplicate]

Suppose I have a rule in Mathematica: x -> x[a] defined under some variable. Is there a way I can use the reverse of the rule ...
codebpr's user avatar
  • 2,953
3 votes
2 answers
136 views

How to do substitution of a function by another function in derivatives [duplicate]

Simplifying my problem, I have the expression D[f[x], x], and I want to substitute f[x] with ...
Ignat Fialkovskiy's user avatar
1 vote
1 answer
107 views

ReplaceRepeated ( //. ) does not work as expected

I have a list expr of symbols. ...
A. Kato's user avatar
  • 5,515
2 votes
0 answers
66 views

Doubt about ReplaceRepeated?

I made the following code: L={{1,2},{2,3},{2,4}}; R:=(L=(L/.{x_,y_}:>Splice[{{x,y},{x,x},{y,y}}]/;MemberQ[L,{x,y}])//Union) When I run R three times, I get: <...
Red Banana's user avatar
  • 5,573
4 votes
3 answers
170 views

How to map a list of elements to a list of positions of a matrix

I have an all zero matrix zeromatrix= ConstantArray[0,{4,4}] I have a list of non-zero positions and a list of non-zero values ...
am567's user avatar
  • 891
4 votes
5 answers
222 views

Transform a list of rules into a list of function definitions

I have a list of rules obtained by solving a system of equations, e.g. {f[x] -> a + 3 h[x], g[x] -> 2 a + c + 6 h[x]}. I wish to convert this list of rules ...
Stanislas Antczak's user avatar
0 votes
0 answers
36 views

How to apply dependent rules in a complex expression?

I am working with a complex expression, $L_0$, which I need to simplify iteratively using a series of dependent replacement rules. Here's the structured approach I am trying to implement: Start with ...
Charmbracelet's user avatar
1 vote
0 answers
53 views

How to Prevent Short Name Character from Auto Converting [duplicate]

The following code creates the short name character aliasdelimiter, then selects it and reads and tests it. ...
B flat's user avatar
  • 6,016
0 votes
1 answer
80 views

Transforming an expression into function

I want to transform the expression a = 2 x + 1 into f=Exp[a], z=Log[x], and express the ...
Themis's user avatar
  • 780
0 votes
0 answers
38 views

Can I remove a rule from a built-in function?

Can I remove the rule DiracDelta[n x]==DiracDelta[x]/n when n is numeric from the definition of ...
Anixx's user avatar
  • 3,712
0 votes
1 answer
30 views

How to put prime before value during a substitution?

Here is a sample Mathematica code: ...
codebpr's user avatar
  • 2,953
0 votes
2 answers
68 views

Hold Dt[r,t] unevaluated but Mathematica substitutes value of r

I have the formula for the Volume of the sphere and then differentiate Dt[V == 4/3 \[Pi] r^3, t] The output is ...
Mark Grindol's user avatar
1 vote
0 answers
113 views

Perturbation theory. Get xAct tensor component. Substitution for xAct tensors

I work with perturbations in FLRW metric with arbitary curvature. I'm following Weinberg's book. In modified gravitation theory there is additional tensor S and I need to find it's perturbation in the ...
Ruslan Kamalitdinov's user avatar
1 vote
1 answer
58 views

How to achieve automatic nesting of pattern application

I want to apply the following rules: ...
მამუკა ჯიბლაძე's user avatar
4 votes
0 answers
140 views

Limit of a PolyLog does not work [bug]

This is an issue I am having with Mathematica version 13.1.0.0. I tried the following code, but it does not work as expected: ...
Zachary Wüthrich's user avatar
0 votes
1 answer
36 views

Cross derivative rules

I am trying to generalize the condition Derivative[1, 0][ℒp][t, ϕ] -> Derivative[0, 1][ℒp][t, ϕ]/l for $\ell$ a constant, through the following rule ...
hyriusen's user avatar
  • 155
3 votes
2 answers
181 views

Modify Rules with new patterns

My Rules always have one instance of TR on the LHS, and several on the RHS, like this TR[2] -> TR[5] + TR[h, g] I want to generalize them by adding optional ...
Albercoc's user avatar
  • 1,122
1 vote
1 answer
59 views

Weird behavior when using Parallelize with LieART

I want to perform computation with the LieART package and Parallelize some long computation. But I run into the following ...
Lelouch's user avatar
  • 555
1 vote
0 answers
40 views

Replacing an expression with pre-defined function

I am asking Mathematica to do a long calculation with functions I am defining at the beginning of the script. Because the resulting expressions are long, I want to replace them with the functions I ...
emir sezik's user avatar
3 votes
1 answer
100 views

Sort the arguments of a function using replace

I want to sort the arguments of a function f while multiplying with the signature of the permutation, i.e. f is totally antisymmetric function. My idea was something like ...
jkb1603's user avatar
  • 187
2 votes
2 answers
106 views

Why does Replace function not work the first time I try it?

Please explain why in the following mathematica code, the cos term was not replaced in the first try, but got replaced in the second try? ...
Prem's user avatar
  • 121
2 votes
4 answers
320 views

Ignore higher order terms in an expression

I am trying to ignore terms that are higher order (third or more) in an expression. For example, for the input function: $$f_{in}= \alpha\beta + \alpha^2 + \beta^2 + \alpha\beta^2/2 + \alpha^2 \beta $...
Arnab's user avatar
  • 123
0 votes
0 answers
55 views

Mathematica solve with conditions on constants differ from replace

I have been trying to solve some complicated linear equations in Mathematica, with variables $y_{i}$, and constants $a, f_{j}$ where $0\leq j\leq10$. I only care about the case where $\sum_{i=1}^{10}...
patchouli's user avatar
  • 101
4 votes
1 answer
128 views

How to write a rule that matches alternatives but return one of them always?

Consider the following rule: $rule={"Period ID"|p:"Period":>p}; This rule will match ...
user13892's user avatar
  • 9,751
3 votes
1 answer
108 views

How to `Collect` where `var` is one expression?

Edit: Clear["Global`*"]; expr1 = (a + c - b + 1)^3 + (-b + a + c + 2)^4 // Expand For test case expr1, this is the ...
138 Aspen's user avatar
  • 2,067
0 votes
0 answers
38 views

Replacement not working as desired [duplicate]

The following replacement works fine ReplaceAll[1/F[x],F[x]->y] (*1/y*) but this doesn't ...
qreus's user avatar
  • 343
6 votes
4 answers
348 views

Transform sequence into ragged list

I want to transform seq = {x, 1, 2, x, 3, x, 4, 5, y, y, 67, y}; into {1, 2, {3, {4, 5}}, 67} The only way I found is rather ...
eldo's user avatar
  • 83.1k
0 votes
1 answer
89 views

Why does Mathematica fail to substitute some terms in an expression but not others?

I have an expression of the form: $A-\frac{e^{-t/t_1} \; a \; b}{c \; t_1} \; U_1 - \frac{e^{-t/t_2} \; a \; d}{c \; t_2} \; U_2 -\frac{e^{-t/t_2} \; a \; e}{c \; t_2} \; U_2 - \frac{e^{-t/t_3} \; a \;...
CountBackwardsFromInfinity's user avatar
4 votes
4 answers
309 views

Replacing string values with one of the sequence-functions

Given the following list of rules (which might contain duplicate keys), I want to replace the string values with the first preceding numerical value. ...
eldo's user avatar
  • 83.1k
1 vote
0 answers
43 views

Why list of replacement does not work in the following example? [closed]

I want to replace a long list but in the following format, but it does not work: (Aa + Bb + Cc) /. {{Aa, Bb, Cc} -> {x + 2, y + 2, z + 2}}
SciJewel's user avatar
  • 575
1 vote
0 answers
59 views

Replacement rule runs for a long time [duplicate]

I have a simple expression that reads (some expression in b) q^(8/3): ...
Lelouch's user avatar
  • 555
1 vote
1 answer
42 views

How to do this replacement? Match the variable, but not the function [duplicate]

I have the following expression: $$\frac{\left(-2 \lambda \lambda [\theta ]+\lambda [\theta ]^2+\lambda ^2+\lambda \right) \lambda '[\theta ]^2}{\lambda [\theta ]^2}$$ I want to replace every ...
AccidentalTaylorExpansion's user avatar
1 vote
0 answers
43 views

Difference in pattern matching between Cases and ReplaceAll (Already searching at all levels and heads)

Why is there a difference between the pattern matching between Cases and ReplaceAll in the following: ...
Kvothe's user avatar
  • 4,781
1 vote
0 answers
63 views

Random replacement in array

In the spirit of this interesting article of Stephen Wolfram I also decided to study some issues related to mutations. I’m working with simple {0,1} arrays and I’ve ...
lesobrod's user avatar
  • 1,924
1 vote
1 answer
83 views

How to replace C[1] in solutions of trigonometric equations into k?

This is my code Table[{HoldForm[Cos[3 x + 2 Pi/5]] == Sqrt[i]/2, Reduce[Sin[2 x] == Sqrt[i]/2, x, Reals]}, {i, 0, 4}] How can I replace C1 to ...
John Paul Peter's user avatar
3 votes
2 answers
105 views

Multiple replacements in a long expression

Why does the replace /. not work on the second argument in the following expression: ...
SciJewel's user avatar
  • 575

1
2 3 4 5
34