Diferencia entre revisiones de «Series de Fourier (Grupo CCE)»

De MateWiki
Saltar a: navegación, buscar

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/mat/public_html/w/includes/diff/DairikiDiff.php on line 434
 
(No se muestran 42 ediciones intermedias del mismo usuario)
Línea 1: Línea 1:
{{ TrabajoED | Series de Fourier. Grupo CCE | [[:Categoría:EDP|EDP]]|[[:Categoría:EDP25/26|2025-26]] | Coloma de Lara, Carlos de MIguel y Elena Rodríguez }}
+
{{ TrabajoED | Series de Fourier. Grupo CCE| [[:Categoría:EDP|EDP]]|[[:Categoría:EDP25/26|2025-26]] | Coloma de Lara
== Introducción==
+
Carlos de Miguel  
Este trabajo tiene como objetivo principal profundizar en la '''aproximación de funciones por series trigonométricas''', herramienta fundamental en el estudio de las Ecuaciones en Derivadas Parciales. A través de un estudio numérico y computacional, se analiza cómo la regularidad de una función y el número de términos empleados en su desarrollo afectan a la precisión de la aproximación.
+
  
En este artículo, se abordan tres puntos de los propuestos: primero visualizar la aproximación de la serie de Fourier de una función, segundo comparar la serie de Fourier de una función en términos de la regularidad, y tercero ilustrar el fenómeno de Gibbs al aproximar una función discontinua.
+
Elena Rodríguez }}
 +
 
 +
 
 +
[[Archivo:Seriesdefourier_grupoCCEposter.pdf]]
 +
 
 +
== Visualizar la base trigométrica ==
 +
Vamos a dibujar en una gráfica, con Matlab, los 7 primeros términos de la serie trigonométrica en <math> x\in [-1,1] </math>, para que sea más fácil visualizarla.
 +
{| class="wikitable" style="width: 100%; border: none; background: transparent;"
 +
|-
 +
! style="width: 65%; text-align: left; background: #f2f2f2;" | Implementación en MATLAB
 +
! style="width: 35%; text-align: center; background: #f2f2f2;" | Resultado Gráfico
 +
|-
 +
| style="vertical-align: top;" |
 +
<syntaxhighlight lang="matlab">
 +
% definimos intervalo [-T, T]
 +
T = 1;                 
 +
x = linspace(-T, T, 1000);
 +
n_max = 7;    %numero de terminos         
 +
 
 +
% normalizamos
 +
phi_0_factor = 1/sqrt(2*T);
 +
phi_n_factor = 1/sqrt(T);
 +
 
 +
figure('Color', 'w');
 +
 
 +
%  d0 y dn (Cosenos - Pares)
 +
subplot(2,1,1); hold on;
 +
plot(x, ones(size(x)) * phi_0_factor, 'k', 'LineWidth', 2.5, 'DisplayName', 'd_0');
 +
colors_d = lines(n_max);
 +
for n = 1:n_max
 +
    y_cos = phi_n_factor * cos(n * pi * x / T);
 +
    plot(x, y_cos, 'Color', [colors_d(n,:), 0.5]);
 +
end
 +
title('Funciones de la base para d_0 y d_n (Pares)');
 +
grid on; ylabel('Amplitud');
 +
 
 +
%  cn (Senos - Impares)
 +
subplot(2,1,2); hold on;
 +
colors_c = jet(n_max);
 +
for n = 1:n_max
 +
    y_sin = phi_n_factor * sin(n * pi * x / T);
 +
    plot(x, y_sin, 'Color', [colors_c(n,:), 0.5]);
 +
end
 +
title('Funciones de la base para c_n (Impares)');
 +
grid on; xlabel('x'); ylabel('Amplitud');
 +
</syntaxhighlight>
 +
| style="vertical-align: middle; text-align: center;" |
 +
[[Archivo:Basetrigo_n7_grupoCCE.png|450px|thumb|center|Visualización de la base ortonormal en [-1, 1].]]
 +
|}
 +
 
 +
== Aproximación de una función continua ==
 +
 
 +
En este apartado, aproximamos la función continua <math>f(x) = 1 - 2|1/2 - x|</math> en el intervalo <math>[0, 1]</math>.
 +
 
 +
=== Estudio de Convergencia según el número de términos===
 +
Calculamos los coeficientes <math>a_k</math> mediante la '''fórmula del trapecio''' con una división de <math>10^{-3}</math>. Evaluamos el error en las normas <math>L^2</math> y uniforme (<math>L^\infty</math>) .
 +
 
 +
{| class="wikitable" style="width: 100%; border: none; background: transparent;"
 +
|-
 +
! colspan="2" style="text-align: left; background: #f2f2f2;" | Implementación en MATLAB
 +
|-
 +
| colspan="2" style="vertical-align: top;" |
 +
<syntaxhighlight lang="matlab">
 +
% Parámetros iniciales
 +
dx = 1e-3; % división sugerida
 +
x = 0:dx:1;
 +
f = 1 - 2*abs(0.5 - x);
 +
% Configuración de términos para visualización
 +
valores_n = [1, 5, 10];
 +
figure(1);
 +
plot(x, f, 'k--', 'LineWidth', 2); hold on;
 +
% Bucle para calcular aproximaciones y errores
 +
N_max = 50;
 +
err_L2 = zeros(1, N_max);
 +
err_inf = zeros(1, N_max);
 +
 
 +
for n = 1:N_max
 +
    fn = zeros(size(x));
 +
    for k = 1:n
 +
        % Cálculo de ak mediante trapecio
 +
        integrando = 2 * f .* sin(k * pi * x);
 +
        ak = trapz(x, integrando);
 +
       
 +
        % suma de los términos impares
 +
        fn = fn + ak * sin(k * pi * x);
 +
    end
 +
    % guardar errores en normas L2 y uniforme
 +
    err_L2(n) = sqrt(trapz(x, (f - fn).^2));
 +
    err_inf(n) = max(abs(f - fn));
 +
   
 +
    if ismember(n, valores_n)
 +
        plot(x, fn, 'DisplayName', ['n = ' num2str(n)]);
 +
    end
 +
end
 +
 
 +
title('Aproximación de f(x) por Serie de Fourier (Senos)');
 +
xlabel('x'); ylabel('f(x)');
 +
legend('Original', 'n=1', 'n=5', 'n=10');
 +
grid on;
 +
 
 +
% gráfica de Errores
 +
figure(2);
 +
subplot(2,1,1);
 +
plot(1:N_max, err_L2, 'bo-', 'LineWidth', 1.5);
 +
title('Evolución del Error en Norma L^2');
 +
xlabel('n (términos)'); ylabel('Error'); grid on;
 +
 
 +
subplot(2,1,2);
 +
plot(1:N_max, err_inf, 'ro-', 'LineWidth', 1.5);
 +
title('Evolución del Error en Norma Uniforme');
 +
xlabel('n (términos)'); ylabel('Error'); grid on;
 +
</syntaxhighlight>
 +
|-
 +
! style="width: 50%; text-align: center; background: #f2f2f2;" | Resultado de la Aproximación
 +
! style="width: 50%; text-align: center; background: #f2f2f2;" | Estudio de Convergencia
 +
|-
 +
| style="text-align: center;" | [[Archivo:Funcioncontinuaimagen_grupoCCE.png|400px|thumb|center|Visualización de aproximación de f(x) en [0,1]. ]]
 +
| style="text-align: center;" | [[Archivo:Errores_grupoCCE.png|400px|thumb|center|Errores graficados en norma L2 y uniforme.]]
 +
|}
 +
 
 +
=== Estudio de la Convergencia según la regularidad===
 +
{| class="wikitable" style="width: 100%; border: none; background: transparent;"
 +
|-
 +
! colspan="3" style="text-align: left; background: #f2f2f2;" | Implementación en MATLAB: Comparativa de Regularidad
 +
|-
 +
| colspan="3" style="vertical-align: top;" |
 +
<syntaxhighlight lang="matlab">
 +
% Parámetros iniciales
 +
dx = 1e-3;
 +
x = 0:dx:1;
 +
N = 20; % Número de armónicos para la comparativa
 +
 
 +
% Definición de las tres funciones
 +
f1 = double(x < 0.5);          % 1. Función Salto (C^-1)
 +
f2 = 1 - 2*abs(0.5 - x);      % 2. Función Triangular (C^0)
 +
f3 = x.^2 - x;                % 3. Parábola (C^inf)
 +
 
 +
funciones = {f1, f2, f3};
 +
titulos = {'Aproximación Función Salto', 'Aproximación Función f(x)', 'Aproximación Parábola'};
 +
 
 +
for i = 1:3
 +
    f_actual = funciones{i};
 +
    figure(i);
 +
    plot(x, f_actual, 'k--', 'LineWidth', 2); hold on;
 +
   
 +
    % Reconstrucción mediante Serie de Fourier (Base completa)
 +
    L = 1;
 +
    a0 = (2/L) * trapz(x, f_actual);
 +
    fn = (a0/2) * ones(size(x));
 +
   
 +
    for k = 1:N
 +
        ak = (2/L) * trapz(x, f_actual .* cos(2*pi*k*x/L));
 +
        bk = (2/L) * trapz(x, f_actual .* sin(2*pi*k*x/L));
 +
        fn = fn + ak*cos(2*pi*k*x/L) + bk*sin(2*pi*k*x/L);
 +
    end
 +
   
 +
    plot(x, fn, 'r', 'LineWidth', 1.5);
 +
    title(titulos{i});
 +
    xlabel('x'); ylabel('f(x)');
 +
    legend('Original', ['Serie Fourier (N=' num2str(N) ')']);
 +
    grid on;
 +
end
 +
</syntaxhighlight>
 +
|-
 +
! style="width: 33%; text-align: center; background: #f2f2f2;" | 1. Función f(x) (Continua)
 +
! style="width: 33%; text-align: center; background: #f2f2f2;" | 2. Parábola (Suave)
 +
! style="width: 33%; text-align: center; background: #f2f2f2;" | 3. Función Salto (Discontinua)
 +
|-
 +
| style="text-align: center;" |
 +
[[Archivo:Triangular_grupoCCE.png|300px|thumb|center|Convergencia moderada sobre todo en el pico.]]
 +
| style="text-align: center;" |
 +
[[Archivo:Parabola_grupoCCE.png|300px|thumb|center|Convergencia rápida.]]
 +
| style="text-align: center;" |
 +
[[Archivo:Salto_grupoCCE.png|300px|thumb|center|]]
 +
|}
 +
 
 +
 
 +
{| class="wikitable" style="width: 100%; border: none; background: transparent;"
 +
|-
 +
! style="width: 65%; text-align: left; background: #f2f2f2;" | Implementación en MATLAB
 +
! style="width: 35%; text-align: center; background: #f2f2f2;" | Resultado Gráfico
 +
|-
 +
| style="vertical-align: top;" |
 +
<syntaxhighlight lang="matlab">
 +
dx = 1e-3;
 +
x = 0:dx:1;
 +
N_max = 50;
 +
f1 = double(x < 0.5);       
 +
f2 = 1 - 2*abs(0.5 - x);     
 +
f3 = x.^2 - x;               
 +
funciones = {f1, f2, f3};
 +
colores = {'b', 'r', 'g'};
 +
nombres = {'Salto', 'Triangular f(x)', 'Parábola'};
 +
 
 +
figure(1);
 +
hold on;
 +
 
 +
for i = 1:3
 +
    f_target = funciones{i};
 +
    err_L2 = zeros(1, N_max);
 +
    for n = 1:N_max
 +
        a0 = 2 * trapz(x, f_target);
 +
        fn = (a0/2) * ones(size(x));
 +
        for k = 1:n
 +
            ak = 2 * trapz(x, f_target .* cos(2*pi*k*x));
 +
            bk = 2 * trapz(x, f_target .* sin(2*pi*k*x));
 +
            fn = fn + ak*cos(2*pi*k*x) + bk*sin(2*pi*k*x);
 +
        end
 +
        % cálculo del error
 +
        err_L2(n) = sqrt(trapz(x, (f_target - fn).^2));
 +
    end
 +
   
 +
    plot(1:N_max, err_L2, 'Color', colores{i}, 'LineWidth', 2, 'DisplayName', nombres{i});
 +
end
 +
 
 +
set(gca, 'YScale', 'log'); % escala logarítmica para ver mejor las diferencias
 +
title('Evolución del Error Residual (Norma L^2)');
 +
xlabel('Número de terminos (N)'); ylabel('Error (log)');
 +
legend('show'); grid on;
 +
</syntaxhighlight>
 +
| style="vertical-align: middle; text-align: center;" |
 +
[[Archivo:Erroresfunciones_grupoCCE.png|450px|thumb|center|Error de cada función.]]
 +
|}
 +
 
 +
 
 +
{| class="wikitable" style="text-align: center; width: 100%;"
 +
|+ Coeficientes de Fourier bn
 +
! n !! Función Salto  !! Función Triangular !! Parábola x^2-x
 +
|-
 +
| '''1''' || 1.2732 || 0.8106 || -0.2580
 +
|-
 +
| '''3''' || 0.4244 || -0.0901 || -0.0096
 +
|-
 +
| '''5''' || 0.2546 || 0.0324 || -0.0021
 +
|-
 +
| '''7''' || 0.1819 || -0.0165 || -0.0008
 +
|-
 +
| '''9''' || 0.1415 || 0.0100 || -0.0004
 +
|-
 +
| '''11''' || 0.1157 || -0.0067 || -0.0002
 +
|-
 +
| '''13''' || 0.0979 || 0.0048 || -0.0001
 +
|-
 +
| '''15''' || 0.0849 || -0.0036 || -0.0001
 +
|-
 +
! Decaimiento !! '''1/n'''  !! '''1/n²'''  !! '''1/n³'''
 +
|}
 +
 
 +
[[Categoría:EDP]]
 +
[[Categoría:EDP25/26]]

Revisión actual del 08:22 19 feb 2026

Trabajo realizado por estudiantes
Título Series de Fourier. Grupo CCE
Asignatura EDP
Curso 2025-26
Autores Coloma de Lara

Carlos de Miguel

Elena Rodríguez

Este artículo ha sido escrito por estudiantes como parte de su evaluación en la asignatura


Archivo:Seriesdefourier grupoCCEposter.pdf

1 Visualizar la base trigométrica

Vamos a dibujar en una gráfica, con Matlab, los 7 primeros términos de la serie trigonométrica en [math] x\in [-1,1] [/math], para que sea más fácil visualizarla.

Implementación en MATLAB Resultado Gráfico
% definimos intervalo [-T, T]
T = 1;                  
x = linspace(-T, T, 1000); 
n_max = 7;    %numero de terminos          

% normalizamos
phi_0_factor = 1/sqrt(2*T);
phi_n_factor = 1/sqrt(T);

figure('Color', 'w');

%  d0 y dn (Cosenos - Pares)
subplot(2,1,1); hold on;
plot(x, ones(size(x)) * phi_0_factor, 'k', 'LineWidth', 2.5, 'DisplayName', 'd_0');
colors_d = lines(n_max);
for n = 1:n_max
    y_cos = phi_n_factor * cos(n * pi * x / T);
    plot(x, y_cos, 'Color', [colors_d(n,:), 0.5]);
end
title('Funciones de la base para d_0 y d_n (Pares)');
grid on; ylabel('Amplitud');

%  cn (Senos - Impares)
subplot(2,1,2); hold on;
colors_c = jet(n_max);
for n = 1:n_max
    y_sin = phi_n_factor * sin(n * pi * x / T);
    plot(x, y_sin, 'Color', [colors_c(n,:), 0.5]);
end
title('Funciones de la base para c_n (Impares)');
grid on; xlabel('x'); ylabel('Amplitud');
Visualización de la base ortonormal en [-1, 1].

2 Aproximación de una función continua

En este apartado, aproximamos la función continua [math]f(x) = 1 - 2|1/2 - x|[/math] en el intervalo [math][0, 1][/math].

2.1 Estudio de Convergencia según el número de términos

Calculamos los coeficientes [math]a_k[/math] mediante la fórmula del trapecio con una división de [math]10^{-3}[/math]. Evaluamos el error en las normas [math]L^2[/math] y uniforme ([math]L^\infty[/math]) .

Implementación en MATLAB
% Parámetros iniciales
dx = 1e-3; % división sugerida
x = 0:dx:1;
f = 1 - 2*abs(0.5 - x);
% Configuración de términos para visualización 
valores_n = [1, 5, 10]; 
figure(1);
plot(x, f, 'k--', 'LineWidth', 2); hold on;
% Bucle para calcular aproximaciones y errores 
N_max = 50; 
err_L2 = zeros(1, N_max);
err_inf = zeros(1, N_max);

for n = 1:N_max
    fn = zeros(size(x));
    for k = 1:n
        % Cálculo de ak mediante trapecio
        integrando = 2 * f .* sin(k * pi * x);
        ak = trapz(x, integrando);
        
        % suma de los términos impares
        fn = fn + ak * sin(k * pi * x);
    end
    % guardar errores en normas L2 y uniforme 
    err_L2(n) = sqrt(trapz(x, (f - fn).^2));
    err_inf(n) = max(abs(f - fn));
    
    if ismember(n, valores_n)
        plot(x, fn, 'DisplayName', ['n = ' num2str(n)]);
    end
end

title('Aproximación de f(x) por Serie de Fourier (Senos)');
xlabel('x'); ylabel('f(x)');
legend('Original', 'n=1', 'n=5', 'n=10');
grid on;

% gráfica de Errores 
figure(2);
subplot(2,1,1);
plot(1:N_max, err_L2, 'bo-', 'LineWidth', 1.5);
title('Evolución del Error en Norma L^2');
xlabel('n (términos)'); ylabel('Error'); grid on;

subplot(2,1,2);
plot(1:N_max, err_inf, 'ro-', 'LineWidth', 1.5);
title('Evolución del Error en Norma Uniforme');
xlabel('n (términos)'); ylabel('Error'); grid on;
Resultado de la Aproximación Estudio de Convergencia
Visualización de aproximación de f(x) en [0,1].
Errores graficados en norma L2 y uniforme.

2.2 Estudio de la Convergencia según la regularidad

Implementación en MATLAB: Comparativa de Regularidad
% Parámetros iniciales
dx = 1e-3;
x = 0:dx:1;
N = 20; % Número de armónicos para la comparativa

% Definición de las tres funciones
f1 = double(x < 0.5);          % 1. Función Salto (C^-1)
f2 = 1 - 2*abs(0.5 - x);       % 2. Función Triangular (C^0)
f3 = x.^2 - x;                 % 3. Parábola (C^inf)

funciones = {f1, f2, f3};
titulos = {'Aproximación Función Salto', 'Aproximación Función f(x)', 'Aproximación Parábola'};

for i = 1:3
    f_actual = funciones{i};
    figure(i);
    plot(x, f_actual, 'k--', 'LineWidth', 2); hold on;
    
    % Reconstrucción mediante Serie de Fourier (Base completa)
    L = 1;
    a0 = (2/L) * trapz(x, f_actual);
    fn = (a0/2) * ones(size(x));
    
    for k = 1:N
        ak = (2/L) * trapz(x, f_actual .* cos(2*pi*k*x/L));
        bk = (2/L) * trapz(x, f_actual .* sin(2*pi*k*x/L));
        fn = fn + ak*cos(2*pi*k*x/L) + bk*sin(2*pi*k*x/L);
    end
    
    plot(x, fn, 'r', 'LineWidth', 1.5);
    title(titulos{i});
    xlabel('x'); ylabel('f(x)');
    legend('Original', ['Serie Fourier (N=' num2str(N) ')']);
    grid on;
end
1. Función f(x) (Continua) 2. Parábola (Suave) 3. Función Salto (Discontinua)
Convergencia moderada sobre todo en el pico.
Convergencia rápida.
Salto grupoCCE.png


Implementación en MATLAB Resultado Gráfico
dx = 1e-3;
x = 0:dx:1;
N_max = 50;
f1 = double(x < 0.5);         
f2 = 1 - 2*abs(0.5 - x);      
f3 = x.^2 - x;                
funciones = {f1, f2, f3};
colores = {'b', 'r', 'g'};
nombres = {'Salto', 'Triangular f(x)', 'Parábola'};

figure(1); 
hold on;

for i = 1:3
    f_target = funciones{i};
    err_L2 = zeros(1, N_max);
    for n = 1:N_max
        a0 = 2 * trapz(x, f_target);
        fn = (a0/2) * ones(size(x));
        for k = 1:n
            ak = 2 * trapz(x, f_target .* cos(2*pi*k*x));
            bk = 2 * trapz(x, f_target .* sin(2*pi*k*x));
            fn = fn + ak*cos(2*pi*k*x) + bk*sin(2*pi*k*x);
        end
        % cálculo del error 
        err_L2(n) = sqrt(trapz(x, (f_target - fn).^2));
    end
    
    plot(1:N_max, err_L2, 'Color', colores{i}, 'LineWidth', 2, 'DisplayName', nombres{i});
end

set(gca, 'YScale', 'log'); % escala logarítmica para ver mejor las diferencias
title('Evolución del Error Residual (Norma L^2)');
xlabel('Número de terminos (N)'); ylabel('Error (log)');
legend('show'); grid on;
Error de cada función.


Coeficientes de Fourier bn
n Función Salto Función Triangular Parábola x^2-x
1 1.2732 0.8106 -0.2580
3 0.4244 -0.0901 -0.0096
5 0.2546 0.0324 -0.0021
7 0.1819 -0.0165 -0.0008
9 0.1415 0.0100 -0.0004
11 0.1157 -0.0067 -0.0002
13 0.0979 0.0048 -0.0001
15 0.0849 -0.0036 -0.0001
Decaimiento 1/n 1/n² 1/n³