Test 1

studied byStudied by 11 people
0.0(0)
get a hint
hint

Truncation Errors

1 / 68

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

69 Terms

1

Truncation Errors

Refer to errors in a method, which occur because some series (finite or infinite) is truncated to a fewer number of terms.

Such errors are essentially algorithmic errors and we can predict the extent of the error that will occur in the method.

(e.g. π ≠ 3.14 ≠ 3.14159 but they are approximate)

New cards
2

Round-off errors

Round off error occurs because of the computing device's inability to deal with inexact numbers.

Such numbers need to be rounded off to some near approximation which is dependent on the space allotted by the device to represent the number

New cards
3

Absolute Error

= true value - approximation

Shortcoming: an error of a micrometer is much more significant if we are measuring the size of a cell in comparison to the length of your arm.

So how do we account for the size of the error with respect to the magnitude of the measurement?

New cards
4

Fractional Relative Error

= (Absolute error/true value)*100%

The relative error gives an indication of how good the approximation is relative to the true value

These will be needed when we talk about propagating errors (i.e. combining multiple values that each have an error associated with it)

New cards
5

Variance

a measure of how data points differ from the mean

<p>a measure of how data points differ from the mean</p>
New cards
6

Standard Deviation

a measure of variation of scores about the mean

the average distance to the mean, although that's not numerically accurate, it's conceptually helpful. All ways of saying the same thing: higher standard deviation indicates higher spread, less consistency, and less clustering

Square root of variance

std() provides the sample standard deviation

<p>a measure of variation of scores about the mean</p><p>the average distance to the mean, although that's not numerically accurate, it's conceptually helpful. All ways of saying the same thing: higher standard deviation indicates higher spread, less consistency, and less clustering</p><p>Square root of variance</p><p>std() provides the sample standard deviation</p>
New cards
7

Dot-operations

use the “.” for element-by-element level

So use .* or ./ or .^ instead of * or / or ^

New cards
8

Matrix multiplication vs array multiplication

Use “.” before operator for array calculations

<p>Use “.” before operator for array calculations</p>
New cards
9

Defining Matrices

Enclosed in square bracket [ ]

Commas separate columns

Semicolons indicate a new row

<p>Enclosed in square bracket [ ]</p><p>Commas separate columns</p><p>Semicolons indicate a new row</p>
New cards
10

Indexing arrays

Indexing can also be used to change values in a matrix or include additional values

New cards
11

Colon notation

Can be used to define evenly spaced vectors with a defined increment in the form:

first:increment:limit

New cards
12

linspace

Can be used to define evenly spaced vectors with a in the form

linspace(X1, X2, N)

generates N points between X1 and X2

New cards
13

Plotting in 2D

  1. Create 2 vectors

  2. Use the plot(x,y,’format’) command

  3. Will create a plot of y vs x

  4. Format examples in pic

  5. To plot again of same plot use the hold on command

<ol><li><p>Create 2 vectors</p></li><li><p>Use the plot(x,y,’format’) command</p></li><li><p>Will create a plot of y vs x</p></li><li><p>Format examples in pic</p></li><li><p>To plot again of same plot use the hold on command</p></li></ol>
New cards
14

Subplots

Allows for putting multiple graphs in one figure

subplot(m,n,p) divides graphing window into a grid of m rows and n columns, where p identifies the part of the window where the plot will be drawn

<p>Allows for putting multiple graphs in one figure</p><p>subplot(m,n,p) divides graphing window into a grid of m rows and n columns, where p identifies the part of the window where the plot will be drawn</p>
New cards
15

Polar plots

To plot polar coordinates (angle vs radius) use polar(angle,radius)

<p>To plot polar coordinates (angle vs radius) use polar(angle,radius)</p>
New cards
16

Logarithmic plots

3 kinds:

  • semilogx

  • semilogy

  • loglog

Replace linear scales with logarithmic scales

New cards
17

Linear regression

minimizes the squared distance between experimental data points and the modeled data points. This prevents positive and negative values from cancelling each other out

Use polyfit(x,y,polynomial degree) function with polyval() if necessary

<p>minimizes the squared distance between experimental data points and the modeled data points. This prevents positive and negative values from cancelling each other out</p><p>Use polyfit(x,y,polynomial degree) function with polyval() if necessary</p>
New cards
18

fplot

“smart” command for plotting functions

Automatically analyzes the function to be plotted and decides number of plotting points to show all the features of the function

fplot(function,[xmin xmax])

<p>“smart” command for plotting functions</p><p>Automatically analyzes the function to be plotted and decides number of plotting points to show all the features of the function</p><p>fplot(function,[xmin xmax])</p>
New cards
19

3D plots

plot3

graphs of 3 axes

<p>plot3</p><p>graphs of 3 axes</p>
New cards
20

Surface mesh plots

meshgrid()

mesh(,,)

Create a rectangular grid out of an array of x values and an array of y values

To fill in the faces of the surface in color use

meshgrid()

surf(,,)

<p>meshgrid()</p><p>mesh(,,)</p><p>Create a rectangular grid out of an array of x values and an array of y values</p><p>To fill in the faces of the surface in color use</p><p>meshgrid()</p><p>surf(,,)</p>
New cards
21

Contour Plots

a 3-D surface by plotting lines that connect points with common z-values along a slice

<p> a 3-D surface by plotting lines that connect points with common z-values along a slice</p>
New cards
22

Things plots need

  • a title

  • axis label with the name of quantity and units

  • same symbol of each data point in a given data set

  • grid

  • a legend

  • regularly spaced tick marks at convenient intervals along each axis.

New cards
23

Syntax Errors

Syntax errors are errors in a MATLAB statement itself, such as spelling or punctuation errors

<p>Syntax errors are errors in a MATLAB statement itself, such as spelling or punctuation errors</p>
New cards
24

Run time Errors

  • illegal operations

  • exceeds the dimensions of that matrix

New cards
25

Logical Errors

  • when the program runs without displaying an error, but produces an unexpected result

  • very difficult to find.

    • compare simple test cases with known correct results to find where errors occur

New cards
26

Less than

<

New cards
27

Greater than

>

New cards
28

Equal to

==

New cards
29

Less than or equal to

<=

New cards
30

Greater than or equal to

>=

New cards
31

Not equal to

~=

New cards
32

And (logical operator)

&

is true when all of its operands are true

New cards
33

Not (logical operator)

~

is true when its operand is false

New cards
34

Or (logical operator)

|

is true when one or more of its operands are true

New cards
35

Hierarchy of Operations

  1. Parentheses ()

  2. Exponentiation (.^)

  3. NOT operator (~)

  4. Multiplication (.*) and division (./)

  5. Addition (+) and subtraction (-)

  6. Less than (<), less than or equal to (<=), greater than (>), greater than or equal to (>=), equal to (==), and not equal to (~=)

  7. AND operator (&)

  8. OR operator (|)

New cards
36

is Functions

ischar() input is character array

isfinite() input is finite

isinf() input isinfinite

isletter() input is alphabetic letter

isnumeric() input is numeric array

New cards
37

Pseudocode

Verbal description of your plan for writing a program

Written in English or as a combination of MATLAB code and English

<p>Verbal description of your plan for writing a program</p><p>Written in English or as a combination of MATLAB code and English</p>
New cards
38

Flowcharts

graphical approach to creating a coding plan

Epecially appropriate for planning large or complicated programming tasks

<p>graphical approach to creating a coding plan</p><p>Epecially appropriate for planning large or complicated programming tasks</p>
New cards
39

if statement

allows us to execute a series of statements if a condition is true and to skip those steps if the condition is false

can add else statements and if else

<p>allows us to execute a series of statements if a condition is true and to skip those steps if the condition is false</p><p>can add else statements and if else</p>
New cards
40

Nested if statements

If statements can be nested within each other

Allow you to choose 2 parameters of interest

New cards
41

for loop

repeat a block of commands for a specified matrix which is known before the loop is executed

indexed

<p>repeat a block of commands for a specified matrix which is known before the loop is executed</p><p>indexed</p>
New cards
42

one loop _ be written inside another loop

one loop CAN be written inside another loop

Called a nested loop

New cards
43

while loops

Loops are MATLAB constructs that allow a sequence of MATLAB statements to be executed more than once

loops repeat a block of commands as long as an expression is true (1)

The loop ends when the expression is false (0) and any code following the loop (after the end) is then executed

useful for repeating a procedure an unknown number of times as long as a certain statement is true

can be used to acquire data in experiments

useful when a procedure needs to be repeated until a specific criterion is met

<p>Loops are MATLAB constructs that allow a sequence of MATLAB statements to be executed more than once</p><p>loops repeat a block of commands as long as an expression is true (1)</p><p>The loop ends when the expression is false (0) and any code following the loop (after the end) is then executed</p><p></p><p>useful for repeating a procedure an unknown number of times as long as a certain statement is true</p><p><span>can be used to acquire data in experiments</span></p><p>useful when a procedure needs to be repeated until a specific criterion is met</p>
New cards
44

Components of a while loops

<p></p>
New cards
45

Built-in timer function

tic toc

tic starts the timer

time elapsed since the timer was started is given by the built-in function toc

New cards
46

Converting a for loop into a while loop

One can change any program written with a for loop into a program written using a while loop instead

Change the index matrix of the for loop into an expression or set of variables that can be used in the while loop

<p>One can change any program written with a for loop into a program written using a while loop instead</p><p>Change the index matrix of the for loop into an expression or set of variables that can be used in the while loop</p>
New cards
47

break statement

can be used to terminate a loop prematurely

cause termination of the smallest enclosing loop

New cards
48

How to improve loop efficiency

pre-allocating space for a placeholder variable before entering the loop

New cards
49

Command to display text and matrix values

fprintf()

New cards
50

Different place holders for fprintf

Need in the format-string in order for variable to show up in your display on the command window

%d - integer notation

%f - fixed point notation (decimal)

%e - exponential notation

%g - whichever is shorter between %f or %e (insignificant zeros do not print)

%c - character information

%s - string of characters

New cards
51

normal distribution/gaussian

a probability distribution that is symmetric about the mean, showing that data near the mean are more frequent in occurrence than data far from the mean. In graphical form, it appears as a "bell curve"

New cards
52

What is the area of a normal curve within 1 standard deviation (between μ+σ and μ-σ)

68%

<p>68%</p>
New cards
53

What is the area of a normal curve within 2 standard deviations (between μ+2σ and μ-2σ)

95%

<p>95%</p>
New cards
54

What is the area of a normal curve within 3 standard deviations (between μ+3σ and μ-3σ)

99.7%

<p>99.7%</p>
New cards
55

Code for a gaussian distribution

f(x) = gaussmf(x, [std mu])

std is the standard deviation

mu is the mean

x is the parameter under scrutiny

New cards
56

The standard normal distribution (z)

All normal distributions can be converted into the standard normal curve by subtracting the mean and dividing by the standard deviation

The probabilities given the z is in a table

<p>All normal distributions can be converted into the standard normal curve by subtracting the mean and dividing by the standard deviation</p><p>The probabilities given the z is in a table</p>
New cards
57

_ continuous random variables are normally distributed

NOT ALL continuous random variables are normally distributed

New cards
58

How to tell if your data is normally distributed

  1. Look at the histogram! Does it appear bell shaped?

  2. Compute descriptive summary measures—are mean, median, and mode similar?

  3. Do 2/3 of observations lay within 1 std dev of the mean? Do 95% of observations lay within 2 std dev of the mean?

  4. Look at a normal probability plot—is it approximately linear?

New cards
59

Every physical quantity has:

A value or size

Uncertainty (or Error)

Units

<p>A value or size</p><p>Uncertainty (or Error)</p><p>Units</p>
New cards
60

Error propagation equation to the first order if (∆x)/x is small:

knowt flashcard image
New cards
61

Equation for error propagation with addition and subtraction

knowt flashcard image
New cards
62

Equation for error propagation with multiplication and division

knowt flashcard image
New cards
63

Errors in computational models

Those due to uncertainty in the formulation of the mathematical models and deliberate simplifications of the models

Caused by rounding, data uncertainty, and truncation

New cards
64

Truncation Errors

Results from using an approximation in place of an exact mathematical procedure

The difference between analytical and numerical solutions

New cards
65

Any smooth function can be approximated as a

Polynomial

New cards
66

As the degree of the polynomial approximation _ the _ accurate the approximation

As the degree of the polynomial approximation INCREASES the MORE accurate the approximation

(adding more terms reduce truncation error)

New cards
67

Model Error

Incomplete mathematical models

e.g: E=mc²

New cards
68

Techniques to solve for roots

  1. Graphically - inaccurate

  2. Trial and Error (using excel) - long winded

  3. Automated methods (require an initial guess)

    1. Bracketing Methods - Robust

      • 2 initial guesses that “bracket” the root

    2. Open methods - Faster

      • 1 guess or more but no need to bracket

New cards
69

Bracketing techniques for root finding

  1. Incremental Search

    • Can work

    • Very inefficient

  2. Bisection Method

New cards

Explore top notes

note Note
studied byStudied by 6 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 3 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 5 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 11 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 11 people
Updated ... ago
4.0 Stars(1)
note Note
studied byStudied by 17 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 27 people
Updated ... ago
4.5 Stars(2)
note Note
studied byStudied by 12152 people
Updated ... ago
4.9 Stars(99)

Explore top flashcards

flashcards Flashcard52 terms
studied byStudied by 25 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard34 terms
studied byStudied by 67 people
Updated ... ago
5.0 Stars(2)
flashcards Flashcard132 terms
studied byStudied by 22 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard51 terms
studied byStudied by 80 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard38 terms
studied byStudied by 2 people
Updated ... ago
4.3 Stars(3)
flashcards Flashcard64 terms
studied byStudied by 1 person
Updated ... ago
5.0 Stars(1)
flashcards Flashcard68 terms
studied byStudied by 51 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard63 terms
studied byStudied by 72 people
Updated ... ago
5.0 Stars(1)