Questions tagged [commutativity]

In mathematics, a binary operation is commutative if changing the order of the operands does not change the result. It is a fundamental property of many binary operations, and many mathematical proofs depend on it. The name is needed because there are operations, such as division and subtraction, that do not have it (for example, "3 − 5 ≠ 5 − 3"); such operations are not commutative, and so are referred to as noncommutative operations. The idea that simple operations such as the multiplication and addition of numbers are commutative, was for many years implicitly assumed.

Source: https://en.wikipedia.org/wiki/Commutative_property

61 questions
2
votes
2 answers

upper_bound With binary_function Visual Studio 2008 Bug?

1st of all, yes, I am stuck using Visual Studio 2008, and I believe this bug is specific to Visual Studio 2008. I'm trying to write a functor to compare just 1 member of my struct so I can do upper_bound on a vector of said structs which is sorted…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
2
votes
3 answers

A or B = B or A proof (natural deduction)

This problem feels like it should be simpler than I've made it so my ultimate question will be: is there a simpler way to do this? In logic we know that A v B = B v A But in natural deduction we use our v-Introductions, RAA, etc. to prove these…
K. Shea
  • 107
  • 1
  • 10
1
vote
1 answer

Homomorphic and non-commutative hash function?

Does a non commutative homomorphic hash function exist (or been researched/published)? LtHash developed by Facebook and implemented on Github here is the sort of function I am looking for, but LtHash commutes and I'd like to know if there is a non…
Tobias
  • 13
  • 3
1
vote
4 answers

Is the order of the equality operator important in Ruby?

I have used the bcrypt library in my Ruby program. I noticed that the order of the equality operator seems to be important. Depending on which variable is left or right of the '==' I get a different result. Here is an example program: require…
schande
  • 576
  • 12
  • 27
1
vote
2 answers

@lru_cache on function with commutative arguments

I am calculating the Hamming distance between 2 strings where Hamming(A,B) == Hamming(B,A) The function signature is @lru_cache def Hamming(A:str,B:str)->int: ... How can I modify @lru_cache or the function to ignore argument order when…
Greedo
  • 4,967
  • 2
  • 30
  • 78
1
vote
1 answer

Are coalesce + orderBy commutative in Spark?

I want to run the following code: df = df.coalesce(1).orderBy(["my_col"]) but its execution will obviously bottleneck on a single task doing all the sort work. I know it's possible to run the following: df =…
vanhooser
  • 1,497
  • 3
  • 19
1
vote
1 answer

Why is convolve() not commutative? The end result depends on the order of the convolutions

Convolution is supposed to be commutative - the order of the operations should not matter. This example therefore creates three beta PDFs and then convolves them in three different orders. Convolutions 1 and 3 result in the same end function.…
nigewi
  • 11
  • 1
1
vote
1 answer

How should commutative operator overloads be efficiently implemented in C#?

Say I have a type Vector3 with an overloaded operator * allowing multiplication by a double: public readonly struct Vector3 { public double X { get; } public double Y { get; } public double Z { get; } public Vector3f(double x,…
1
vote
1 answer

Haskell: Usage of flip results in error: Equations for ‘.>’ have different numbers of arguments

I am struggling to understand what's going on here. I want to implement a data type Direction and define a commutative operator .> for it. So far I have this: data Direction = N | E | S | W | None (.>) :: Direction -> Direction -> [Direction] N .>…
rolly
  • 145
  • 9
1
vote
0 answers

Python iterate through unique commutative equations

Inspired by the math of this video, I was curious how long it takes get a number, n, where I can use the number, 1, and a few operations like addition and subtraction, in the binary base. Currently, I have things coded up like this: import itertools…
Zach Hunter
  • 169
  • 8
1
vote
1 answer

Commutativity of joins in SQL

There are a few discussions on StackOverflow of commutativity of joins, such as 1, 2, 3, and 4. It gets pretty complicated, and I don't think any of them answers my question here. I've often noticed that when I put the SQL for a query into Access,…
NewSites
  • 1,402
  • 2
  • 11
  • 26
1
vote
1 answer

Sympy: substitute to symbolic bosonic commutation its numerical value

I would like to simplify expressions involving boson commutators using sympy. The problem is that, using secondquant in sympy, the numerical values of the bosonic commutator [b_0,b^\dagger_0]=1 and [b_0,b^\dagger_1]=0 is never substituted to the…
Chaos
  • 199
  • 1
  • 13
1
vote
2 answers

Julia-lang comparison of expression and commutativity

OK my title isn't great but it's easily explainable with an example. julia>a = :(1 + 2) julia>b = :(2 + 1) julia>a == b false I have two expressions a and b. I would like to know if they will give me the same results without being evaluated. I…
Thomas Jalabert
  • 1,344
  • 9
  • 19
1
vote
1 answer

The derivative of the product of non-commutative functions

If I use functions in SymPy and call the diff method, the commutative property just gets ignored. h = Function('h',real=True,commutative=False)(t) R = Function('R',real=True,commutative=False)(t) print(diff(R*h,t)) # returns: R(t)*Derivative(h(t),…
mike
  • 791
  • 11
  • 26
1
vote
1 answer

Understanding functor laws: is this a functor?

The following code is written in javascript. This question involves an attempt to dive into some category theory, maybe a haskeller or someone more familiar with the mathematical aspects of this question can help me out? I'm trying to wrap my head…
MFave
  • 1,044
  • 2
  • 8
  • 19