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
65
votes
6answers
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 ...
63
votes
2answers
4k 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 ...
34
votes
3answers
778 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, ...
31
votes
6answers
5k 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 \...
25
votes
3answers
2k 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 ...
23
votes
11answers
2k 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 ...
20
votes
4answers
866 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, ...
17
votes
2answers
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 ...
15
votes
2answers
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\\ ...
14
votes
3answers
667 views
14
votes
2answers
445 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$, ...
13
votes
4answers
2k 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\...
13
votes
2answers
261 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] ...
12
votes
6answers
1k 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 ...
12
votes
13answers
1k 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? ...
12
votes
2answers
370 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}=...
11
votes
3answers
980 views

Replace operators

/. can be used to replace variables but how can one replace operators. For example in a * b, ...
10
votes
3answers
4k 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 ...
10
votes
3answers
461 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 ...
10
votes
2answers
3k 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 ...
10
votes
1answer
350 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 ...
10
votes
2answers
389 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 ...
10
votes
1answer
288 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. ...
10
votes
1answer
166 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: ...
9
votes
2answers
6k 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 ...
9
votes
2answers
248 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 ...
9
votes
2answers
1k 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}...
8
votes
4answers
508 views

Change Operator Precedence of --> operator

I am trying to use --> operator with highest precedence ...
8
votes
3answers
515 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 ...
8
votes
1answer
249 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 ...
8
votes
1answer
174 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 ...
7
votes
5answers
634 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 <...
7
votes
2answers
786 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 ...
7
votes
3answers
2k 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 ...
7
votes
2answers
331 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. ...
7
votes
3answers
2k 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 ...
7
votes
2answers
7k 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 ...
7
votes
1answer
612 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 ...
7
votes
1answer
502 views

How to construct custom operators with precedence?

I need to combine data structures in operations analogous to addition, subtraction, multiplication and division (and more). I need more than one operation of each type, i.e. more than one method of ...
6
votes
2answers
2k 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:...
6
votes
1answer
425 views

What is the mathematical meaning behind D[f]?

y = a + b x; I can understand this output of the ordinary differentiation of y w.r.t. x <...
6
votes
3answers
949 views

Computing with matrix differential operators

I am looking the achieve a working set of Mathematica functions that would allow me to take products, commutators, etc. of (2x2) matrix differential operators and apply them to vector-valued functions ...
6
votes
2answers
4k views

Why can't I define a commutator operator in this way?

I am trying to define some operators I use frequently. For example, I defined a KroneckerProduct operator as $\otimes $ as follows: ...
6
votes
1answer
1k views

Define operator algebra

My objective is to work out commutators like this $$[f(x,y)\partial_x^2+g(x,y)\partial_x+h(x,y),a(x,y)\partial_x^2+b(x,y)\partial_x+c(x,y)]$$ or $$[f(x,y)\partial_x^2+g(x,y)\partial_x+h(x,y),a(x,y)\...
5
votes
4answers
5k views

How to write a differential operator in Mathematica

I have a very basic question. I am trying to code the LHS of the differential equation: $$\Big[\frac{1}{\sin\theta}\frac{d}{d\theta}\big(\sin\theta\frac{d}{d\theta}\big)-\frac{m^2}{\sin^2\theta}+n(n+...
5
votes
1answer
1k views

I want to be able to define (a(x) d/dx + b(x))^n

I want to be able to define an operator $(a(x) d/dx + b(x))^n$ where $d/dx$ is the derivative operator and $a(x)$ and $b(x)$ are known functions and $n$ is a positive integer. Related Query: How ...
5
votes
2answers
256 views

Associativity of `/@` [duplicate]

Why are the following not equivalent: Map[Line, Map[(Print[#]; #) &, {{{2, 1}, {1, 1}}, {{-2, 1}, {3, 1}}}]] which produces ...
5
votes
3answers
529 views

ComplexInfinity/Indeterminate error when evaluating derivative

Motivation: I want to find the coefficients for the polynomial that is obtained when one adds together the first $n$ natural numbers to the power of $a$; that is, when you consider $1^{a} + 2^{a} + \...
5
votes
1answer
143 views

Associativity of upvalue

how can I ensure the following definition to be associative? Unprotect[Times]; a_ f[x_] + b_ f[y_] ^:= f[a x + b y] Protect[Times]; gives me ...
5
votes
1answer
278 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 <...