J

@joseclaudineiferreira

Simula salário

Python
2 years ago
p=2437.59 for i in range(2,14): p=p*(5/100+1) print(i,p)

Predador-Preza-frac

R
2 years ago
#----------------------------------------------------------------------------------------------- # Exemplo 4: Modelo Lotka-Volterra D^alpha Y= f(t, Y). alpha = 0.9 f<-function(t){2*c(t[1]-3*t[1]*t[2]/2,-2*t[2]+t[1]*t[2]/2)} x0=0 xn=50

Mandelbrot-simples

R
3 years ago
p=20 # experimente usar outros valores para p e b b=20 Z=0*(1:(p+1)) Z[1]=0 c=.10+.3*1i # experimente usar outros valores aqui h=b/p; Y=0 f<-function(U){p=U^2-U+c;p }

Exp-Runge-Kutta2-prevcor

Python
4 years ago
import numpy as np, matplotlib.pyplot as plt # Resolver a equação diferencial u'(s)=(u1',u2'), com u(80)=(0,0). Estime u(10). def f(s,u): # y=u[0] z=u[1] dy=(y-z)/s dz=-np.sqrt(1+dy**2)/2 return np.array([dy, dz])

Teste-Trap-prev-cor

Python
4 years ago
import numpy as np, matplotlib.pyplot as plt # Resolver a equação diferencial u'(s)=u^2+2scos(u(s)), com u(0)=2. def f(s,u): # du/dt=2su p=u**2+2*s*np.cos(u) return p def phi(s,u): # Fução de iteração do trapézio previsao-correcao

EDO-Euler-Trap

Python
4 years ago
import numpy as np, matplotlib.pyplot as plt # Resolver a equação diferencial u'(s)=2su(s), com u(0)=1. def f(s,u): # du/dt=2su p=2*s*u return p n=10 h=(1-0)/n

Trapzio-euler

Python
4 years ago
# Da da a função f(s)=sin((1+s^2)^(1/2)*ln(2)). # Calcular a integral de f(s), pra s entre 0 e 1. import numpy as np # para usar expressões matemáticas import matplotlib.pyplot as plt # para fazer gráficos # Primeira forma de resolu

Derivada Numerica

Python
4 years ago
import math, numpy as np # para usar expressões matemáticas from matplotlib import pyplot as plt # para fazer gráficos def f(u): # Função f(u) para testarmos os métodos .

Teste-vetores

Python
4 years ago
import math, numpy as np # para usar expressões matemáticas from matplotlib import pyplot as plt # para fazer gráficos # Resolução da equação u''(t)=-u(t), u(0)=0 e u'(0)=1. escrira como u'=v e v'=-u, u(0)=0 e v(0)=1. L=1

Teste-aula-10-06

Python
4 years ago
import math, numpy as np # para usar expressões matemáticas from matplotlib import pyplot as plt # para fazer gráficos # Resolução da equação u''(t)=-u(t), u(0)=0 e u'(0)=1. escrira como u'=v e v'=-u, u(0)=0 e v(0)=1. L=1

Taylor2

Python
4 years ago
import math # para usar expressões matemáticas import matplotlib.pyplot as plt # para fazer gráficos # Um exemplo def df(u): # Definição de f(u)=u p=u return p a=0 b=1

Problema Cachorro Coelho

Python
4 years ago
import math # para usar expressões matemáticas from matplotlib import pyplot as plt # para fazer gráficos # Resolução do problema do cachorro e do coelho com o método de Euler L=80 #

Subgradb

R
4 years ago
n=50 a=-5;b=5;x=0*1:n for ( k in 1:n){ # Nós de Chebyshev reescalados. x[k]=(a+b)/2+(b-a)*cos((2*k-1)/(2*n)*pi )/2} y=1/(1+x^2) n=length(x) plot(x,y,col="red")

SubGrad-test

R
4 years ago
n=50 a=-5;b=5;x=0*1:n for ( k in 1:n){ # Nós de Chebyshev reescalados. x[k]=(a+b)/2+(b-a)*cos((2*k-1)/(2*n)*pi )/2} y=1/(1+x^2) n=length(x) plot(x,y,col="red")

Exemplo Bissecção

Python
4 years ago
import math def f(u): # Definição de f(u)=usen(u)cos(u) p=u*math.sin(u)*math.cos(u) return p print(f(0))

Bestfit!

R
4 years ago
# Test points x=c(-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7) y=c(-9,-4,-6,-3,-2,-1,2,3,5,3,7,4,8) plot(x,y) #1. Ordinary least square -------------------------------------------------------------------------- # If p(x)=a+bx # Let A=[x_i^(j-1)] and u=(a,b).

Test

R
4 years ago
# Truncate the sum at ondex p p=2 F<-function(u){ # Vectorial function F(x,y)=(f(x,y),g(x,y)=(0,0). x=u[1] y=u[2] f = x + y^(3^2)/3 + x^(3^5)/(3^2) +y^(3^7)/(3^3) + x^(3^(10))/(3^4) g = y + x^(3^3)/3 + y^(3^5)/(3^2) +x^(3^8)/(3^3)

constOpitmin-c

R
4 years ago
# We need to minimize u^TAu+2b^Tu. # Let us constraining u>=0. u0=c(3,2,1) # is an initial guess. A=matrix(c(2,1,-1,1,3,0,-1,0,4),3,3); b=-c(4,2,1) A;b solve(A,-b) ## Solves linear and quadratic programming problems

CG-method

R
4 years ago
# Linear system Au=v. c=c(1,2,1,-1,3,2,4,4,4,4,3,4,2,0,1,5) A=matrix(c,4,4,,byrow=TRUE); A # Matrix A b=c( 5, 16, 22,15); b # Vector v f<-function(u){A%*%u-b} # Au=v when f(u)=0. B=t(A)%*%A; bb=t(A)%*%b # A*Au=A*v

Bisect-test

R
4 years ago
f<-function(x){x*cos(x)+1} curve(f,0,5) # Bisection's method a=0 # Initial guess b=3 # Initial guess n=10 for (i in 1:n){