I am attempting to create creation and annihilation operator used in 2nd quantisation in quantum mechanics. I want to do this both numerically and symbolically. Here is the idea:

$n= {c^\dagger}c$

where ${c\dagger}$ is the creation operator and c is annihilation operator. The basic rules are: $ [{c^\dagger},c] = {c^\dagger}c+c{c^\dagger} = 1$

$[{c^\dagger},{c^\dagger}] = {c^\dagger}{c^\dagger}+{c^\dagger}{c^\dagger} = 0$

$[c,c] = cc+cc = 0$

Below is my listing for numerical approach:

clear all;close all;
matdimension = 3;
tempvector   = 0:1:matdimension
tempvector = sqrt(tempvector)
tempmatrix = diag(tempvector);
creation = circshift(tempmatrix,-1);
annihilation = creation';
% creation = circshift(diag(sqrt(0:1:mat_dim)),-1);
H3= H1 + H2
H4= H2 + H1;
H5= creation*creation + creation*creation;

And the output is :

tempvector = 0   1   2   3

tempvector = 0.00000   1.00000   1.41421   1.73205`

H3 =
    1.00000   0.00000   0.00000   0.00000
    0.00000   3.00000   0.00000   0.00000
    0.00000   0.00000   5.00000   0.00000
    0.00000   0.00000   0.00000   3.00000

1) Obviously something is wrong with my code since answer H3 should be equal to 1 which is not. What I am missing here?

2)Is it possible to create new math rules in matlab? ( I have commutation in mind [A,B]= ) I want to create the above code but do the symbolic calculation as well.

3)I managed to copy dagger symbol and paste it on matlab script, however the script will not compile. Is there a work around this?

  • 1
    $\begingroup$ I might be wrong, but this seems like a question for Stack Overflow. $\endgroup$ Mar 6 '17 at 2:12
  • 4
    $\begingroup$ I'm voting to close this question as off-topic because it is about writing/editing code and not physics. Stack Overflow or Computational Science would be better suited for this question. $\endgroup$
    – Kyle Kanos
    Mar 6 '17 at 12:45

The creation and anihilation operators you had written are for bosonic things, not ferminic things, because of that, the rule [c,c†]=c c† - c† c = 1, not {c, c†}= c c† + c† c = 1. Your code works well. try H3= H1 - H2 (you will see a little error asociated to the truncation of states (the -3)), H4 = H2 - H1, and H5 = creationcreation - creationcreation=0;

Creating functions works like this: you create a script with a code like

function [C] = brakets(A,B) C=AB-BA; end

I think that with this you will be happy, I hope. For fermionic things you need to create a different thing. If you want, I will tell you how.

The problem wasn't the program, it was the physics that you put'd on it.

Zorry If reading this was a pain in the a**. My native language is spanish.

  • $\begingroup$ Thanks for your valuable comments. I will look into this. Yes you are correct. If I use H3=H1-H2 , then it is almost correct except for that error you mentioned... I wonder if it is fixable. Yes, I want to know your approach to fermionic things. Again, thank you Uli_WH. $\endgroup$
    – Aschoolar
    Mar 7 '17 at 2:21
  • $\begingroup$ If you have a creation operator $A$ and an anihilation operator $A^\dagger$ for a fermionic system, then: $${A,A}=2AA=0$$ So, you don't have the state in wich you create two fermions. Your space for the ocupation state has only two states: $|0>$ and $|1>$ $\endgroup$
    – Uli_WH
    Mar 7 '17 at 23:49
  • $\begingroup$ Try matdimension equal to one. $\endgroup$
    – Uli_WH
    Mar 8 '17 at 0:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.