Questions on expression testing and manipulation through pattern matching and constructing efficient patterns.

learn more… | top users | synonyms (1)

35
votes
2answers
661 views

How is pattern specificity decided?

Mathematica has a notion of pattern specificity, which is a partial ordering on patterns. The rules (e.g. DownValues, ...
0
votes
1answer
44 views

How to ensure efficient order of operations for rules, slots, substitutions?

I need to calculate several functionals Q[[t]] of a pdf f[x]. ...
5
votes
0answers
197 views

Convert logical relational expression to / from disjunctive and conjunctive forms?

I would like to convert logical relational expressions in disjunctive form, e.g., $$(x \lt -1) \lor (-1 \lt x \lt +1) \lor (x \gt +1)$$ into conjunctive form, e.g., $$(x \ne -1) \land (x \ne +1)$$ ...
4
votes
0answers
135 views

Syntax error for optional pattern, but only in debugger

This expression (explained here by Leonid) evaluates fine unless Evaluation->Debugger is enabled: h[x : (_Integer) : 1] := x Syntax::sntxf: "x:" cannot be ...
3
votes
0answers
143 views

I am missing a function like HoldPattern

Temporary message: I am planning to edit this question, making the examples less confusing and by moving the things that are confusing to a separate question For any confusion about expressions that ...
2
votes
0answers
47 views

pattern matching and applying a function, not working as expected

Consider the following code G[x, y] /. a_[b__] -> Total[a @@@ Permutations[List[b]]] I expect it to give G[x, y]+G[y,x] ...
2
votes
0answers
84 views

Is this a bug in NCAlgebra library?

In course of my work with NCAlgebra package for Mathematica, http://math.ucsd.edu/~ncalg/ , I encountered unexpected behavior of replacements. I am using ...
2
votes
0answers
30 views

How to syntax check that all instance of symbol must be contained in Subscript[]

I have a function f[expr] that is only allowed to take an expression expr that is a polynomial in ...
2
votes
0answers
234 views

NDSolve Issue with initial conditions

I am trying to implement a Poincare section for a gravitational movement on the plane $(x,y)$. Here is the code I wrote ...
1
vote
0answers
71 views

Crosscorrelation for nonperiodic signals

I want to detect patterns (of an absorption spectrum which is nonperiodic) with Mathematica automaticly. I have found CorrelationFuncion but as far as I understand, ...
1
vote
0answers
49 views

Symbolic and numeric calculations (and plots) simultanuosly

I use Mathematica to do a bunch of symbolic calculations (integrals, ...). This is good because I found that sometimes, if I plug in numeric values, Mathematica takes much longer. However, sometimes ...
1
vote
0answers
43 views

Hashing by Equals instead of SameQ

I have some numerical code involving complex numbers representing points on a plane. Some of these are equal but not identical, ie ...
1
vote
0answers
59 views

Function behavior based on Head

I'm figuring how to implement a function behavior based on the Head of its argument. I mean ...
1
vote
0answers
36 views

Matching Root[…] objects with patterns, unexpected hidden argument

I needed to write patterns that could distinguish between arbitrary-function and polynomial forms of Root objects, for example, ...
0
votes
0answers
64 views

Making a list of terms ordered by product order

I have some expressions f,g,h that are elements of a symmetric tensor algebra. The expressions are generated by a basis ...