Skip to main content
19 votes
Accepted

How to implement ladder operators for the quantum harmonic oscillator?

Here is a simple implementation: ...
glS's user avatar
  • 7,663
17 votes

How to find constant term of binomial

Coefficient[(-2*x^4 - 5/x)^25, x, 0] (* -162139892578125000000 *)
Roman's user avatar
  • 48.3k
11 votes
Accepted

How to specify algebraic relations between objects?

There are different ways to go about doing this. I'll set UpValues on e for the multiplication of the basis vectors as you've ...
march's user avatar
  • 23.9k
11 votes

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

Here is one idea. Convert the set expression into an equivalent boolean expression, use BooleanMinimize to simplify the boolean expression, and then convert back to ...
Carl Woll's user avatar
  • 131k
10 votes
Accepted

Implement abstract algebraic structure

I decided it was worth giving another example of modern OOP in Mathematica. There will be a small amount of code, but almost all of it is boiler-plate. I use a package to handle most of the boiler ...
b3m2a1's user avatar
  • 46.9k
10 votes
Accepted

Present a logarithm in terms of two logarithms

There doesn't seem to be a single built-in function for the task, but I can think out a solution involving a bit manual analysis. First use PowerExpand: ...
xzczd's user avatar
  • 67k
10 votes
Accepted

Why is the result of TrueQ[(x^n)^m == x^(n*m)] False?

The answer is that you did not feed to Mathematica any assumptions. Check for example FullSimplify: ...
bmf's user avatar
  • 16.1k
9 votes
Accepted

Symbolic calculation on roots of polynomial

I upvoted the other responses. That said, there is a better way. ...
Daniel Lichtblau's user avatar
9 votes
Accepted

Subtracting equations from each other?

An easy way to munge equations is to convert them to lists and then convert them back to equations when you are done munging. In your case, like so: ...
m_goldberg's user avatar
  • 108k
9 votes
Accepted

Removing higher order terms

You can use a variation of the idea I gave here: Normal @ Series[ ss /. {f:u1|u2 -> (s f[#1,#2,#3,#4]&)}, {s, 0, 3} ] /. s->1 u2[x, y, z, t]^...
Carl Woll's user avatar
  • 131k
9 votes
Accepted

Simplifying simple signed expression ( such as $-x(x-1) \to x(1-x)$ ) based on assumptions

You can use ComplexityFunction option to "penalize" the number of terms with a negative sign: ...
kglr's user avatar
  • 398k
9 votes
Accepted

How to implement split-complex numbers?

Try this: J /: Power[J, p_Integer?OddQ] := J J /: Power[J, p_Integer?EvenQ] := 1 J^Range[-10, 10] {1, J, 1, J, 1, J, 1, J, 1, J, 1, J, 1, J, 1, J, 1, J, 1, J, ...
Henrik Schumacher's user avatar
9 votes

Zassenhaus formula in Mathematica

Here is my old implementation based on M.WEYRAUCH, D.SCHOLZ, COMPUTER PHYSICS COMMUNICATIONS, 180, (2009), 1558-1565 Returns 'unfolded' or 'folded' (in terms of commutators): ...
I.M.'s user avatar
  • 3,051
9 votes

Why is the result of TrueQ[(x^n)^m == x^(n*m)] False?

$Version (* "13.3.1 for Mac OS X ARM (64-bit) (July 24, 2023)" *) Clear["Global`*"] Use FindInstance to ...
Bob Hanlon's user avatar
  • 160k
8 votes

KroneckerDelta does not automatically simplify

Use PiecewiseExpand R[a_, b_] := KroneckerDelta[a, b] KroneckerDelta[a, b] // PiecewiseExpand R[a, b] ...
Bob Hanlon's user avatar
  • 160k
8 votes
Accepted

Turn single fraction into multiple fraction expression

Something like this? (F1/F2 /. c/f -> Defer[c/f]) /. aa_*bb_Defer -> Defer[aa]*bb (* Out[15]= c/f (d e)/(g h i k) *) Reordering will require a different ...
Daniel Lichtblau's user avatar
8 votes
Accepted

Symbolic calculation with generators and relations

Edit. Based on the comments, here is a more concrete answer to what I think you'd like. My previous answer can be found below. Defining a ring symbolically. Let's consider some ring (or algebra) ...
Jules Lamers's user avatar
  • 1,104
8 votes
Accepted

Check if polynomial is in factored form, without factoring

You can check whether the Head of the expression is Plus, which is associated with a non-factored polynomial: ...
MarcoB's user avatar
  • 67.4k
8 votes
Accepted

ReplaceAll for expressions involving negative power

Try 1 + 1/x + 2/x^2 - 3/x^3 /. Power[x, i_] -> f[-i] (*1 + f[1] + 2 f[2] - 3 f[3]*)
Ulrich Neumann's user avatar
7 votes
Accepted

Hadamard Lemma and commutators algebra

One should really use commutator rather than Commutator for future-proofing concerns, but I have some bad habits... ...
evanb's user avatar
  • 6,151
7 votes

Factorization of a polynomial fraction to a certain combinations of other polynomial fractions

Rewriting your definitions slightly ...
Sander's user avatar
  • 1,876
7 votes

Subtracting equations from each other?

I'm going to guess that your actual goal here is to eliminate one of the terms shared by the two equations. In that case, you could also use Eliminate: ...
Jens's user avatar
  • 97.4k
7 votes
Accepted

Normal ordering in Mathematica

Represent a string of field operators a[k]$\equiv\hat{a}(k)$ and ad[k]$\equiv\hat{a}^\dagger(k)$sandwiched between the ground ...
QuantumDot's user avatar
  • 19.7k
7 votes
Accepted

Factoring expression with rational powers

How about that ...
Akku14's user avatar
  • 17.3k
7 votes
Accepted

How to get the extension degree

You can use ToNumberField to do this: ...
Carl Woll's user avatar
  • 131k
7 votes

Move variables to one side of equation

tran = SubtractSides[SubtractSides[#], First@CoefficientArrays[#]] &; eqn=x[1] == 5012 - 5x[3] - 2x[4] + 5x[7]; tran[eqn] ...
cvgmt's user avatar
  • 76.6k
7 votes
Accepted

How to get the analytical form of a solution to an algebraic equation?

Using answer in Solving quintic in radicals QuinticToRadicals[sol[[1]]] gives Full code (see post above) ...
Nasser's user avatar
  • 146k
7 votes
Accepted

PolynomialQ behaviour

We can use PolynomialExpressionQ, which has an optional 3 argument that allows us force the coefficients to be explicitly numeric: ...
Greg Hurst's user avatar
  • 36.3k
6 votes
Accepted

How to make `D` apply chain rule on user-defined symbols as it does on `Dot` and `NonCommutativeMultiply`

By default, Mathematica always differentiates function heads that contain the independent differentiation variables, unless the function head is listed in the "DifferentiationOptions"->"...
Carl Woll's user avatar
  • 131k
6 votes

How to specify algebraic relations between objects?

There is a new paclet for doing Geometric Algebra: PacletInstall["https://wolfr.am/N9OenlOc"] << GeometricAlgebra`; You can construct multivectors of any ...
swish's user avatar
  • 7,921

Only top scored, non community-wiki answers of a minimum length are eligible