Questions tagged [replacement]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
33 views

Evaluate, NDSolve and ReplaceAll do not work with tables of solutions

Why does the following report an error even though it returns a (seemingly valid) result? It's also weird that it returns a list of lists, whereas I would expect just a list. ...
2
votes
1answer
113 views

Combining VectorPlot and Graphics3D

I have a simple VectorPlot3D VectorPlot3D[{x, y, z}, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}] Can I substitute the default arrows with Graphics3D object like: ...
0
votes
1answer
57 views

Forcing mathematica not to substitute some terms in an expression

I have an expression c which should be defined before the function and a function f defined as follows: ...
0
votes
4answers
41 views

Simplifying an equation by factoring the current coefficients in order to substitute a new coefficients

I have an equation in the following form: a*x + b*y + c*z == d I want to substitute the following constants instead of a,b,c,d: ...
5
votes
1answer
89 views

Patterns are not Sequences are not Lists, or: Global Function Argument Reversal

H[z_] := z /. {F[p__] -> F[Reverse[p]]} F[{x, y}] + F[{x, z}] + F[{}] // H Almost. It gives an annoying "Nonatomic Reverse" error message at the ...
0
votes
1answer
38 views

Formatting expressions with numeric exponents using pattern matching

Thank you all in advance. Question: I want to change the format of this expression (n + r)^3/n^3 into this (1+r/n)^3using rules ...
1
vote
1answer
46 views

How to create a simple transformation function on lists using short form of ReplaceAll?

I can easily do this with Map so the real goal of this exercise is to get a better grip on using transformation rules. Please help with this. The outputs should be ...
1
vote
2answers
61 views

Unable to plot a solution of NDSolve whilst being able to evaluate it

I want to define a function $f_c(x,y)$ as the solution of the PDE $\Delta f_c(x,y) = g_c(x,y)$, where $g_c$ is a given function depending on a constant $c$. I tried the following: ...
0
votes
1answer
73 views

Can someone please help me in breaking down what this code means?

I hope someone can assist me as I am pretty new to Mathematica and understanding the language is a bit of a hurdle. I am trying to rotate a plot of interlaced circles by some angle without rotating ...
1
vote
1answer
99 views

general replacement

I have 500 terms. and I want replace them with below function ...
6
votes
1answer
78 views

unexpected StringCases behaviour inside function module

First, Let use see a = {"wx", "wy", "wz"}; AssociationThread[Flatten[StringCases[a, "w" ~~ d_ :> d]] -> a] gives <...
0
votes
1answer
31 views

Setting rules for Gamma functions

I have some expressions involving lots of Gamma functions. Now the arguments of the functions sometime go to zero, in which case I want to use the factorial instead of the Gamma function (since it ...
1
vote
1answer
57 views

Denoting the whole in Position/Extract/ReplacePart

Position returns lists of numbers consumed by Extract, ReplacePart and others as "...
5
votes
2answers
142 views

Replace terms without symbolic term

I have a variety of terms that have coefficients of what I'll call $c_x$ and terms that are without this coefficient. I have a variable $U$, and would like to substitute powers of $U^2 \to d$ but only ...
0
votes
0answers
51 views

Block Behavior, but for Function Assignment instead of Variable Assignment

We can define a function using a variable b that does not appear as an argument, and then using Block, change the output of the ...
0
votes
1answer
56 views

Single computation is fast, but 6 computations are extremely slow

I have an expression that involves many Sign functions. I want to expand this in the piecewise format. My function is: ...
2
votes
0answers
34 views

Trouble using pattern matching with derivatives

I'm going to pre-reference this similar question as its very nearly what I need but my attempt at extending it to my case doesn't seem to quite work: Pattern matching a multivariate derivative In my ...
1
vote
2answers
147 views
0
votes
0answers
68 views

What is the difference between using replace all and using the value of a function?

For a project I'm working on, I'm using some functions that have a Chop[] to get rid of small terms that complicate things numerically. My function is ...
2
votes
2answers
68 views

Cutting of terms on denominators of giant expression

I have an immense expression of the form $$ \sum_i \frac{f_i(X,Y,x,y)}{(a_iX^2+b_iY^2+c_ix^2+d_iy^2)(e_iX^2+g_iY^2+h_ix^2+k_iy^2)}, $$ where at $a_i$ or $b_i$ AND $e_i$ or $g_i$ is different from zero....
2
votes
1answer
122 views

How to replace the arguments of a function?

I have the following type of (very long) expression: $$\ldots + X[1,2,3,5] + X[2,4,5,6] + \ldots \tag{1}$$ where $X[a,b,c,d]$ is some undefined function. I would like to replace all the occurrences of ...
0
votes
1answer
89 views

How to replace either one of the variables?

Here's my code: ...
4
votes
1answer
76 views

How to act with replacement on an association with syntax most similar to ReplaceAll

Replacements acting on Associations confuse me. I have read Pattern matching to a function evaluation inside an Association and How to use ReplaceAll and RuleDelayed with an Association? and I ...
3
votes
4answers
191 views

List all substrings of a number

Need some help listing all substrings of a number X=219 The output should be Output= {2,21,219,1,19,9} Order does not matter for this problem Any help is appreciated
1
vote
1answer
90 views

Rewrite a variable in terms of another variable

I have two variables t = 1/Sqrt[2] (Sqrt[1 + Cos[a]] + Sqrt[1 - Cos[a]] + Sqrt[1 + Cos[b]] + Sqrt[1 - Cos[b]] + Sqrt[1 + Cos[c]] + Sqrt[1 - Cos[c]]) and <...
2
votes
0answers
34 views

Replace element within a list of lists with MemberQ condition [closed]

I'm trying to replace the second element within a list of ordered pairs depending on whether that ordered pair exists within another set. ...
0
votes
0answers
85 views

Part specification is longer than the depth of object

I want to solve the function lns50 all the values are Part 1 of an List ...
0
votes
1answer
79 views

No solution to the equation even though it has one

I was trying out Mathematica with a simple equation. I tried this one out, but it outputted nothing and when I went on WolframAlpha to test it, there was a result (c = 3 btw). Please let me know if ...
1
vote
0answers
25 views

What subsequences does SequenceReplace consider

Consider SequenceReplace[{a, b, x, x, a, c}, {a, e_} :> e]. What subsequences does SequenceReplace consider? The ...
0
votes
1answer
60 views

Using :> vs -> in SequenceReplace

The first example on the page for SequenceReplace is the following: SequenceReplace[{a, b, x, x, a, c}, {a, e_} :> e] ...
0
votes
1answer
68 views

Nonlinear Model Fitting to Numerical Data with automatic elimination

I have an experimental data set {f,x,y,z} as {{300., 2., 4., 6.}, {500., 0., 4., 25.}, {6600., 1., 15., 9.}, {100., 5., 0., 2.}, {1100., 10., 8., 1.}, {1300., 7., 8., 18.}, {300., 23., 5., 0.}, {400....
4
votes
1answer
86 views

Making a rule that only applies when the expression is NOT an argument?

I know we can make rules of the kind: magic/:f_[x___,magic[a_],y___]:=f[x,arg[a],y] This will replace magic[a] by ...
1
vote
2answers
66 views

I use the rule, but it cannot work, So I want to know why it can't? [closed]

I make a approximate solution of the differential equations. But when I use the rule for one, and it can work. But when using a list of rules, It cannot. I mean "(Sum[ep^k*Subscript[y, k], {k, 0,...
0
votes
1answer
72 views

How to change a string-formatted element in an array?

I have an array called Array7 in which a typical element, let's say Array7[5][[22]], looks like this: ...
1
vote
1answer
68 views

Tracing my rules

As said in another question, I apply a set of rules to a string (OK, technically written as a function F of several arguments so I can easily apply rules on the fly)...
0
votes
1answer
52 views

Trouble with variable replacement

I'm having a lot of trouble with functions build from other functions. I'm struggling to understand the nuance of variable replacement. Here is an example: ...
2
votes
1answer
62 views

Replace with rule

I have an expression, $$test=\left(x_{jv}-y_{jv}\right)b+\left(x_{im}-y_{im}\right)c$$ ...
0
votes
1answer
64 views

Composite function derivatives

I would like to calculate the numerical partial derivatives (numerical gradient) of this function: ...
3
votes
0answers
45 views

Preventing $-renaming of pattern names in lexically-scoped constructs

When you use a lexically-scoped construct like With or Function to perform replacements in an expression, Mathematica might ...
2
votes
1answer
56 views

Mathematica association does not work on symbols

Question about using an association within Replace. If I have an association which contains symbols like so: ...
1
vote
2answers
64 views

How to Replace a Date in String Format with Values ​in a Table

I have a Table generated by reading a set of Excel files using the code: ...
1
vote
0answers
49 views

Rule Precedence

Do I understand the following correct ($R$ on-the-fly executable rules, $E$ expressions)? I assume MATHEMATICA uses an unification algorithm like I learnt it for e.g. PROLOG. If $R_1$ was defined ...
0
votes
0answers
51 views

How to implement integration by parts?

I have been trying to simplify integrand expressions using integration by parts, which schematically is given by $\theta(x)\nabla\phi(x)=-\phi(x)\nabla\theta(x)$. I think this can be done as a ...
1
vote
0answers
52 views

Avoiding infinite rule recursion

Assume I want to apply rule $R_1$ from a rule set $S$ to an expression $E$ just if it is "half safe", i.e., if the next application of $S$ to $R_1(E)$ does not yield $E$ again. (This ...
2
votes
2answers
68 views

Formal substitution of exponential factors in an expression

Assume that we have some complex algebraic expression, like Exp[(a t + b s)/w] ( t Exp[ q t] w + q Exp[q s] Exp[-2 s] + a^2 Exp[3 s] + s t + 1 ) Now, this is just ...
0
votes
0answers
31 views

Substituting factors for letters in expression

I have several large expressions that I'd like to substitute some factors for letter for the sake of simplicity. For example, I have this expression: $$ \frac{C_3 C_5 (C_1+C_4)-C_1 C_6 (C_2+C_5)}{2 ...
2
votes
1answer
59 views

Replacing multiple variables according to the index

I'm currently working on the Polya's Enumeration Theorem implementation in Mathematica. As an example, of what I want to do, here's a formula I'm working with: $$P_{C_{12}}(x_1,\ldots,x_{12})=\frac{1}{...
0
votes
2answers
84 views

Replacement of names of variables

First of all, I know replace or plugging input of given function through command Replace[] or /.{x->1} etc. Here I want to focus not just on plugging or replacing variables into numbers but just ...
4
votes
2answers
74 views

How to replace x[t] with Cos[t] in a differential equation? [closed]

If I use /. only x[t] is getting replaced, but x''[t] is not getting replaced. ...
0
votes
2answers
78 views

Why does this simple code with Eliminate not give any result?

My goal is to obtain the function $s$ defined in the code below as a function of $\chi_1$, $\chi_2$, $\chi_3$. The code runs but never ends, although the problem does not seem too hard to solve for a ...

1
2 3 4 5
28