Skip to main content

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!"

Filter by
Sorted by
Tagged with
1 vote
3 answers
162 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 \...
Curious Cat's user avatar
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
3 votes
5 answers
190 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, ...
LollyPop's user avatar
3 votes
2 answers
47 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 : ...
Adrien Martina's user avatar
5 votes
1 answer
214 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 ...
Tokubara's user avatar
  • 215
0 votes
3 answers
59 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 ...
csn899's user avatar
  • 1
1 vote
1 answer
115 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_{\...
我心永恒's user avatar
  • 1,630
0 votes
0 answers
76 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 ...
Ramiro dell'Erba's user avatar
4 votes
4 answers
193 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 <...
Borislav Stanimirov's user avatar
2 votes
1 answer
182 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 ...
Borislav Stanimirov's user avatar
4 votes
3 answers
205 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) $$ ...
我心永恒's user avatar
  • 1,630
2 votes
2 answers
139 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 ...
Student's user avatar
  • 177
5 votes
2 answers
278 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 ...
George Rey's user avatar
3 votes
1 answer
201 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 ...
Mieczmik's user avatar
2 votes
0 answers
247 views

What is Wolfram's equivalent of Maple's algsubs?

Maple has two primary substitution functions. subs - which is similar to ReplaceAll in WL. algsubs - which does replacement but takes into account the algebraic ...
user13892's user avatar
  • 9,751
2 votes
2 answers
372 views

How do you get substitution to recognize a derivative?

I have a simple expression involving a derivative: x[t_] = Q/T[t]; Simplify[Derivative[1][x][t] /. Q -> x T[t]] That produces:$$-\frac{x T'[t]}{T[t]}$$I have ...
Quark Soup's user avatar
  • 1,610
5 votes
3 answers
752 views

ReplaceAll (/.) not working as expected

I am trying to replace some variables in the form of n*wt with wt. However, I came across some cases where the ...
nanjun's user avatar
  • 1,327
4 votes
2 answers
337 views

Definition of a general rule

By defining: rule = Sqrt[expr_^2] :> expr; and writing: Sqrt[x^2] /. rule I get: x which is what is desired (...
πρόσεχε's user avatar
0 votes
1 answer
43 views

Parsing time interval strings as "Uncertain" Time Intervals

Problem: I have strings of form "[d1, d2]" or sometimes just [d1] where d1 and ...
George's user avatar
  • 3,175
9 votes
1 answer
1k views

How to find multi-word synonyms?

I’m looking to write a semantic distance function for phrases (5 words or less) that can map multi-word synonyms together. My domain is e-commerce fashion - here are some required examples for a ...
M.R.'s user avatar
  • 31.8k
0 votes
1 answer
200 views

Using Semantic Import to do an Excel-like VLookUp using Mathematica

I'm following an example provided in the following Stack Exchange Link but, using a different approach. My data is contained in an Excel workbook called "Input Workbook.xlsx" as shown here: I ...
Gilmar Rodriguez Pierluissi's user avatar
6 votes
2 answers
420 views

"Smart" substitution of subexpressions

I have the following question. An expression, which I want to simplify contains several subexpressions which appear quite frequently all over the place. To optimize simplification I would like to ...
user43283's user avatar
  • 245
3 votes
0 answers
142 views

SemanticImport extremely slow with "Number" format

With the following definition: col = "num\n" <> StringRiffle[Table[i, {i, 1000}], "\n"]; I do not understand why the ...
Aharon Naiman's user avatar
2 votes
2 answers
234 views

Sets of identical equality/inequalities

So I've used Mathematica for some months, but I never noticed this sort of thing about it, namely: (a > b) == (b < a) which are supposed to be identical ...
kozner's user avatar
  • 283
0 votes
1 answer
195 views

Simplifying expressions

Let's define a function $\Omega(x,y)$ ...
Vaggelis_Z's user avatar
  • 8,830
4 votes
4 answers
850 views

How to apply ReplaceAll to denominator?

Here is the simple task. In reality, it's far more complicated, but it comes down to this. I want to take the expression $\frac{y}{x^2}$ and replace $x^2$ with $k$. This doesn't work: ...
Luka's user avatar
  • 133
60 votes
4 answers
11k views

Can I simplify an expression into form which uses my own definitions?

This seems like a simple thing to do, but I couldn't find anything relevant from Mathematica documentation. So suppose I have an expression: a*b/(a + a*Cos[a/b]) ...
Echows's user avatar
  • 981