Questions tagged [semantic-matching]
Posts about semantic pattern matching rather than syntactic pattern matching (which is the built-in pattern matcher of Mathematica) e.g. "Why x^3 /. x^2->a doesn't work!"
28 questions
2
votes
1
answer
134
views
Difference in pattern matching before & after Expand
The goal is to substitute m2/m1 in expr with k. Code1 does not match the pattern, but if it is pre-processed with Expand like in code2, it matches the pattern. Could I know why there is this ...
1
vote
4
answers
236
views
How to keep a specific expression unevaluated?
For example, I define some quantities here
$$
\gamma=\frac1{\sqrt{1-\frac{r^2}{c^2 t^2}}}, \qquad \mbox{with} \; r^2=x^2+y^2+z^2.
$$
Now I want to calculate some expressions. Let's say, $\partial_t \...
2
votes
2
answers
216
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 ...
3
votes
5
answers
274
views
Importing Specific Data from a Text File
I am quite new to Mathematica. I have a text file that upon importing has a repetitive structure with characters included. I need to extract only the following in numbers only (no letters, dash lines, ...
3
votes
2
answers
109
views
Trouble with replacement rules for squared variables [duplicate]
I want to do replacement of products (because I am dealing with abstract projectors), but Mathematica seems to fail understanding this toy example replacement :
...
5
votes
1
answer
252
views
How to Replace 'delta t' with 'a' in Mathematica Without Affecting Separate Instances of 'delta' or 't'?
In Mathematica, how can I replace instances of delta t in an expression with a, while keeping instances of ...
0
votes
3
answers
110
views
How to replace polynomials numerically? [duplicate]
We know that the value of this equation is 0
x2 y1 - x1 y2 == 0
For the following equation, there is a correlation between the polynomial parts of the known ...
1
vote
1
answer
176
views
Expression substitution
I konw:
$$
a_0=\frac{4 \pi \epsilon_0 \hbar^2}{m_e e^2}
$$
and
$$
\alpha = \frac{m_{\mathrm{e}}^2 e^4}{18 \pi^3 \epsilon_0^2 \hbar^4}
$$
So we can use $a_0$ for $\alpha$,like this:
$$
\alpha=\frac{m_{\...
0
votes
0
answers
110
views
Neural network: Segmentation of water and not water area
Good morning everyone. I have a large dataset of photographs similar to the one attached. It would be my intention to train a neural network to recognise water and "non-water" zones. How ...
4
votes
4
answers
283
views
How to use replacement rules in a named expression before a sub-expression evaluates?
I have a named expression: expr := a + b. a and b are also named expressions.
Let's say <...
2
votes
1
answer
244
views
How to replace Divide in an expression?
It seems that a/b is always replaced with the form: a * b^-1, Times[a, Power[b, -1]]. I ...
4
votes
3
answers
318
views
Rule can not work? [duplicate]
For example I have this equation,I want to use c->a/b ,but it can not work
$$
\frac{a^2}{b^2}+\frac{b^2}{a^2}+\frac{a}{b}+e^{a/b}+\frac{b}{a}+\log \left(\frac{a}{b}\right)
$$
...
2
votes
2
answers
181
views
How can I change variables, if the variables I want to change to are not directly stated in the term?
So I don't mean something like this
f[x_] = x^2
f[x] /. x^2 -> y
But what I mean is something like this:
where the variables I want to change to are defined ...
5
votes
2
answers
333
views
What is a nice way to convince Mathematica to use $\tau$ instead of $\pi$ in evaluated formulas?
I have tried like
Replace[something, {2*π -> HoldForm[τ]}]
Although it works well where a lone 2 π symbol, it fails to ...
3
votes
1
answer
256
views
ReplaceAll with Powers [duplicate]
If I run the following code:
a^2/b^2 /. {a/b -> c}
I'm getting output:
a^2/b^2
How can I obtain ...