Questions tagged [replacement]

The tag has no usage guidance.

1,644 questions
Filter by
Sorted by
Tagged with
1 vote
39 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}}
• 452
1 vote
55 views

Replacement rule runs for a long time [duplicate]

I have a simple expression that reads (some expression in b) q^(8/3): ...
• 543
1 vote
34 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 ...
1 vote
34 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: ...
• 4,491
1 vote
53 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 ...
• 1,729
1 vote
74 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 ...
• 1,567
100 views

Multiple replacements in a long expression

Why does the replace /. not work on the second argument in the following expression: ...
• 452
26 views

Time Complexity of Multiway System

I was wondering what the time complexity for the implementation of a Multiway System would be. For reference, we can implement a MultiwaySystem using the Resource Function ...
• 171
77 views

Generate variables in multiple integral

I want to do a multiple integrate with n variables. When I change the value of n, I do not want to rewrite the variables in the integral manually like here: ...
• 185
77 views

Removing `circular rules'

Say that I have a huge list (>300.000 elements) of polynomial equations and I want to simplify these by looking for some simple equations of the form x[i] == _ ...
• 1,530
322 views

Reversing the order of function arguments by a replacement rule

I am facing an issue when I try to reverse the arguments of a function in a replacement rule. Let me give an example : ...
1 vote
37 views

Performing difference in extracting coefficients from a sum

I have an expression ...
• 543
55 views

Difference between variables and expressions for ReplaceAll

I'm doing some GR calculations with xAct. I get an expression that is heavy. In order to simplify the results, I try to use the function ReplaceAll in simple cases. ...
• 21
210 views

How to make expression-dependent replacements?

Consider as a toy example that I want a replacement which acts on {x,1,2,3} by replacing $x$ with the length of the list itself. In this example this should output ...
370 views

Reconstruct list from its PositionIndex

Is there a more elegant or shorter way of reconstructing a list from its PositionIndex? The following I regard quite cumbersome: ...
• 18.9k
513 views

Isomorphic lists

Is there a function that outputs True if lists are isomorphic (there exists a rule that changes the first list into the second one and inverse of the rule changes ...
• 18.9k
77 views

How to effectively substitute variables in xAct?

I am trying to find the gauge field equation by varying the Born-Infeld Action with the help of xact package. I use the following ...
• 2,263
1 vote
42 views

Set the value of a parameter in a Series expression [closed]

I have a lengthy expression resulting from a series expansion in some dummy variable $e$ which I now wish to set equal to 1. However, when I try to use a ReplaceAll ...
263 views

Replace number in string with ? and /;

I am trying to make the following: StringReplace[{"A4", "A#3"}, {"A" ~~ x_ -> "B" ~~ x}] This should replace ...
• 5,401
41 views

How to Replace EdgeLabel in a Graph [duplicate]

I am working with Graphs in which I want to define a Graph with Symbols or Strings as EdgeLabels, and later replace these with functions of the symbols with symbols then replaced with numerical values....
• 4,604
1 vote
64 views

Rules Being Ignored by Mathematica

Can someone explain to me why Mathematica is ignoring the replacement rules in the following code: ...
• 233
103 views

Substitute solution into ODE to verify it holds

I am struggling a lot to understand how to do the very basic exercise of substituting a solution into an ODE so see whether the solution is indeed valid. Consider the following ODE: ...
• 479
1 vote
96 views

How do you remove parts of an element within a list? [closed]

I have a data set that is something like: time={-2_ms, -1_ms, 0_ms, 1_ms, 2_ms}; How do I drop the _ms part such that its just a list of numbers?
501 views

What's the difference between With and ReplaceAll?

A wolfram Tutorial mentions that ReplaceAll and With are similar: The way ...
• 991
147 views

How to correctly replace scalars with matrices?

How can a scalar be replaced with a matrix to perform operations on the matrix, not its elements? For example, ...
79 views

I'm trying to define a non-commutative product with respect to which, certain quantities (e.g. numbers, and some other quantities defined in my code) behave as "scalars" and can be pulled ...
• 451
1 vote
40 views

• 648
29 views

How can I get the result of TeXForm[HoldForm[1 x^2 + 1 x + 1 == 0]] is x^2 + x + 1 ==0?

Sometimes, I get the situation when using TeXForm and HoldFormof a polynomial. E.g ...
• 1,567
132 views

Obtaining Pairs of Consecutive Elements with Conditional Adjustment

I've encountered a particular problem and was wondering if anyone has any insights on how to approach it more efficiently or elegantly. To be accurate, given the list: ...
• 25.3k
1 vote
65 views

Simplifying an expression by plugging some "knowledge" into it

I am having trouble simplifying an expression using some characteristics ("knowledge") I have regarding the variables. In the expression below, I have the weighted average ...
• 289
44 views

Simple question on ReplaceAll funciton

This is working. Array[f, {3, 3}] /. f -> g {{g[1, 1], g[1, 2], g[1, 3]}, {g[2, 1], g[2, 2], g[2, 3]}, {g[3, 1], g[3, 2], g[3, 3]}} This is working. ...
1 vote
55 views

Is there an easy way to make built-in functions do a replacement before throwing an error message?

Many built-in functions throw errors before executing a ReplaceAll. The functions still execute the ReplaceAll as intended, but ...
• 71
1 vote
141 views

What's the difference between Mathematica 14 and Wolfram Alpha Notebook 14

A version of my question was asked in 2019 (What is the difference between Mathematica and WolframAlpha Notebook Edition?) with no clear answer then. Is there anything new that that addresses this? ...
• 71
68 views

Algebraic replacement [duplicate]

How do I replace an algebraic expression with a symbol? I'm trying to replace repeated terms such as $(a+b)$ with c, for example, so that $x(4a + 4b) + x^2(6a + 6b)$ becomes $x4c + x^26c$ .
1 vote
54 views

How to display a formula written in proper LaTeX (e.g. no double backslashes) in Mathematica? [duplicate]

I would like to display some formulae in a Mathematica notebook. For this I would like to have a function like ...
• 111
137 views

Using patterns in ReplaceAll to match different symbols

I have an expression expr = kb.kpb+kb.kb+knb.knb+kpb.knb+kd.kpd+kd.kd+knd.knd+kpd.knd; and I want to make replacement rules as: ...
63 views

Replacing a set

I have the following set ...
• 357