Random Slides for Numerical Analysis and Computing | MATH 541, Study notes of Mathematics

Material Type: Notes; Professor: Blomgren; Class: INTRO NUM ANALYS & COMPUT; Subject: Mathematics; University: San Diego State University; Term: Fall 2009;

Typology: Study notes

Pre 2010

Uploaded on 03/28/2010

koofers-user-5mq
koofers-user-5mq 🇺🇸

9 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Homework Comments
Numerical Analysis and Computing
Random Notes #51
2
Peter Blomgren,
Department of Mathematics and Statistics
Dynamical Systems Group
Computational Sciences Research Center
San Diego State University
San Diego, CA 92182-7720
http://terminus.sdsu.edu/
Fall 2009
Peter Blomgren, h[email protected]iRandom Notes #5 1
2 (1/11)
Homework Comments
Outline
1Homework Comments
Homework #2
Peter Blomgren, h[email protected]iRandom Notes #5 1
2 (2/11)
Homework Comments Homework #2
Somewhat Common Mistakes
1Please give some measure of speed either
1Number of steps needed (robust), or
2execution time (may depend on what else is going on in the
background...).
2Don’t display failure message when the root is found.
Peter Blomgren, h[email protected]iRandom Notes #5 1
2 (3/11)
Homework Comments Homework #2
Function Calls
Cute idea: sending the mathematical function as a string argument
to the function
file: bisection.m
function [ReturnValue] = bisection( fstring, a, b, TOL );
f = inline( fstring, ’x’ );
...
Matlab prompt
>> my root1 = bisection( ’sin(x)’, -0.2, 0.5, 1e-8 );
Peter Blomgren, h[email protected]iRandom Notes #5 1
2 (4/11)
pf3

Partial preview of the text

Download Random Slides for Numerical Analysis and Computing | MATH 541 and more Study notes Mathematics in PDF only on Docsity!

Homework Comments Numerical Analysis and Computing^ Random Notes

Peter Blomgren, 〈[email protected]

Department of Mathematics and Statistics^ Dynamical Systems GroupComputational Sciences Research Center^ San Diego State UniversitySan Diego, CA 92182-7720^ http://terminus.sdsu.edu/^ Fall 2009 Peter Blomgren, 〈[email protected]〉^

(^1) Random Notes #5 2

— (1/11)

Homework Comments

Outline^1 Homework Comments^ Homework #2^ Peter Blomgren,

[email protected]

(^1) 〉 Random Notes #5 2

— (2/11)

Homework Comments^

Homework #

Somewhat Common Mistakes^1 Please give

some^ measure of speed — either 1 Number of steps needed (robust), or 2 execution time (may depend on what else is going on in thebackground...). 2 Don’t display failure message when the root

is^ found.

Peter Blomgren,^ 〈[email protected]

(^1) 〉 Random Notes #5 2

— (3/11)

Homework Comments^

Homework #

Function Calls^ Cute idea: sending the mathematical function as a string argumentto the function —^ file:^ bisection.m^ function [ReturnValue] = bisection( fstring, a, b, TOL );f = inline( fstring, ’x’ );...^ Matlab prompt^ >> my^ root1 = bisection( ’sin(x)’, -0.2, 0.5, 1e-8 );^ Peter Blomgren,

[email protected]

(^1) 〉 Random Notes #5 2

— (4/11)

Homework Comments^

Homework #

Function Calls — Other Variants, 1^ file:^ bisection.m^ function [ReturnValue] = bisection( f, a, b, TOL );fa = f(a);fb = f(b);...^ Matlab prompt^ >> F = inline(’sin(x)’,’x’);>> G = inline(’sin(x) .* cos(x) .* exp(x)’,’x’);>> my^ root2 = bisection( F, -0.2, 0.5, 1e-8 );>> my^ root3 = bisection( G, -0.3, 0.4, 1e-10 );^ Peter Blomgren,

[email protected]

(^1) 〉 Random Notes #5 2

— (5/11)

Homework Comments^

Homework #

Function Calls — Other Variants, 2^ file:^ myGnarlyFunction.m^ function [ReturnValue] = myGnarlyFunction( x );ReturnValue =(exp(sin(x.cos(tan(x+pi/52))))+9).sin(cos(x));^ Matlab prompt^ >> r4 = bisection( @myGnarlyFunction, -0.2, 0.5, 1e-8 );^ Peter Blomgren,

[email protected]

(^1) 〉 Random Notes #5 2

— (6/11)

Homework Comments^

Homework #

Function Calls — help...^ For more information^ >> help function^ >> help punct^ See the entry for

@^ “At.”

>> help publish^ If you want to do fancy “publishing” of your code Peter Blomgren,^ 〈[email protected]

(^1) 〉 Random Notes #5 2

— (7/11)

Homework Comments^

Homework #

Publishing Example, 1/4^ file:^ test^ pub.m^ % % This is the main driver...% (cannot be a function for publishing)% xv = 1.4 :^

0.001 :^ 1.6;fxv = myGnarlyFunction(xv);r = bisection( @myGnarlyFunction, 1.4, 1.6, 1e-5 );% plot(xv,fxv);hold onaxis([min(xv) max(xv) min(fxv)1.05 max(fxv)1.05])plot(r,myGnarlyFunction(r),’ro’);grid ongrid minorhold off Peter Blomgren, 〈[email protected]

(^1) 〉 Random Notes #5 2

— (8/11)