




























































































Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Prepare-se para as provas
Estude fácil! Tem muito documento disponível na Docsity
Prepare-se para as provas com trabalhos de outros alunos como você, aqui na Docsity
Os melhores documentos à venda: Trabalhos de alunos formados
Prepare-se com as videoaulas e exercícios resolvidos criados a partir da grade da sua Universidade
Responda perguntas de provas passadas e avalie sua preparação.
Ganhe pontos para baixar
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Comunidade
Peça ajuda à comunidade e tire suas dúvidas relacionadas ao estudo
Descubra as melhores universidades em seu país de acordo com os usuários da Docsity
Guias grátis
Baixe gratuitamente nossos guias de estudo, métodos para diminuir a ansiedade, dicas de TCC preparadas pelos professores da Docsity
Resolução das questões do Livro de Método Númerico.
Tipologia: Exercícios
1 / 515
Esta página não é visível na pré-visualização
Não perca as partes importantes!
IF x < 10 THEN
IF x < 5 THEN
x = 5
PRINT x
IF x < 50 EXIT
x = x - 5
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
PROGRAM Rootfind
IMPLICIT NONE
INTEGER::ier
REAL::a, b, c, r1, i1, r2, i
DATA a,b,c/1.,5.,2./
CALL Roots(a, b, c, ier, r1, i1, r2, i2)
IF (ier .EQ. 0) THEN
PRINT *, r1,i1," i"
PRINT *, r2,i2," i"
ELSE
PRINT *, "No roots"
END IF
END
SUBROUTINE Roots(a, b, c, ier, r1, i1, r2, i2)
IMPLICIT NONE
INTEGER::ier
REAL::a, b, c, d, r1, i1, r2, i
r1=0.
r2=0.
i1=0.
i2=0.
IF (a .EQ. 0.) THEN
IF (b <> 0) THEN
r1 = -c/b
ELSE
ier = 1
END IF
ELSE
d = b2 - 4.ac
IF (d >= 0) THEN
r1 = (-b + SQRT(d))/(2*a)
r2 = (-b - SQRT(d))/(2*a)
ELSE
r1 = -b/(2*a)
r2 = r
i1 = SQRT(ABS(d))/(2*a)
i2 = -i
END IF
END IF
END
start
INPUT
x, n
i > n
end
i = 1
true = sin(x)
approx = 0
factor = 1
approx approx
x
factor
i
i -
2 1
OUTPUT
i,approx,error
i = i + 1
F
T
factor=factor(2i-2)(2i-1)
SUBROUTINE Sincomp(n,x)
i = 1
true = SIN(x)
approx = 0
factor = 1
IF i > n EXIT
approx = approx + (-1)
i-
2
i-
/ factor
error = Abs(true - approx) / true) * 100
PRINT i, true, approx, error
i = i + 1
factor = factor • (2 • i-2) • (2 • i-1)
PROGRAM Series
INTEGER::n
REAL::x
n = 15
x = 1.
CALL Sincomp(n,x)
SUBROUTINE Sincomp(n,x)
INTEGER::n,i,fac
REAL::x,tru,approx,er
i = 1
tru = SIN(x)
approx = 0.
fac = 1
PRINT *, " order true approx error"
IF (i > n) EXIT
approx = approx + (-1) ** (i-1) * x ** (2*i - 1) / fac
er = ABS(tru - approx) / tru) * 100
PRINT *, i, tru, approx, er
i = i + 1
fac = fac * (2i-2) * (2i-1)
order true approx error
Press any key to continue
1.E-
1.E-
1.E-
1.E-
1.E-
1.E+
1.E+
1.E+
0 5 10 15
error
t
Function Vol(R, d)
pi = 3.
d < R
d < 3 * R
V1 = pi * R^3 / 3
V2 = pi * R^2 (d – R)
Vol = V1 + V
Vol =
“Overtop”
End Function
Vol = pi * d^3 / 3
Option Explicit
Function Vol(R, d)
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
x y θ
IV
st
nd
rd
th
nd
rd
th
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
0 1 2 3 4
0
1
2
3
f(x )= x -1-0.5*s in(x )
0 1 2 3 4
0
1s t O rder Tay lor S eries E rror
0 1 2 3 4
0
2nd/3rd O rder Tay lor S eries E rror
0 1 2 3 4
0
4th O rder Tay lor S eries E rror
First Derivative Approximations Compared to Theoretical
-4.
-2.
-2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.
x-values
f'(x)
Theoretical
Backward
Centered
Forward