online advertising

Thursday, May 7, 2015

Exploring Quantum Physics - The contraction identity

The proof of that identity is a straightforward verification, so here is the code that does the job for us.

Note in particular that the Einstein summation convention in action in the left hand side as $ i $ is a repeated index.

namespace ManagedWorkspace
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    internal static class Program
    {
        static int levi(int i, int j, int k)
        {
            int c = i * 100 + j * 10 + k;
            switch (c)
            {
                case 123: return 1;
                case 231: return 1;
                case 312: return 1;
                case 132: return -1;
                case 213: return -1;
                case 321: return -1;
            }
            return 0;
        }

        static int delta(int i, int j)
        {
            return i == j ? 1 : 0;
        }

        static void Main(string[] args)
        {
                for (int j = 1; j <= 3; j++)
                {
                    for (int k = 1; k <= 3; k++)
                    {
                        for (int s = 1; s <= 3; s++)
                        {
                            for (int t = 1; t <= 3; t++)
                            {
                                int lhs = 0;
                                for (int i = 1; i <= 3; i++)
                                {
                                    lhs += levi(i, j, k) * levi(i, s, t);
                                }
                                int rhs = delta(j, s) * delta(k, t) - delta(j, t) * delta(k, s);
                                if (lhs != rhs)
                                {
                                    Console.WriteLine("Error!");
                                }
                            }
                        }
                    }
                }
            }
        }
    }

No comments:

Post a Comment