Docsity
Docsity

Prepara tus exámenes
Prepara tus exámenes

Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity


Consigue puntos base para descargar
Consigue puntos base para descargar

Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium


Orientación Universidad
Orientación Universidad


métodos numéricos matlab, Esquemas y mapas conceptuales de Métodos Numéricos

métodos numéricos que sirve para resolver ejercicios basicos en matlab

Tipo: Esquemas y mapas conceptuales

2021/2022

Subido el 17/11/2022

luis-miguel-hdg
luis-miguel-hdg 🇵🇪

3 documentos

1 / 516

Toggle sidebar

Esta página no es visible en la vista previa

¡No te pierdas las partes importantes!

bg1
http://www.elsolucionario.blogspot.com
LIBROS UNIVERISTARIOS
Y SOLUCIONARIOS DE
MUCHOS DE ESTOS LIBROS
LOS SOLUCIONARIOS
CONTIENEN TODOS LOS
EJERCICIOS DEL LIBRO
RESUELTOS Y EXPLICADOS
DE FORMA CLARA
VISITANOS PARA
DESARGALOS GRATIS.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Vista previa parcial del texto

¡Descarga métodos numéricos matlab y más Esquemas y mapas conceptuales en PDF de Métodos Numéricos solo en Docsity!

http://www.elsolucionario.blogspot.com

CHAPTER 2

IF x < 10 THEN

IF x < 5 THEN

x = 5

ELSE

PRINT x

END IF
ELSE
DO

IF x < 50 EXIT

x = x - 5

END DO
END IF

Step 1: Start

Step 2: Initialize sum and count to zero

Step 3: Examine top card.

Step 4: If it says “end of data” proceed to step 9; otherwise, proceed to next step.

Step 5: Add value from top card to sum.

Step 6: Increase count by 1.

Step 7: Discard top card

Step 8: Return to Step 3.

Step 9: Is the count greater than zero?

If yes, proceed to step 10.

If no, proceed to step 11.

Step 10: Calculate average = sum / count

Step 11: End

start

sum = 0

count = 0

INPUT

value

value =

“end of data”

value =

“end of data”

sum = sum + value

count = count + 1

T

F

count > 0

average = sum/count

end

T

F

2.5 The development of the algorithm hinges on recognizing that the series approximation of the

sine can be represented concisely by the summation,

x

i

i

i

n 2 1

1

=

where i = the order of the approximation. The following algorithm implements this

summation:

Step 1: Start

Step 2: Input value to be evaluated x and maximum order n

Step 3: Set order (i) equal to one

Step 4: Set accumulator for approximation (approx) to zero

Step 5: Set accumulator for factorial product (fact) equal to one

Step 6: Calculate true value of sin(x)

Step 7: If order is greater than n then proceed to step 13

Otherwise, proceed to next step

Step 8: Calculate the approximation with the formula

approx approx ( 1)

x

factor

i- 1

2i- 1

Step 9: Determine the error

true

true approx

%error

Step 10: Increment the order by one

Step 11: Determine the factorial for the next iteration

factor = factor • (2 • i − 2) • (2 • i −1)

Step 12: Return to step 7

Step 13: End

start

INPUT

x, n

i > n

end

i = 1

true = sin(x)

approx = 0

factor = 1

approx approx

x

factor

i

i -

  • 1

2 1

error

true approx

true

OUTPUT

i,approx,error

i = i + 1

F

T

factor=factor(2i-2)(2i-1)

Pseudocode:

SUBROUTINE Sincomp(n,x)

i = 1

true = SIN(x)

approx = 0

factor = 1

DO

IF i > n EXIT

approx = approx + (-1)

i-

  • x

2

i-

/ factor

error = Abs(true - approx) / true) * 100

PRINT i, true, approx, error

i = i + 1

factor = factor(2i-2)(2i-1)

END DO
END

Interpretation: The absolute percent relative error drops until at n = 6, it actually yields a

perfect result (pure luck!). Beyond, n = 8, the errors starts to grow. This occurs because of

round-off error, which will be discussed in Chap. 3.

2.8 AQ = 442/5 = 88.

AH = 548/6 = 91.

without final

AG =

with final

AG =

The following pseudocode provides an algorithm to program this problem. Notice that the

input of the quizzes and homeworks is done with logical loops that terminate when the user

enters a negative grade:

INPUT number, name

INPUT WQ, WH, WF

nq = 0

sumq = 0

DO

INPUT quiz (enter negative to signal end of quizzes)

IF quiz < 0 EXIT

nq = nq + 1

sumq = sumq + quiz

END DO

AQ = sumq / nq

PRINT AQ

nh = 0

sumh = 0

PRINT "homeworks"

DO

INPUT homework (enter negative to signal end of homeworks)

IF homework < 0 EXIT

nh = nh + 1

sumh = sumh + homework

END DO

AH = sumh / nh

PRINT "Is there a final grade (y or n)"

INPUT answer

IF answer = "y" THEN

INPUT FE

AG = (WQ * AQ + WH * AH + WF * FE) / (WQ + WH + WF)

ELSE

AG = (WQ * AQ + WH * AH) / (WQ + WH)

END IF

PRINT number, name$, AG

END

n F

2.10 Programs vary, but results are

Bismarck = −10.842 t = 0 to 59

Yuma = 33.040 t = 180 to 242

n A

Step v (12)

t

Error is halved when step is halved

Fortran 90 VBA

Dim V1 As Single, v2 As Single, pi As Single

pi = 4 * Atn(1)

If d < R Then

Vol = pi * d ^ 3 / 3

ElseIf d <= 3 * R Then

V1 = pi * R ^ 3 / 3

v2 = pi * R ^ 2 * (d - R)

Vol = V1 + v

Else

Vol = "overtop"

End If

End Function

The results are

R d Volume

1 3.1 overtop

2.15 Here is a flowchart for the algorithm:

Function Polar(x, y)

2 2

r = x + y

x < 0

y > 0 y > 0

θ + π

x

y

1

tan

θ − π 

x

y 1

tan

θ −π 

x

y 1

tan

θ = 0

π

θ =−

y < 0

θ = π

y < 0

Polar

Polar

End Polar

T

T

T

T

T

F

F

F

F

And here is a VBA function procedure to implement it:

Option Explicit

Function Polar(x, y)

Dim th As Single, r As Single

Const pi As Single = 3.

r = Sqr(x ^ 2 + y ^ 2)

If x < 0 Then

If y > 0 Then

th = Atn(y / x) + pi

ElseIf y < 0 Then

th = Atn(y / x) - pi

Else

th = pi

End If

Else

If y > 0 Then

th = pi / 2

ElseIf y < 0 Then

th = -pi / 2

Else

th = 0

End If

End If

Polar = th * 180 / pi

End Function

The results are:

x y θ

4.18 f(x) = x-1-1/2*sin(x)

f '(x) = 1-1/2*cos(x)

f ''(x) = 1/2*sin(x)

f '''(x) = 1/2*cos(x)

f

IV

(x) = -1/2*sin(x)

Using the Taylor Series Expansion (Equation 4.5 in the book), we obtain the following

st

nd

rd

, and 4

th

Order Taylor Series functions shown below in the Matlab program-

f1, f2, f4. Note the 2

nd

and 3

rd

Order Taylor Series functions are the same.

From the plots below, we see that the answer is the 4

th

Order Taylor Series expansion.

x=0:0.001:3.2;

f=x-1-0.5*sin(x) ;

subplot(2,2,1);

plot(x,f);grid;title('f(x)=x-1-0.5*sin(x)');hold on

f1=x-1.5 ;

e1=abs(f-f1); %Calculates the absolute value of the

difference/error

subplot(2,2,2);

plot(x,e1);grid;title('1st Order Taylor Series Error');

f2=x-1.5+0.25.((x-0.5pi).^2);

e2=abs(f-f2);

subplot(2,2,3);

plot(x,e2);grid;title('2nd/3rd Order Taylor Series Error');

f4=x-1.5+0.25.((x-0.5pi).^2)-(1/48)((x-0.5pi).^4);

e4=abs(f4-f);

subplot(2,2,4);

plot(x,e4);grid;title('4th Order Taylor Series Error');hold off