• Sonuç bulunamadı

Getting Started Getting Started with with Mathematica Mathematica

N/A
N/A
Protected

Academic year: 2021

Share "Getting Started Getting Started with with Mathematica Mathematica"

Copied!
32
0
0

Yükleniyor.... (view fulltext now)

Tam metin

(1)

Getting Started Getting Started

with with

Mathematica Mathematica

by

Hakan Kutucu

(2)

What is

What is Mathematica Mathematica

 Mathematica is a computer program created by Wolfram Research Inc.(1988)

 Mathematica is a powerful desktop computer program capable of doing algebraic calculations, numerical approximations, and computer graphics.

 It is suitable for both numeric and symbolic work, and it has remarkable word-processing capabilities as well.

(3)

Some Graphical Examples

Some Graphical Examples

(4)

 Mathematica has two parts: the Kernel and the Front End.

 The Kernel is the main part of the system,

which accepts Mathematica commands, processes them and sends back results. This is called

evaluating the command.

 The Front End is the part of the system that

handles such things as screen display, printing and the creation of Mathematica documents.

What is

What is Mathematica Mathematica

(5)

How does

How does Mathematica Mathematica work? work?

Mathematica documents are called Notebooks. A Notebook is a bit like a word-processor

document; you can type and edit commands, send them to the Kernel for

evaluation, display the results and save your work.

(6)

How does

How does Mathematica Mathematica work? work?

 You send commands to be evaluated by

holding down the “shift” key and pressing the

“enter” key

 Another easy way to evaluate by pressing the

“enter” key at the right hand side of keyboard.

(7)

Functionalities of

Functionalities of Mathematica Mathematica

Numerical ComputationNumerical Computation

Equation SolvingEquation Solving

Symbolic calculationSymbolic calculation

CalculusCalculus

GraphicsGraphics

Self-defined functionsSelf-defined functions

ListList

Pattern MatchingPattern Matching

AnimationAnimation

(8)

Mathematica Syntax Mathematica Syntax

 Mathematica commands start with a CAPITAL letter, e.g. Sin[x]. If the command is really

severalwords in English joined together then each one starts with a capital but

WithNoSpacesInBetween.

Case Sensitive: the word Fun is different from the word fun which is different from the word fuN.

(9)

Mathematica Syntax Mathematica Syntax

 Mathematica uses a lot of brackets and all the different sorts of them, ( [ { } ] ).

 Arguments of functions are given in square brackets [ ].

 Curly brackets, called “braces”, {…} are used to make a list, usually to allow several objects to be treated as one.

 Expression are cascaded by () pairs.

(10)

Mathematica protects these names; they cannot be used as names for other

quantities.

SPECIAL CONSTANTS

SPECIAL CONSTANTS

(11)

Operation Operation

Symbol

Symbol Operation Operation

NameName SampleSample

++ AddAdd 3+53+5

-- SubstructSubstruct 8-38-3 // DivideDivide 4/64/6

* or Space

* or Space MultiplyMultiply 2*4 or 2 42*4 or 2 4

^^ PowerPower 3^43^4

Arithmetic Operations

Arithmetic Operations

(12)

Arithmetic Operations Arithmetic Operations

Order of operation is important .

BEDMAS

(13)

N N (Numerical) (Numerical)

(a) N[expr] displays 6 digits by default

(b) N[expr, n] displays 6 digits when n<16

(c) N[expr, n] does not display more digits than n originally has.

(14)

Some Mathematical Functions Some Mathematical Functions

Sqrt[x]

Sqrt[x] square root ( )square root ( ) Exp[x]

Exp[x] exponential (eexponential (exx)) Log[x]

Log[x] natural logarithm lnxnatural logarithm lnx Log[b, x]

Log[b, x] logarithm to base b (loglogarithm to base b (logbbx)x) Sin[x],

Sin[x],

Cos[x], Tan[x]

Cos[x], Tan[x]

trigonometric functions (with trigonometric functions (with

arguments in radians) arguments in radians) nn!! factorial of nfactorial of n

Mod[Mod[nn, , mm]] n modulo mn modulo m FactorInteger[

FactorInteger[nn]] prime factors of nprime factors of n

(15)

Mathematica incorporates a wide range of two- and three-dimensional graphics functions. The

simplest is Plot, which generates two-dimensional Cartesian graphs

Plot[f, {x, xmin, xmax}]

generates a plot of f as a function of x from xmin to xmax.

Plot[{f1, f2, … }, {x, xmin, xmax}]

plots several functions f.

Graphics

Graphics

(16)

Graphics (Example)

Graphics (Example)

(17)

Graphics(Options)

Graphics(Options)

(18)

Graphics(Options) Graphics(Options)

For Other Options the command is

Options[Plot]

(19)

3 Dimensional Plotting

Plot3D[ f, {x,xmin,xmax}, {y,ymin,ymax}]

will draw the graph of z = f(x,y) over the

rectangle [xmin,xmax]×[ymin,ymax] in the xy- plane.

(20)

3 Dimensional Plotting(Options)

(21)

Three Dimensional Plotting(Options)

(22)

 A function may return a symbol, a real

number, a complex matrix, another function....

 Any mathematical object is an acceptable value for a function.

 A function may be written using mathematical notation, it may be created using programming constructs (like for, if/then, etc.), or it could even be written in another language entirely (Fortran, C, etc.).

Defining Functions

Defining Functions

(23)

 Mathematica variable names can be long, but they must not begin with a number,

 Because Mathematica interprets, say, 2dimension as 2 * dimension.

 Names can end with a number, though: x1 is a useful way of writing in Mathematica a subscripted variable like x1.

Note also that combinations of letters without spaces are interpreted as new variables: ax does not mean a*x.

Function & Variable Names

Function & Variable Names

(24)

A function can be defined by using the following form:

f[x_] := an expression involving x (no underbar)

Example: f[x_]:=x^2+3x f[4]

f[a+1]

?f (This shows the definition you made for f. )

Defining Functions

(25)

Equation solving Equation solving

Use Solve to solve an equation with an Use Solve to solve an equation with an

exact solution, including a symbolic solution.

exact solution, including a symbolic solution.

Use NSolve or FindRoot to obtain a Use NSolve or FindRoot to obtain a

numerical approximation to the solution.

numerical approximation to the solution.

To use solutions need to use To use solutions need to use expr/ .x y. expr/ .x y.

(26)

Ma Ma trix Defining trix Defining

Entering a matrix:Entering a matrix:

a={{1,2,3},{4,5,6},{7,8,9}}

a={{1,2,3},{4,5,6},{7,8,9}}

Displays nicely only if told to:Displays nicely only if told to:

(27)

Menus exist but are harder to use than typing

Menus exist but are harder to use than typing

(28)

Ma Ma trix Operations trix Operations

(29)

Matrix multiplication

(also called dot or inner product) is carried out in Mathematica with the

function Dot, typically entered with a dot short- hand syntax.

Ma Ma trix trix Operations Operations (Multiplication)

(Multiplication)

(30)

Ma Ma trix trix Operations Operations (Transpose)

(Transpose)

(31)

Ma Ma trix trix Operations Operations (Inverse)

(Inverse)

(32)

16 5

4

12 2

3

2 2

6 2

Solve

q z

y x

q z

y x

q y

x

q z

y x

Ma Ma trix trix Operations Operations Exercises

Exercises

1.By using Solve Commabd

2.By using The equation Ax=b

Referanslar

Benzer Belgeler

The patient was diagnosed as a fracture of the lumbar vertebral ring apophysis imitating disc herniation.. To obtain the correct diagnosis, CT

Stiffness is the most commonly modulated part of impedance. Hardware based stiffness modulation can be achieved through three fundamental approaches: i) by loading non-linear

Our MathOptimizer software package serves to solve global and local optimization models developed using Mathematica.. We introduce MathOptimizer’s key features

Tek boyutlu ve iki boyutlu kutudaki tanecik ile harmonik osilatör problemleri için dalga fonksiyonu ve olasılık yoğunluğuna ait eğriler elde edilmiştir.

1 Sakarya University Training and Reaearch Hospital, Clinic of Pediatrics, Division of Allergy and Immunology, Sakarya, Turkey 2 Sakarya University Training and Research

It was observed that the patient's stuttering complaint was resumed when the patient had reached the euthymic state by the treatment.. Keywords: bipoar disorder, stuttering,

During the study period, a total of 42 laparoscopic adrenalectomy procedures by transabdominal lateral approach were performed and the vast majority of cases were women

Materials and Methods: This is a retrospective analysis of 63 patients who underwent IVM due to the high risk of Ovarian Hyperstimulation syndrome (OHSS) (n=39), cancerophobia