0% found this document useful (0 votes)
18 views21 pages

Day 1 - Lecture - Mathematica 101 - 0 - 0

Uploaded by

Hosayn Chibani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views21 pages

Day 1 - Lecture - Mathematica 101 - 0 - 0

Uploaded by

Hosayn Chibani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

2

Basic input

Ÿ 1) Notebook Shortcuts

Shift + Enter : evaluate expression

2+2

Ctrl + ’ : toggle cell groups open/closed


F12 : Full Screen

Ÿ 2) Formula input

Ctrl + /

ƒ
ƒ

Ctrl + 2

Ctr + Enter, Ctr + ,

ƒ ƒ ƒ
ƒ ƒ ƒ
ƒ ƒ ƒ

Ÿ 3) Symbols

Esc + ? + Esc:

H* a *L Α
H* inf *L ¥
H* \ell *L { ;

Ÿ 4) Help

Ctr + K : Auto-complete
Ctr + Shift + K : Hint for arguments

NI

? : To get immediate help


Day 1 - Lecture - Mathematica 101_0.nb 3

? NIntegrate

NIntegrate@ f , 8x, xmin , xmax <D gives a numerical approximation to the integral à
xmax
f dx.
xmin

NIntegrate@ f , 8x, xmin , xmax <, 8y, ymin , ymax <, D

gives a numerical approximation to the multiple integral à dxà


xmax ymax
dy … f. ‡
xmin ymin

?? NIntegrate

NIntegrate@ f , 8x, xmin , xmax <D gives a numerical approximation to the integral à
xmax
f dx.
xmin

NIntegrate@ f , 8x, xmin , xmax <, 8y, ymin , ymax <, D

gives a numerical approximation to the multiple integral à dxà


xmax ymax
dy … f. ‡
xmin ymin

Attributes@NIntegrateD = 8HoldAll, Protected<

Options@NIntegrateD = 8AccuracyGoal ® ¥, Compiled ® Automatic, EvaluationMonitor ® None,


Exclusions ® None, MaxPoints ® Automatic, MaxRecursion ® Automatic, Method ® Automatic,
MinRecursion ® 0, PrecisionGoal ® Automatic, WorkingPrecision ® MachinePrecision <

? *Integrate

System‘

Integrate NIntegrate

? *Bessel*

System‘

BesselI BesselJZero BesselY SphericalBesselJ


BesselJ BesselK BesselYZero SphericalBesselY

Ÿ 5) Selecting and checking expressions

Ctr + . : Select more and more

Sin@1 + Sin@1 + x + Cos@yDDD

Ctr + Shift + B : To match baskets

8Sin@1 + Sin@1 + x + Cos@yDDD, Tan@xD<

Ÿ 6) Stop evaluation

Alt + . : Stop the evaluation


4

1 + F@xD . F@a_D ® F@F@aDD

Ÿ 7) Advanced

It is possible to introduce your own shortcut by editing


MenuSetup.tr
Add the following line to add
Ctr+Shift+c : select active cell

Item["Select &Cell",FrontEndExecute[
Module[{Set[nb,InputNotebook[]]},
SelectionMove[nb,All,Cell];]
],MenuKey["c", Modifiers->{Shift, Control}], MenuEvaluator->Automatic],
Day 1 - Lecture - Mathematica 101_0.nb 5

Syntaxes

Ÿ 1) = and :=

There are two ways to assign the r.h.s.


= and :=
It is very important to feel the difference!

a = 1;
F1@x_D = x + a;
F2@x_D := x + a;

= immediately evaluates r.h.s. and then result is assigned to l.h.s.


:= the r.h.s. will be evaluated each time we use the function

8F1@ΠD, F2@ΠD<

81 + Π, 1 + Π<

Now we change a

a = 2;
8F1@ΠD, F2@ΠD<

81 + Π, 2 + Π<

To make it even more clear

a = 1;
F1@x_D = HPrint@"F1::I am evaluated"D; xL;
F2@x_D := HPrint@"F2::I am evaluated"D; xL;

F1::I am evaluated

F1@1D

F2@1D

F2::I am evaluated

Since := forces Mathematica to look into the r.h.s. we can apply additional conditions.
That is done using /;

a := b ; b > 0
a := Print@"b ise negative!!!"D ; b < 0

Ÿ 2) == and ===
6

2) == and ===

81 == 1, 1 == 2<

8True, False<

81 === 1, 1 === 2<

8True, False<

but!

8a Š b, a === b<

8a Š b, False<

Ÿ 3) Logical operations

"And" , "Or" , "Not"

True && False


True ÈÈ False
Not@TrueD

Ÿ 4) Substitutes (/. and //. ) (® and ¦)

Substitutes are very important.


Many calculations could be performed very efficiently be using them

. x ® Zeta@3D
x
x^2 + 1

Zeta@3D

1 + Zeta@3D2

There are several variants of substitute

H1 + x H1 + x H1 + xLLL . 1 + x ® 1

1 + x H1 + xL

H1 + x H1 + x H1 + xLLL . 1 + x ® 1

Ÿ
Day 1 - Lecture - Mathematica 101_0.nb 7

? //.

expr . rules repeatedly performs replacements until expr no longer changes. ‡

Similar to = and := one should clearly distinguish ® and ¦


® r.h.s. is immediately evaluated
¦ r.h.s. will be evaluated each time when the substitute applied

H1 + ΠL * 2 - 2 - 2 Π
ExpB1 - F . Exp@a_D ® Exp@Simplify@aDD
Π

-2-2 Π+2 H1+ΠL


1-
ã Π

H1 + ΠL * 2 - 2 - 2 Π
ExpB1 - F . Exp@a_D ¦ Exp@Simplify@aDD
Π

Ÿ 5) Apply Function (//, @ , /@ and @@)

F1@x_D = x + 1;

Usual form

F1@ΠD

1+Π

Another convenient way: no brackets

Π  F1

1+Π

F1 ž Π

1+Π

They have different priority. First the functions with @ are applied.

G@g2 ž g1 ž Π  f1  f2D

G@f2@f1@g2@g1@ΠDDDDD

When we want to apply something to each term in some expression we use /@


8

Sin ž Hx + x ^ 2 + x ^ 3 + x ^ 4L

Sin@xD + SinAx2 E + SinAx3 E + SinAx4 E

F ž 88x, 8y, z<<, b<

8F@8x, 8y, z<<D, F@bD<

Somehow different operations is @@. It replaces Head of the expresion

G žž F@1, 2, 3, 4D

G@1, 2, 3, 4D

Plus žž F@1, 2, 3, 4D

10

Plus žž 81, 2, 3, 4<

10

Ÿ 6) Recursions and Functions with memory

We want to solve an equation


f(x)=Exp[-x2 ] + Ú
f HkL
Cosh@x-kD
we can try to solve it by iterations
fn-1 HkL
fn (x)=Exp[-x^2]+Ú
f0 HxL = 0
Cosh@x-kD

f@0, x_D = 0;

, 8k, - 10, 10<F


f@n - 1, kD
Cosh@x - kD  N
f@n_, x_D := Exp@- x ^ 2D + SumB

f@5, 1D  Timing

822.5019, 33.4025<

To make it much faster let us make f to memorize its values.


It is very simple to do!

Clear@fD;
f@0, x_D = 0;

, 8k, - 10, 10<F


f@n - 1, kD
Cosh@x - kD  N
f@n_, x_D := f@n, xD = Exp@- x ^ 2D + SumB
Day 1 - Lecture - Mathematica 101_0.nb 9

f@5, 1D  Timing

80.011858, 33.4025<
10

Patterns

Ÿ 1) Basic usage

Patterns are one of the most important ingredients in the Mathematica!!!

Patterns are used throughout Mathematica to represent classes of expressions. A simple example of a pattern is the
expression f@x_D. This pattern represents the class of expressions with the form f@anythingD.

f@1D + f@ΠD . f@x_D ® x ^ 2

1 + Π2

ex = Sin@xD HSin@xD + Cos@2 xD + 6 Sin@xD + Sin@xD Cos@yDL HSin@xD + 12 Sin@3 xDL;

Collect@ex, Sin@_DD

H7 + Cos@yDL Sin@xD3 + 12 Cos@2 xD Sin@xD Sin@3 xD + Sin@xD2 HCos@2 xD + H84 + 12 Cos@yDL Sin@3 xDL

FreeQ@ex, Sin@_DD

False

FreeQ@ex, Tan@_DD

True

MatchQ@ex, Sin@xD a_D

True

Ÿ 2) Simple examples

f@n_D f with any argument


f@n_, m_D f with two arguments
x ^ n_ x to any power, with the power
x_ ^ n_ any expression to any power
a_ + b_
8a1_, a2_<
a sum of two expressions
a list of two expressions
f@n_, n_D f with two identical arguments

h@8x_, y_<D := x ^ y
Day 1 - Lecture - Mathematica 101_0.nb 11

h@1, 2D

h@1, 2D

h@8Sin@xD, 3<D

Sin@xD3

Ÿ 3) "x_", "x_." and "x_:y"

8b, b ^ 2, b ^ 3< . b ^ n_ ® P@nD

8b, P@2D, P@3D<

To understand why it is not working for the first element we


should see how the thing are looking like
inside Mathematica. We use FullForm

FullForm@8b, b ^ 2, b ^ 3<D

List@b, Power@b, 2D, Power@b, 3DD

In some cases to fix this problem one can use n_.

8b, b ^ 2, b ^ 3< . b ^ In_.M ® P@nD

8P@1D, P@2D, P@3D<

Which is a particular case of n_:p

? _.

p : v is a pattern object which represents an expression of the form p, which, if omitted, should be replaced by v. ‡

Pattern of the form n_:p is very good to define functions


with optional arguments

f@x_, y_: 0D := 8x, y<

f@ΠD

8Π, 0<

f@Π, 1D

8Π, 1<

Ÿ 4) Specifying types and condition


12

4) Specifying types and condition

To restrict the type of the expression to be Integer

g@n_IntegerD := Hn - 1L !

H*we define conditioning function*L


MyQ@a_D := Ha < 5L

H*and then use in inside the pattern*L


h0@n_ ? MyQD := Hn - 1L !

Or a bit different syntaxes

h1@n_ ; MyQ@nDD := Hn - 1L !
h2@a bD := p@n_, m_D := Hn + m - 1L ! ; MyQ@n m D

Ÿ 5) Many arguments

f[x_] - function with one argument


f[x_ _] - function with one argument or more
f[x_ _ _] - function with one argument or more or none

f1@x_D = 8x<;
f2@x__D = 8x<;
f3@1, x___D = 81, x<;

Using that one can define the following sophisticated object

h@a___, x_, b___, x_, c___D := hh@xD h@a, b, cD

h@1, 2, 3, 2, 4D

h@1, 3, 4D hh@2D

h@1, 2, 1, 2, 4D

h@4D hh@1D hh@2D

Ÿ 6) Examples

This deletes all integers appearing at any level.

DeleteCases@83, 4, x, 2 + x ^ Π, 3 + x ^ 2<, _Integer, ¥D

8x, xΠ , x<

This finds all ways that the sum can be written in two parts.
Ÿ
Day 1 - Lecture - Mathematica 101_0.nb 13

H*returns a list of all possibilities to *L


ReplaceList@a + b + c, x_ + y_ -> g@x, yDD

8g@a, b + cD, g@b, a + cD, g@c, a + bD, g@a + b, cD, g@a + c, bD, g@b + c, aD<

Sometimes it is convenient to name the pattern to use in rhs of substitute or in the definition of the function

H*only when the argument is Sin of something the function is defined*L


f@x : Sin@_DD = x ^ 2;

It is easy to combine several alternative patterns

H*for x integer or List we define the function*L


h@x : _Integer _ListD := x ^ 2
14

Most used functions

Ÿ 1) Simplify, FullSimplify

Simplify@Exp@I ΦD + Exp@- I ΦDD

ã-ä Φ + ãä Φ

FullSimplify @Exp@I ΦD + Exp@- I ΦDD

2 Cos@ΦD

Making assumptions

SimplifyB - x ^ 2 Hy ^ 2 + 1L z ^ 2 , x > 0 && z < 0F

-x - 1 - y2 z

Simplify@Exp@I Π nD, n Î IntegersD

H- 1Ln

Simplify@Exp@a + b + c + dD, a + b + c Š 1D

ã1+d

Some usefull options:

FullSimplify AHx + 1L ^ 2 - 4 x + x ^ 2, ExcludedForms ® 9I_PlusM ^ _=E

H- 4 + xL x + H1 + xL2

Simplify@4 Sin@xD ^ 2 Cos@xD ^ 2 + 4 Sin@xD Cos@xD + 1, Trig ® FalseD

H1 + 2 Cos@xD Sin@xDL2

Simplify@4 Sin@xD ^ 2 Cos@xD ^ 2 + 4 Sin@xD Cos@xD + 1D

HCos@xD + Sin@xDL4
Day 1 - Lecture - Mathematica 101_0.nb 15

Ÿ 2) Factor, Expand

Factor@x ^ 10 - 1D

H- 1 + xL H1 + xL I1 - x + x2 - x3 + x4 M I1 + x + x2 + x3 + x4 M

%  Expand

- 1 + x10

Some usefull options for Factor:

Factor@x ^ 8 - 1D

H- 1 + xL H1 + xL I1 + x2 M I1 + x4 M

Factor@x ^ 8 - 1, Extension ® 8I<D

H- 1 + xL H- ä + xL Hä + xL H1 + xL I- ä + x2 M Iä + x2 M

FactorBx ^ 8 - 1, Extension ® :I, I >F

IH- 3 - 2 äL H- 1L14 + 2 H- 1L34 - 3 xM IH- 1L34 - xM H- 1 + xL


1
9
H- ä + xL Hä + xL H1 + xL IH- 1L34 + xM IH- 3 - 2 äL H- 1L14 + 2 H- 1L34 + 3 xM

res = FullSimplify ž FactorBx ^ 8 - 1, Extension ® :I, I >F

IH- 1L34 - xM H- 1 + xL H- ä + xL Hä + xL H1 + xL IH- 1L14 + xM IH- 1L34 + xM I- 3 H- 1L14 + 3 xM


1
-
3

Some usefull options for Factor:

Expand@Ha@1D + a@2DL Hx@1D + x@2DL ^ 2, x@_DD

Ha@1D + a@2DL x@1D2 + 2 Ha@1D + a@2DL x@1D x@2D + Ha@1D + a@2DL x@2D2

Ÿ 3) Collect

a = Sin@xD ^ 10 + Sin@2 xD ^ 5  TrigToExp

Iã-ä x - ãä x M
10

ä Iã-2 ä x - ã2 ä x M
1 5
- +
1024 32
16

Collect@a, Exp@_DD

63 105 5ä 105 5ä 15 15 45 5ä
- - ã-2 ä x - + ã2 ä x + ã-4 ä x + ã4 ä x - + ã-6 ä x -
256 512 16 512 16 128 128 1024 32
45 5ä 5 5 1 ä 1 ä
- ã6 ä x + ã-8 ä x + ã8 ä x - - ã-10 ä x - + ã10 ä x
1024 32 512 512 1024 32 1024 32

b = Sin@yD ^ 2 + Sin@2 yD  TrigToExp

1 1 ä 1 ä
- - ã-2 ä y - + ã2 ä y
2 4 2 4 2

Collect@a b, 8Exp@a_ xD, Exp@a_ yD<D

63 63 63 ä 63 63 ä
- - ã-2 ä y - + ã2 ä y +
512 1024 512 1024 512
105 5ä 425 25 ä 215 185 ä
ã2 ä x - - + - ã-2 ä y - - ã2 ä y +
1024 32 2048 1024 2048 1024
45 5ä 365 35 ä 275 125 ä
ã-6 ä x - - + + ã-2 ä y - - ã2 ä y +
2048 64 4096 2048 4096 2048
15 15 15 ä 15 15 ä
ã-4 ä x - - ã-2 ä y - + ã2 ä y +
256 512 256 512 256
15 15 15 ä 15 15 ä
ã4 ä x - - ã-2 ä y - + ã2 ä y +
256 512 256 512 256
1 ä 65 15 ä 63 17 ä
ã10 ä x - - + + ã-2 ä y - - ã2 ä y +
2048 64 4096 2048 4096 2048
5 5 5ä 5 5ä
ã-8 ä x - - ã-2 ä y - + ã2 ä y +
1024 2048 1024 2048 1024
5 5 5ä 5 5ä
ã8 ä x - - ã-2 ä y - + ã2 ä y +
1024 2048 1024 2048 1024
1 ä 63 17 ä 65 15 ä
ã-10 ä x - + - + ã-2 ä y + - ã2 ä y +
2048 64 4096 2048 4096 2048
45 5ä 275 125 ä 365 35 ä
ã6 ä x - + - + ã-2 ä y + - ã2 ä y +
2048 64 4096 2048 4096 2048
105 5ä 215 185 ä 425 25 ä
ã-2 ä x - + - + ã-2 ä y + + ã2 ä y
1024 32 2048 1024 2048 1024
Day 1 - Lecture - Mathematica 101_0.nb 17

Collect@a b, 8Exp@a_ xD, Exp@a_ yD<, ND

0.123047 - H0.0615234 - 0.123047 äL ã-2 ä y - H0.0615234 + 0.123047 äL ã2 ä y +


ã2 ä x IH- 0.102539 - 0.15625 äL + H0.20752 - 0.0244141 äL ã-2 ä y - H0.10498 - 0.180664 äL ã2 ä y M +
ã-6 ä x IH- 0.0219727 - 0.078125 äL + H0.0891113 + 0.0170898 äL ã-2 ä y - H0.0671387 - 0.0610352 äL ã2 ä y M +
ã-4 ä x I0.0585938 - H0.0292969 - 0.0585938 äL ã-2 ä y - H0.0292969 + 0.0585938 äL ã2 ä y M +
ã4 ä x I0.0585938 - H0.0292969 - 0.0585938 äL ã-2 ä y - H0.0292969 + 0.0585938 äL ã2 ä y M + ã10 ä x
IH- 0.000488281 - 0.015625 äL + H0.0158691 + 0.00732422 äL ã-2 ä y - H0.0153809 - 0.00830078 äL ã2 ä y M +
ã-8 ä x
I0.00488281 - H0.00244141 - 0.00488281 äL ã-2 ä y - H0.00244141 + 0.00488281 äL ã2 ä y M +
ã8äx
I0.00488281 - H0.00244141 - 0.00488281 äL ã-2 ä y - H0.00244141 + 0.00488281 äL ã2 ä y M + ã-10 ä x
IH- 0.000488281 + 0.015625 äL - H0.0153809 + 0.00830078 äL ã-2 ä y + H0.0158691 - 0.00732422 äL ã2 ä y M +
ã6äx
IH- 0.0219727 + 0.078125 äL - H0.0671387 + 0.0610352 äL ã-2 ä y + H0.0891113 - 0.0170898 äL ã2 ä y M +
ã-2 ä x IH- 0.102539 + 0.15625 äL - H0.10498 + 0.180664 äL ã-2 ä y + H0.20752 + 0.0244141 äL ã2 ä y M

Collect@a b, 8Exp@a_ xD, Exp@a_ yD<, Re@N@ðDD &D

0.123047 - 0.0615234 ã-2 ä y - 0.0615234 ã2 ä y + ã2 ä x I- 0.102539 + 0.20752 ã-2 ä y - 0.10498 ã2 ä y M +


ã-6 ä x I- 0.0219727 + 0.0891113 ã-2 ä y - 0.0671387 ã2 ä y M +
ã-4 ä x I0.0585938 - 0.0292969 ã-2 ä y - 0.0292969 ã2 ä y M +
ã4 ä x I0.0585938 - 0.0292969 ã-2 ä y - 0.0292969 ã2 ä y M +
ã10 ä x I- 0.000488281 + 0.0158691 ã-2 ä y - 0.0153809 ã2 ä y M +
ã-8 ä x I0.00488281 - 0.00244141 ã-2 ä y - 0.00244141 ã2 ä y M +
ã8 ä x I0.00488281 - 0.00244141 ã-2 ä y - 0.00244141 ã2 ä y M +
ã-10 ä x I- 0.000488281 - 0.0153809 ã-2 ä y + 0.0158691 ã2 ä y M +
ã6 ä x I- 0.0219727 - 0.0671387 ã-2 ä y + 0.0891113 ã2 ä y M + ã-2 ä x I- 0.102539 - 0.10498 ã-2 ä y + 0.20752 ã2 ä y M

Ÿ 4) Coefficient

a = Sin@xD ^ 10 + Sin@2 xD ^ 5  TrigToExp

Iã-ä x - ãä x M
10

ä Iã-2 ä x - ã2 ä x M
1 5
- +
1024 32

Coefficient@a, Exp@2 I xDD

105 5ä
- -
512 16

Coefficient@a, 8Exp@- 2 I xD, Exp@ 2 I xD, Exp@6 I xD<D

:- >
105 5ä 105 5ä 45 5ä
+ ,- - ,- +
512 16 512 16 1024 32
18

Coefficient@a, Exp@I xD, 80, - 2, 2, 6<D

: >
63 105 5ä 105 5ä 45 5ä
,- + ,- - ,- +
256 512 16 512 16 1024 32

Ÿ 5) Integrate

Indefinite integration is mush faster!

x
TimingBIntegrateB , xFF
x^2 + 1

:0.003425, 1 + x2 >

, 8x, a, b<F;F
x
TimingBIntegrateB
x^2 + 1

85.3159, Null<

If you know what you are doing it is better to define!

NSeries@a__D := Normal@Series@aDD;

MyIntegrate@f_, 8x_, x1_, x2_<D :=


Hif = Integrate@f, xD; NSeries@if, 8x, x2, 0<D - NSeries@if, 8x, x1, 0<DL

, 8x, a, b<FF
x
res = TimingBMyIntegrateB
x^2 + 1

:0.001689, - 1 + a2 + 1 + b2 >

:0., b2 + 1 - a2 + 1 >

But dont forget to check your results numericaly!

sb0 = 8a ® Random@D, b ® 6 + Random@D<;


res . sb0

, 8x, a, b<F . sb0


x
NIntegrateB
x^2 + 1

80.001689, 5.10018<

5.10018
Day 1 - Lecture - Mathematica 101_0.nb 19

Ÿ 6) Series

f@x_D = Log@1 + xD;


ser@x_D = Normal@Series@f@xD, 8x, 0, 10<DD

x2 x3 x4 x5 x6 x7 x8 x9 x10
x- + - + - + - + -
2 3 4 5 6 7 8 9 10

. x ® 10 ^ 8- 2, - 3, - 4<, 20F
f@xD - ser@xD
NB
x ^ 11

80.090083379115353394733 , 0.090825834427472531631 , 0.090900758344916923083 <


20

Example

Ÿ Gamma matrices

Problem : Order product of Γ matrises in some canonical order

ee = Γ@aD Ä Γ@cD Ä Γ@bD Ä Γ@dD;

1) we use "." for non-commutative product. That is not the only possibility.
One can use Ä or some of other symbols as well.

Clear@CircleTimesD;
SetAttributes @∆, OrderlessD;
SetAttributes @CircleTimes, 8Flat, OneIdentity<D;

H*order two gamma matrises if they are not*L


rule1 = Γ@a_D Ä Γ@b_D ¦ 2 ∆@a, bD - Γ@bD Ä Γ@aD ; Not@OrderedQ@8a, b<DD;
rule2 = Γ@a_D Ä Γ@a_D ¦ ∆@a, aD;

ee2 = ee . rule1

Γ@aD Ä H- HΓ@bD Ä Γ@cDL + 2 ∆@b, cDL Ä Γ@dD

To make Ä linear:

NumQ@∆@_, _D _ ? NumericQD = True;


NumQ@_D = False;
CircleTimes : Ia1_ + a2_M Ä a3_ := a1 Ä a3 + a2 Ä a3;
CircleTimes : a3_ Ä Ia1_ + a2_M := a3 Ä a1 + a3 Ä a2;
CircleTimes : Ia2_M Ä Ia3_M := a2 a3 ; NumQ@a2D ÈÈ NumQ@a3D;
CircleTimes : Ia1_ a2_M Ä a3_ := a1 Ha2 Ä a3L ; NumQ@a1D;
CircleTimes : a3_ Ä Ia1_ a2_M := a1 Ha3 Ä a2L ; NumQ@a1D;

Something more complicated

ex = Γ@dD Ä Γ@aD Ä Γ@cD Ä Γ@bD Ä Γ@dD Ä Γ@cD Ä Γ@aD;

ex2 = ex . 8rule1, rule2<  Expand

- 4 Γ@aD Ä Γ@cD Ä Γ@dD ∆@a, dD ∆@b, cD + 8 Γ@dD ∆@a, cD ∆@a, dD ∆@b, cD -


8 Γ@cD ∆@a, dD2 ∆@b, cD + 2 Γ@aD Ä Γ@bD Ä Γ@dD ∆@a, dD ∆@c, cD - 4 Γ@dD ∆@a, bD ∆@a, dD ∆@c, cD +
4 Γ@bD ∆@a, dD2 ∆@c, cD + 2 Γ@dD ∆@a, aD ∆@b, dD ∆@c, cD - 4 Γ@aD ∆@a, dD ∆@b, dD ∆@c, cD -
2 Γ@bD Ä Γ@cD Ä Γ@dD ∆@a, aD ∆@c, dD + 4 Γ@aD Ä Γ@cD Ä Γ@dD ∆@a, bD ∆@c, dD -
4 Γ@aD Ä Γ@bD Ä Γ@dD ∆@a, cD ∆@c, dD + 8 Γ@cD ∆@a, bD ∆@a, dD ∆@c, dD - 8 Γ@bD ∆@a, cD ∆@a, dD ∆@c, dD +
8 Γ@aD ∆@a, dD ∆@b, cD ∆@c, dD - 4 Γ@cD ∆@a, aD ∆@b, dD ∆@c, dD + 8 Γ@aD ∆@a, cD ∆@b, dD ∆@c, dD +
4 Γ@bD ∆@a, aD ∆@c, dD2 - 8 Γ@aD ∆@a, bD ∆@c, dD2 + 2 Γ@cD ∆@a, aD ∆@b, cD ∆@d, dD -
4 Γ@aD ∆@a, cD ∆@b, cD ∆@d, dD - Γ@bD ∆@a, aD ∆@c, cD ∆@d, dD + 2 Γ@aD ∆@a, bD ∆@c, cD ∆@d, dD
Day 1 - Lecture - Mathematica 101_0.nb 21

H*to perform trivial summation with ∆@a,bD *L


rule = 8
rule1,
rule2,
∆@a1_, a1_D ® dim,
∆@a1_, a2_D ^ 2 ® dim,
∆@a1_, a2_D a3_ ¦ Ha3 . a1 ® a2L ; Not@FreeQ@a3, a1DD
<;

res = ex2 . rule  Simplify

- I- 16 + 24 dim - 10 dim2 + dim3 M Γ@bD

Let’s check

∆@a_ ? NumericQ, b_ ? NumericQD := If@a == b, 1, 0D;


ee = Sum@ex . 8b ® 2<, 8a, 4<, 8c, 4<, 8d, 4<D . 8rule1, rule2<

16 Γ@2D

res . dim ® 4

16 Γ@bD

You might also like