Introduction to Wolfram Mathematica

Variables

A=5 (* Assigning the value 5 to the variable A*)

A=8 ;(* Assigning the value 8 to the variable A*)

(Sqrt[-1])

Functions

Sin[3]

sin[3]

Sin[3.]

N[Sin[3],10]

User-defined functions

MyFun[Var1_,Var2_]:=(((((10Sin[Var1]+2(Sqrt[Var2]))/30)))^7)

MyFun[(π/3),-2]

MyFun[(π/3.),-2]

MyFun2[Var1_,Var2_]:=((10*Sin[Var1]+2*Sqrt[Var2])/(30))^7

MyFun2[(π/3),-2]

(∫_0^10)((x^2)+(Sqrt[x]))\[DifferentialD]x

Useful functions

Plot

Plot[(((x^5)+x)/(Sqrt[(x^4)])),{x,-2,2}]

ReplaceAll

(X^2)+3Y/.{X-> a+b,Y-> a-b+(c^2)}

(((a+b))^2)+3 (a-b+(c^2))/.{a->1,b->10,c->2I}

Manipulate

Manipulate[Plot[(((x^5)+x)/(Sqrt[(x^4)+α])),{x,-2,2}],{{α,0},-2,2}]

Simplify & FullSimplify

Simplify[(Sqrt[(x^2)])]

Simplify[(Sqrt[(x^2)]),x≥ 0]

Simplify[(((x^2)-4x+4)/(x Gamma[x]))]

FullSimplify[(((x^2)-4x+4)/(x Gamma[x]))]

Simplify[5 ((Cos[x])^4) Sin[x]-10 ((Cos[x])^2) ((Sin[x])^3)+((Sin[x])^5)]

FullSimplify[5 ((Cos[x])^4) Sin[x]-10 ((Cos[x])^2) ((Sin[x])^3)+((Sin[x])^5)]

TrigReduce[5 ((Cos[x])^4) Sin[x]-10 ((Cos[x])^2) ((Sin[x])^3)+((Sin[x])^5)]

Dirac Delta

(∫_(-∞)^∞)DiracDelta[x]\[DifferentialD]x

Simplify[(∫_(-∞)^∞)(DiracDelta[x-x0]f[x])\[DifferentialD]x,x0∈Reals]

Heaviside Theta & UnitStep

(∂_x)HeavisideTheta[x]

(∂_x)UnitStep[x]

Convolve

Convolve[(E^(-τ))UnitStep[τ]UnitStep[τ],Sin[τ],τ,t]

(∫_(-∞)^∞)((E^(-τ))UnitStep[τ]Sin[t-τ])\[DifferentialD]τ

LaplaceTransform & InverseLaplaceTransform

LaplaceTransform[(t^4)Sin[t],t,s]

(∫_0^∞)((t^4)Sin[t](E^(-s t)))\[DifferentialD]t

InverseLaplaceTransform[((24 (1+5 (s^2) (-2+(s^2))))/(((1+(s^2)))^5)),s,t]

Apart

Apart[((6+2 s)/(12+20 s+9 (s^2)+(s^3)))]

ToMatlab Package

Installation - find the path

FileNameJoin[{$UserBaseDirectory,"Applications"}]

Using ToMatlab package - an example

<<ToMatlab.m

Solve[(((((-8 ζ-3 (a0^2) κ3)/(2 γ1))))^2)+(((((3 (a0^2) α3+4 σ)/(2 γ1))))^2)-1==0,a0]//FullSimplify

Plot[{-(Sqrt[(2/3)]) (Sqrt[-((4 ζ κ3+2 α3 σ+(Sqrt[((α3)^2) (((γ1)^2)-16 (ζ^2))+16 α3 ζ κ3 σ+((κ3)^2) (((γ1)^2)-4 (σ^2))]))/(((α3)^2)+((κ3)^2)))]),(Sqrt[(2/3)]) (Sqrt[-((4 ζ κ3+2 α3 σ+(Sqrt[((α3)^2) (((γ1)^2)-16 (ζ^2))+16 α3 ζ κ3 σ+((κ3)^2) (((γ1)^2)-4 (σ^2))]))/(((α3)^2)+((κ3)^2)))]),-(Sqrt[(2/3)]) (Sqrt[((-4 ζ κ3-2 α3 σ+(Sqrt[((α3)^2) (((γ1)^2)-16 (ζ^2))+16 α3 ζ κ3 σ+((κ3)^2) (((γ1)^2)-4 (σ^2))]))/(((α3)^2)+((κ3)^2)))]),(Sqrt[(2/3)]) (Sqrt[((-4 ζ κ3-2 α3 σ+(Sqrt[((α3)^2) (((γ1)^2)-16 (ζ^2))+16 α3 ζ κ3 σ+((κ3)^2) (((γ1)^2)-4 (σ^2))]))/(((α3)^2)+((κ3)^2)))])}/.{ζ->1,κ3->0.2,γ1->5,α3->2},{σ,-6,4}]

ToMatlab[-(Sqrt[(2/3)]) (Sqrt[-((4 ζ κ3+2 α3 σ+(Sqrt[((α3)^2) (((γ1)^2)-16 (ζ^2))+16 α3 ζ κ3 σ+((κ3)^2) (((γ1)^2)-4 (σ^2))]))/(((α3)^2)+((κ3)^2)))])/.{α3->alpha3,γ1->gamma1,κ3->kappa3,σ->sig,ζ->zeta}]
ToMatlab[(Sqrt[(2/3)]) (Sqrt[-((4 ζ κ3+2 α3 σ+(Sqrt[((α3)^2) (((γ1)^2)-16 (ζ^2))+16 α3 ζ κ3 σ+((κ3)^2) (((γ1)^2)-4 (σ^2))]))/(((α3)^2)+((κ3)^2)))])/.{α3->alpha3,γ1->gamma1,κ3->kappa3,σ->sig,ζ->zeta}]
ToMatlab[-(Sqrt[(2/3)]) (Sqrt[((-4 ζ κ3-2 α3 σ+(Sqrt[((α3)^2) (((γ1)^2)-16 (ζ^2))+16 α3 ζ κ3 σ+((κ3)^2) (((γ1)^2)-4 (σ^2))]))/(((α3)^2)+((κ3)^2)))])/.{α3->alpha3,γ1->gamma1,κ3->kappa3,σ->sig,ζ->zeta}]
ToMatlab[(Sqrt[(2/3)]) (Sqrt[((-4 ζ κ3-2 α3 σ+(Sqrt[((α3)^2) (((γ1)^2)-16 (ζ^2))+16 α3 ζ κ3 σ+((κ3)^2) (((γ1)^2)-4 (σ^2))]))/(((α3)^2)+((κ3)^2)))])/.{α3->alpha3,γ1->gamma1,κ3->kappa3,σ->sig,ζ->zeta}]