Questions tagged [operators]

Questions about using or composing operators--functional mappings from one state or vector space to another.

Filter by
Sorted by
Tagged with
76 votes
3 answers
6k views

when is f@g not the same as f[g]?

I have always thought that f@g will give the same result as f[g] in all cases, and it is just a matter of style which one to use ...
Nasser's user avatar
  • 143k
67 votes
6 answers
3k views

V10's Operator Forms - what are they good for?

V10 introduces an operator form for several functions perhaps primarily due to their role in queries as part of introducing data science functionality. At first pass it seems a lot of effort to add ...
Ronald Monson's user avatar
39 votes
6 answers
8k views

Having the derivative be an operator

How do I create an operator which acts like a derivative to everything to the right of it: for example: $ \left( \partial_x + \partial_y + z \right ) x \psi $ How do I make that evaluate to: $x \...
Andrew Spott's user avatar
  • 1,581
37 votes
3 answers
983 views

Is there a comprehensive list of functions with operator forms?

As of version 10, Mathematica sports operator forms for many functions like Map, SortBy, ...
Martin Ender's user avatar
  • 8,774
28 votes
3 answers
3k views

How is + as an infix operator associated with Plus?

How is + associated with Plus? Suppose I want to define a head FooBar and have it ...
MathCraft's user avatar
  • 585
26 votes
4 answers
2k views

What is the definition of Curl in Mathematica?

I have a usual mathematical background in vector and tensor calculus. I was trying to use the differential operators of Mathematica, namely Grad, ...
Hosein Rahnama's user avatar
23 votes
11 answers
3k views

Generating an ordered list of pairs of elements from ordered lists

I have a pair of ordered lists. I want to generate a new ordered list (using the same ordering) of length n by applying a binary operator to pairs of elements, one from each list, along with the index ...
TheDoctor's user avatar
  • 2,832
19 votes
1 answer
241 views

Why does OperatorApplied by default reverse the arguments?

Perhaps this is just one of those Mathematica curiosities, but I'd like to know why by default OperatorApplied[f][x][y] === f[y,x] versus the more usual way one ...
Kai's user avatar
  • 2,099
17 votes
2 answers
1k views

What happens when you divide by ##?

I've been playing around with sequences a bit. In particular with using ## with unary and binary operators. Let's start simple, the following all make some kind of ...
Martin Ender's user avatar
  • 8,774
17 votes
2 answers
2k views

How to define a non-standard algebra in Mathematica?

I want to define an algebra, where there are three elements: 0, 1 and $\infty$ and two operations, addition and multiplication defined, both commutative: $$\begin{align*} 0+0&=0\\ 0+1&=1\\ ...
Anixx's user avatar
  • 3,585
15 votes
6 answers
3k views

Element-wise test on List elements

This question could sound pretty silly but I can't find a way to apply element -wise tests to a list. For example if I digit ...
dario's user avatar
  • 337
15 votes
3 answers
845 views

Is it possible to define custom compound assignment operators like ⊕= similar to built-ins +=, *= etc?

I would like to do something like this: ...
Vladimir Reshetnikov's user avatar
15 votes
4 answers
3k views

Exponential of a Differential Operator

In Mathematica, is it possible to exponentiate a differential operator such that the operator will act on a function, $f(x,p)$? Specifically, I wondering if I can get Mathematica to do this: $\exp(c\...
user85503's user avatar
  • 992
15 votes
2 answers
436 views

Custom operator form for system functions?

There are some functions for which an operator form would make sense but isn't implemented. For example, I'd like to make this work: RandomSample[3] @ Range[10] ...
M.R.'s user avatar
  • 31.5k
15 votes
2 answers
978 views

What is the best way to define Wirtinger derivatives

Wirtinger derivatives ( also called Cauchy operators) in complex analysis are widely used tools. They are defined in the case of one dimensional complex plane as follows $$\frac{\partial}{\partial z}=...
Aymane Fihadi's user avatar
14 votes
2 answers
597 views

How I can define this operator in Mathematica?

I want to define an operator $G$ such that $$G(f):=\begin{cases}f(\{x\}),&\lfloor x\rfloor\text{ is even}\\\frac1{f(\{x\})},&\lfloor x\rfloor\text{ is odd}\end{cases}$$ for any function $f$, ...
Masacroso's user avatar
  • 1,107
13 votes
13 answers
2k views

How to find range in which a number falls, from given list of numbers?

How can one find the range in which a number falls, from given list of numbers? ...
Prashant Bhate's user avatar
11 votes
3 answers
6k views

Using D to find a symbolic derivative

I need to do the following: Define a function Take the derivative of this function and have a look at the symoblic representation Substitute in some values With the bonus that I want to use the ...
C. E.'s user avatar
  • 70.6k
11 votes
4 answers
671 views

Change Operator Precedence of --> operator

I am trying to use --> operator with highest precedence ...
Neel Basu's user avatar
  • 961
11 votes
3 answers
2k views

Replace operators

/. can be used to replace variables but how can one replace operators. For example in a * b, ...
Pankaj Sejwal's user avatar
11 votes
2 answers
12k views

Defining quantum-mechanical Bra and Ket operations

I have the following ket in the Fock basis: $\vert3, 0 ,1\rangle$, where each entry defines the number of photons in a particular mode and can take any one of the following numbers: 0, 1, 2, 3. As a ...
Sid's user avatar
  • 977
11 votes
2 answers
209 views

How to make a function with two patterns listable?

Suppose that I have a function that has two patterns: disksConstantRadius[radius_][points_] := Disk[#, radius] & /@ points (noting that this would be better---...
Craig Carter's user avatar
  • 4,415
11 votes
2 answers
338 views

Why `Drop` and `Take` do not support a operator form

Since Mathematica 10 introduced the operator form, I have been a big fan of it. Whenever I use some buit-in functions, I first look up whether they support operator form. To me, it was quite ...
Sungmin's user avatar
  • 2,285
11 votes
1 answer
17k views

Difference between = and := [duplicate]

I wanted to know the difference between two operators: = and := I couldn't find the ":=" operator on the list at https://reference.wolfram.com/language/tutorial/Operators.html Can someone help? ...
André's user avatar
  • 111
10 votes
3 answers
534 views

Operate over list of pure functions

I have list of pure functions (All functions are InterpolatingFunction) i.e {{a, b}, {c, d}, {e, f}, ...} and I would like ...
rhermans's user avatar
  • 36.5k
10 votes
4 answers
468 views

Operator currying: how to convert f[a,b][c,d] to {a+c,b+d}?

This question is related to this golfing question (but I'm not interested in golfing, only in functional operator composition): How can we convert f[a,b][c,d] to <...
Roman's user avatar
  • 47.5k
10 votes
2 answers
5k views

How do I expand a sum?

I have a problem with Mathematica's symbolic manipulations. As an example, consider the following expression: $$\sum _{i=1}^n -2 x_i \left(-a x_i-b+y_i\right)=0$$ How do I get Mathematica to expand ...
Misery's user avatar
  • 2,640
10 votes
1 answer
459 views

Question about Rules and Pattern (The operator patt/;test)

Maybe this question is so trivial but it has confused me. I'm studying the What the @#%^&*?! do all those funny signs mean? and in the Rules and patterns under ...
Sepideh Abadpour's user avatar
10 votes
2 answers
512 views

Which operators are missing from the official precedence table?

I often use the Operator Input Forms page as a reference for operator precedence as well as which (used or unused) operators exist. However, I just noticed that at least one operator is missing from ...
Martin Ender's user avatar
  • 8,774
10 votes
2 answers
486 views

Change associativity of the @ operator

The @ operator in Mathematica is right-associative by default, i.e. f@g@h evaluates as f@(g@h) Is it possible to make the ...
sakra's user avatar
  • 5,120
10 votes
1 answer
577 views

Define multilinear operator

In Maple it is possible to define a multilinear, orderless operator with: define(A,'orderless',multilinear): I can't seem to find the equivalent in Mathematica. ...
simon's user avatar
  • 127
10 votes
2 answers
2k views

Defining the Moyal Product in Mathematica

What would be the best way to define the Moyal Product, $f(x,p)\star g(x,p)$, in Mathematica? $f(x,p)\star g(x,p)$ may be written as $f\star g=\sum\limits_{n=0}^{\infty}\frac{1}{n!}\left(\frac{i\hbar}...
user85503's user avatar
  • 992
10 votes
1 answer
226 views

Using MapIndexed[List] on a dataset fails -- why?

The following works: MapIndexed[List]@{1, 2, 3} (* {{1, {1}}, {2, {2}}, {3, {3}}} *) This works too: ...
Szabolcs's user avatar
  • 235k
9 votes
1 answer
1k views

Define an operator with the distributive property

I would like to define the operator with distributive, associative, and commutative properties - so that Mathematica can symbolically simplify expressions I use ...
Elaeum's user avatar
  • 111
9 votes
1 answer
223 views

Position-based Inline syntax for Curry

I would like to update an existing pseudo-curry function: • /: h_[pre___, •, post___] := Function[expr, h[pre, expr, post]]; that I use inline like this - the ...
alancalvitti's user avatar
  • 15.1k
8 votes
7 answers
2k views

Can I use == to compare two list element wise?

I have the following lists Y and EY with actual and estimated outcomes. ...
M.E.'s user avatar
  • 333
8 votes
3 answers
805 views

Redefining a built-in operator

Is there a way I can redefine the || operator such that a||b will be 1/(1/a + 1/b)? Is it ...
Omegaman's user avatar
  • 279
8 votes
3 answers
5k views

Creating the Nabla operator (also known as Del operator) as an operator

How can I define the nabla operator (also known as Del operator) as a an operator, acting on everything to the right of the operator! Also taking \[Del]^2 would ...
TehHO's user avatar
  • 109
8 votes
2 answers
322 views

How can I define operators that implement the algebra of sets?

I need to define some operators with properties like idempotence and distribution over union and intersection so that Mathematica can symbolically simplify expressions. How do I define such operators? ...
Tarun Gupta's user avatar
8 votes
2 answers
9k views

How to find (numerical) value of a derivative at point?

I have the following function: f[0, 0] = 0 f[x_, y_] := Exp[-(x^2 + y^2)^(-1)] How do I find its partial derivatives at any given point, including $(0,0)$? This ...
mbork's user avatar
  • 949
8 votes
1 answer
564 views

Products of Differential Operators

I have a differential equation defined as the product of operators which I want to expand out into a polynomial in powers of $z\frac{d}{dz}$ $\qquad \prod_{n=1}^p(z\frac{d}{dz}+a_n)$ However when I ...
Jack's user avatar
  • 135
7 votes
5 answers
1k views

How to write an operator that acts on pure function (to give another pure function)

I would like to write an operator oper that acts on a pure function f with an undetermined number of arguments, with the syntax <...
QuantumDot's user avatar
  • 19.7k
7 votes
3 answers
516 views

Iterated differential operator

I would like to implement the following differential operator in Mathematica, $$ \prod_{j=1}^n \left({\mathrm d \over \mathrm d x}-j\right) $$ On a case by case basis, I can just expand it out and ...
B. Erenu's user avatar
7 votes
6 answers
464 views

Applying several functions to the same argument

Is there a more concise way of achieving the following result (possibly without d |->)? ...
azerbajdzan's user avatar
  • 16.7k
7 votes
2 answers
3k views

How to change coordinates of a differential operator?

I'm doing a basic quantum mechanics problem and am trying to learn how to do it in Mathematica. Any help would be much appreciated. $\vec{L} = \vec{x} \times \vec{p}$ where $\vec{x}$ has components:...
TaylorR137's user avatar
7 votes
3 answers
4k views

How to define the Poisson bracket in Mathematica

If $f,g$ are functions of the independent variables $\{q_1, q_2, ..., q_N, p_1, p_2, ..., p_N\}$, then the Poisson bracket is defined as: \begin{equation*} [f, g] = \sum_{i=1}^N \left(\frac{\partial ...
stathisk's user avatar
  • 3,054
7 votes
2 answers
834 views

Defining an operator in Mathematica?

How to define the following operator in Mathematica? $$\hat{\nabla}^4=\left(\frac{\partial^2}{\partial\hat{r}^2}+\frac1{\hat{r}}\frac{\partial}{\partial\hat{r}}\right)^2$$
Nishta's user avatar
  • 71
7 votes
2 answers
1k views

How to make a binary function associative? (Or define an n-ary function?)

Suppose I have a simple function that I assign to an operator f[a_, b_] := a + b CirclePlus = f Then I want to write ...
Noon Silk's user avatar
  • 523
7 votes
2 answers
390 views

HoldForm[Operator ##] on some list

Recently in response to this question Mr.Wizard suggested an unusual way to summing numbers. This doesn't seem to be documented. ...
Pankaj Sejwal's user avatar
7 votes
1 answer
464 views

What operator is this?

I was looking at some sample code in a YouTube video and saw an "operator" (not sure this is the right term) consisting of a horizontal bar with circles on the ends. I searched through the ...
Robert McCormick's user avatar

1
2 3 4 5 6