Skip to main content

Questions tagged [replacement]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
0 answers
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}}
SciJewel's user avatar
  • 452
1 vote
0 answers
55 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
  • 543
1 vote
1 answer
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 ...
AccidentalTaylorExpansion's user avatar
1 vote
0 answers
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: ...
Kvothe's user avatar
  • 4,491
1 vote
0 answers
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 ...
lesobrod's user avatar
  • 1,729
1 vote
1 answer
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 ...
John Paul Peter's user avatar
3 votes
2 answers
100 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
  • 452
0 votes
0 answers
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 ...
Navvye's user avatar
  • 171
2 votes
1 answer
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: ...
Zsombor's user avatar
  • 185
2 votes
1 answer
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] == _ ...
Gert's user avatar
  • 1,530
5 votes
3 answers
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 : ...
Adrien Martina's user avatar
1 vote
0 answers
37 views

Performing difference in extracting coefficients from a sum

I have an expression ...
Lelouch's user avatar
  • 543
2 votes
2 answers
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. ...
TrodaroX's user avatar
4 votes
5 answers
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 ...
Adrien Martina's user avatar
9 votes
5 answers
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: ...
azerbajdzan's user avatar
  • 18.9k
11 votes
5 answers
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 ...
azerbajdzan's user avatar
  • 18.9k
2 votes
0 answers
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 ...
codebpr's user avatar
  • 2,263
1 vote
1 answer
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 ...
Matthew Ward's user avatar
7 votes
3 answers
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 ...
Red Banana's user avatar
  • 5,401
3 votes
1 answer
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....
David Keith's user avatar
  • 4,604
1 vote
1 answer
64 views

Rules Being Ignored by Mathematica

Can someone explain to me why Mathematica is ignoring the replacement rules in the following code: ...
Mjoseph's user avatar
  • 233
6 votes
1 answer
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: ...
NC520's user avatar
  • 479
1 vote
2 answers
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?
Alex Wong's user avatar
9 votes
2 answers
501 views

What's the difference between With and ReplaceAll?

A wolfram Tutorial mentions that ReplaceAll and With are similar: The way ...
ions me's user avatar
  • 991
2 votes
1 answer
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, ...
homocomputeris's user avatar
2 votes
1 answer
79 views

Why can't I assign upvalues to NonCommutativeMultiply?

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 ...
user366202's user avatar
1 vote
1 answer
40 views

How to check a group of solutions of partial differential equations?

There is the partial differential equations, $$ \left.\left\{\begin{array}{c}u_t-3qu^2u_x+\frac{3}{2}q(uv)_x-\frac{1}{4}qu_{xxx}=0,\\v_t+\frac{3}{2}qvv_x-3q(u^2v)_x+3qu_xu_{xx}+\frac{3}{2}quu_{xxx}-\...
godspeed's user avatar
1 vote
1 answer
50 views

How to make the following replacement?

Consider the following symbolic expression: expr=mon[m,b]*kd[m,d]+band[a,c]alc[b,c]kd[a,d]+func[a,c]dum[a,c]kd[b,d] + f1[b,c]f2[d,c] It has three types of summands:...
John Taylor's user avatar
  • 5,827
0 votes
0 answers
18 views

Issue with ReplaceAll resulting in Null function return

I am trying to modify some code of mine to change where the final evaluation of a function is performed, as a way to not generate massive tables of data. The code is working fine, until I have started ...
D. Brown's user avatar
  • 304
1 vote
1 answer
77 views

Animate a FindMinimum with NIntegrate

The objective is to investigate how a fitted normal distribution approximates the sum of two normal distributions with a difference in $\mu$, $\sigma$, and amplitude. The purpose is finding out how ...
OmnipotentEntity's user avatar
1 vote
1 answer
98 views

Converting trigonometric expressions between sine and cosine forms

How to convert sine and cosine into each other? Using the relationship between sine and cosine for mutual transformation: Such as: Sqrt[3] Sin[π/6 - (π x)/4] ...
csn899's user avatar
  • 4,315
0 votes
2 answers
58 views

Replacement rule for unevaluated LaplaceTransform

I am wanting to algebraically manipulate expressions resulting from LaplaceTransform applied to time domain expressions. Unknown variables are left unevaluated by the transform as they should be. I ...
David Keith's user avatar
  • 4,604
4 votes
3 answers
180 views

How do I get Replace to work with a complex repeating pattern?

I'm new to Mathematica, but with extensive searching and a lot of experimenting I can't seem to get this to work. I have a list of strings of the form: ...
p quint's user avatar
  • 43
2 votes
3 answers
51 views

In the given code, how can I ask Mathematica to replace the obtained points in function $g$ and plot it?

I obtain a set of points which are the solutions of f[b, c, d] == 0 by this code ...
PhysFan's user avatar
  • 63
6 votes
5 answers
721 views

Manipulating rules

I tried searching in the docs in "Transformation Rules and Definitions", however there wasn't anything of help. So imagine I have these two rules: ...
Confuse-ray30's user avatar
0 votes
1 answer
64 views

Different results of Replacement [closed]

My goal is to replace 1+n with α+β. But the results for code1 and code2 are different as shown below. I don't know why? (I checked FullForm and it's the same) ...
Soon's user avatar
  • 648
1 vote
1 answer
58 views

Rearranging expression

My goal is to place the terms related to q and r in Expression 1 in one place as much as possible, like Expression 2.(Alpha and beta in the expression are constants, and q and r are variables.) How ...
Soon's user avatar
  • 648
1 vote
0 answers
45 views

Replace Contours from ContourPlot3D doesn't work [closed]

I try to replace number of contours in a plot already stored in a variable (or in a function, doesn't matter). I have very complicated and time-consuming calculations followed by plotting a ...
Lechuu's user avatar
  • 534
6 votes
3 answers
158 views

Cancelling factor in fractions with factorial

My goal is to make a simplification: $$\frac{k}{k!} \to \frac{1}{(k-1)!}.$$ However, $k$ in the denominator and numerator is not automatically cancelled by Mathematica. What is the best known method ...
Soon's user avatar
  • 648
0 votes
0 answers
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 ...
John Paul Peter's user avatar
5 votes
2 answers
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: ...
E. Chan-López's user avatar
1 vote
0 answers
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 ...
tyogi's user avatar
  • 289
0 votes
0 answers
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. ...
Satoru Mochizuki's user avatar
1 vote
0 answers
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 ...
crabtree's user avatar
1 vote
0 answers
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? ...
crabtree's user avatar
2 votes
1 answer
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$ .
PoemTechnology's user avatar
1 vote
1 answer
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 ...
jbroedel's user avatar
  • 111
2 votes
3 answers
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: ...
hossein mohseni's user avatar
0 votes
3 answers
63 views

Replacing a set

I have the following set ...
Tanmoy Pati's user avatar
12 votes
5 answers
783 views

How can I remove empty lists { } from a nested list?

I have a list: list={{{1},{2},{1,2},{1,2,3},{},{}},{{2},{3},{}}} I would like to remove the empty lists {} to get: ...
Thuy Nguyen's user avatar
  • 1,097

1
2 3 4 5
33