Lecture 2.pptxLecture 2.pptxLecture 2.pptxLecture 2.pptx

MudassarAhmed39 33 views 24 slides Jul 26, 2024
Slide 1
Slide 1 of 24
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24

About This Presentation

Lecture 2.pptxLecture 2.pptxLecture 2.pptxLecture 2.pptxLecture 2.pptxLecture 2.pptxLecture 2.pptxLecture 2.pptxLecture 2.pptxLecture 2.pptx


Slide Content

Introduction to Mathematica

What is Mathematica? Overview : Mathematica is a powerful computational software used for symbolic and numerical calculations, data visualization, and technical computing. Developer : Created by Wolfram Research, it has been a cornerstone in computational software since its release in 1988. Usage : Widely used in academia, research, engineering, and industries requiring sophisticated mathematical computations.

Why Mathematica? Symbolic and Numerical Computation : Combines symbolic and numerical computation seamlessly, making it versatile for a range of mathematical problems. Interactive Notebooks : Provides an interactive environment for creating dynamic documents that combine code, text, and graphics. Integrated System : Features a fully integrated system with built-in functions covering various fields such as calculus, algebra, statistics, and more. Automation : Automates many aspects of computation, allowing users to focus on problem-solving rather than coding intricacies.

Applications Education : Essential tool in education for teaching complex mathematical concepts through interactive and visual means. Research : Facilitates advanced research in mathematics, physics, engineering, economics, and other fields by providing robust computational tools. Industry Applications : Used in finance, biotechnology, software development, and more to solve real-world problems with high precision. Innovation : Drives innovation by enabling rapid prototyping and testing of mathematical models and algorithms.

Getting Started Notebook and Text-Based Interfaces To start Mathematica on SCC cluster, type mathematica (or Mathematica ) at the prompt: % mathematica To start Mathematica Kernel ( text-base interface), type math at the prompt: % math

Getting Started Notebook and Text-Based Interfaces To start Mathematica on Windows: Start -> Wolfram Mathematica -> Wolfram Mathematica 9 To start Mathematica Kernel ( text-base interface) on Windows: Start -> Wolfram Mathematica -> Wolfram Mathematica 9 Kernel

Getting Started Notebook and Text-Based Interfaces Notebook Interface Text-Based Interface Start mathematica math Execute command Shift-Enter Enter Exit Choose the Quit menu item Cntr -D or Quit[]

Numerical Calculations 21.7 + 19.94 In[1] := 21.7 + 19.94 Out[1] := 41.64 Press Shift + Enter

Numerical Calculations x+y+z add x -y subtract x /y divide x y z or x*y* z multiply x^y power x *( y+z ) control grouping by parentheses Note : You can use space or a * sign for multiplication

Numerical Calculations You get exact result with Mathematica unless you request otherwise. In[1] := 2 ^ 100 (* get exact result *) Out[1] := 1267650600228229401496703205376 In[2] := 2 ^ 100 //N (* get approximation *) Out[2] := 1.26765x10 30 In[3] := 1/3 + 2/7 (* get exact result *) Out[3] := In[4] := 1/3 + 2/7 //N (* get approximation *) Out[4] := 0.619048  

Numerical Calculations If an input number contains an explicit decimal point, Mathematica produces an approximate numerical result. In[5] := 11/3 + 2/7 (* exact result *) Out[5] := In[6] := 1 . 1/3 + 2/7 (* approximation *) Out[6] := 0.652381  

Numerical Calculations Sqrt [x] Exp [x] e x Log[x] ln x Log[ b,x ] log b x Sin[x], Cos[x], Tan[x] trigonometric functions ArcSin [x], ... inverse trigonometric functions n! factorial FactorInteger [n] prime factors of n Abs[x] |x| Round[x] closest integer to x Max[ x,y ,...], Min[ x,y ,...] maximum and minimum of a set Mod[ n,m ] remainder of division of n by m Random[] random number between and 1 Sqrt [x] Exp [x] e x Log[x] ln x Log[ b,x ] log b x Sin[x], Cos[x], Tan[x] trigonometric functions ArcSin [x], ... inverse trigonometric functions n! factorial FactorInteger [n] prime factors of n Abs[x] |x| Round[x] closest integer to x Max[ x,y ,...], Min[ x,y ,...] maximum and minimum of a set Mod[ n,m ] remainder of division of n by m Random[] random number between and 1 Common Mathematical Functions

Numerical Calculations Functions in Mathematica The arguments of ALL Mathematica functions are enclosed in square brackets ; The names of built-in Mathematica functions begin with capital letters ; Unless //N option or decimal point is present, Mathematica tries to output exact value

Numerical Calculations Pi E e Degree I i = Infinity ∞ Pi E e Degree I Infinity ∞ Common Mathematical Constants The names of all built-in constants begin with capital letters .

Numerical Calculations Specify the degree of precision In[1] := N[Pi, 30] (* approximation *) Out[1] := 3.14159265358979323846264338328 In[2] := N[ Sqrt [7], 10] Out[2] := 2.645751311

Numerical Calculations Using Previous Results - use with care! In[1] := 7 + 3 Out[1] := 10 In[2] := % + 1 Out[2] := 11 % the last result generated %% the next-to-last result %n the result on output line Out[n] Note: % is always defined to be the last result that Mathematica generated. It can be anywhere in the script!

Numerical Calculations Variables definition x = value assign a value to the variable x x = y = value assign a value to both x and y x = . or Clear[x] remove any value assigned to x Notes: Mathematica is case-sensitive; To avoid confusion with built-in functions, choose names that start with lower-case letters; x y means x times y; xy with no space means variable name xy ; 5x means 5 times x;

Numerical Calculations Lists of Objects List is a collection of several objects in Mathematica In[1] := vec = {2, 4, 1.8} Out[1] := {2, 4, 1.8} In[2] := vec^2 Out[2] := {4, 16, 3.24} In[3] := vec /(vec-1) Out[3] := {1, , 2.25} In[4] := vec [[2]] (* extract second element *) Out[4] := 4 In[5] := Part[vec,1] (* extract first element *) Out[5] := 2  

Functions Function Definition Use underscore _ after a variable name (function argument) f([x_] := x^2 + 4 x + 4 ; To execute a function, simply call it with a given value: f[1] Mathematica’s built-in functions start with upper-case letter. Start with lower case letter for the user defined function.

Functions Using Functions Show function definition: ?f Expand function: Expand[f[x + y + 1]] Find derivative of a function: D[f[x], x] Find integral of a function: Integrate[f[x] ,x] Find definite integral of a function: Integrate[f[x] ,{x,0,1}] Clear the definition of a function: Clear[f]

Equations Solving equations Define equation using double equal sign == Solve[4 x^2 + 4 x + 1 == 0] Mathematica can solve an equation for one variable in terms of another Solve[5 x^2 -2 Log[y] == 3 x,y ] Solve system of equations: Solve[{x + 2 y == 5, 7 x – 5 x == -3},{ x,y }]

Equations Solving equations Mathematica can solve algebraic equations in one variable for power less than 5 and sometimes even higher. But there are some equations for which it is impossible to find the root(s) algebraically. Mathematica will use Root object to represent the solution. Use N[%] to evaluate the solution numerically. In some cases Mathematica can solve equations involving other functions: In[1] := Solve[Sin[x] == a, x] Out[1] := {{ x -> ArcSin [a]}}

Equations Solving equations You can also find an approximate numerical solution using FindRoot[] : In[1] := FindRoot[Cos[x] == x, {x,0}] Out[1] := { x -> 0.739085} Mathematica can solve system of simultaneous equations. It can eliminate a variable in a system, using Eliminate[] function, or simplify the system using Reduce[] function.

Programs Programming Constructs Assignments: = += ++ *= AppendTo Loops: Do While For Table Nest Conditionals: If Which Switch And(&&) Equal(==) Less(<) … Flow Control: Return Throw Catch TimeConstrained Scope Constructs: Module With Block I/O: Print Input Pause Import OpenRead …
Tags