Talaksan:Numerical integration illustration, h=1.png
Mula testwiki
Pumunta sa nabigasyon
Pumunta sa paghahanap
Laki ng pasilip na ito: 412 x 600 na pixel. Ibang resolusyon: 165 x 240 na pixel | 330 x 480 na pixel | 528 x 768 na pixel | 703 x 1,024 na pixel | 1,500 x 2,183 na pixel.
Orihinal na file (1,500 × 2,183 na pixel, laki: 72 KB, uri ng MIME: image/png)
Mula sa Wikimedia Commons ang talaksang ito at posibleng magamit sa ibang proyekto. Makikita sa baba ang paglalarawan sa pahina ng paglalarawan nito roon.
Buod
Lisensiya
| Public domainPublic domainfalsefalse |
| Ang akdang ito ay pinakawalan sa sakop ng madla ng may-akda nito, si Oleg Alexandrov. Magagamit ito sa buong daigdig. Maaaring hindi ito posibleng legal sa ilang mga bansa; kung ganito: Ibinibigay ni Oleg Alexandrov kaninuman ang karapatang gamitin ang akdang ito para sa anumang layunin, na walang anumang kundisyon, maliban na lamang kung ang ganyang mga kundisyon ay kinakailangan sa batas. |
Source code (MATLAB)
% illustration of numerical integration
% compare the Forward Euler method, which is globally O(h)
% with Midpoint method, which is globally O(h^2)
% and the exact solution
function main()
f = inline ('y', 't', 'y'); % will solve y' = f(t, y)
a=0; b=4; % endpoints of the interval where we will solve the ODE
N = 5; T = linspace(a, b, N); h = T(2)-T(1); % the grid
y0 = 1; % initial condition
% solve the ODE
Y_euler = solve_ODE (N, f, y0, h, T, 1); % Forward Euler method
Y_midpt = solve_ODE (N, f, y0, h, T, 2); % midpoint method
T_highres = a:0.1:b; Y_exact = exp(T_highres);
% prepare the plotting window
lw = 3; % curves linewidth
fs = 20; % font size
figure(1); clf; set(gca, 'fontsize', fs); hold on;
% colors
red=[0.867 0.06 0.14];
blue = [0, 129, 205]/256;
green = [0, 200, 70]/256;
% plot the solutions
plot(T, Y_euler, 'color', blue, 'linewidth', lw)
plot(T, Y_midpt, 'color', green, 'linewidth', lw)
plot(T_highres, Y_exact, 'color', red, 'linewidth', lw)
% axes aspect ratio
pbaspect([1 1.5 1]);
% save to disk
disp(sprintf('Grid size is %0.9g', h))
saveas(gcf, sprintf('Numerical_integration_illustration,_h=%0.2g.eps', h), 'psc2');
function Y = solve_ODE (N, f, y0, h, T, method)
Y = 0*T;
Y(1)=y0;
for i=1:(N-1)
t = T(i); y = Y(i);
if method == 1 % forward Euler method
Y(i+1) = y + h*f(t, y);
elseif method == 2 % explicit one step midpoint method
K = y + 0.5*h*f(t, y);
Y(i+1) = y + h*f(t+h/2, K);
else
disp ('Don`t know this type of method');
return;
end
end
Captions
Add a one-line explanation of what this file represents
Items portrayed in this file
depicts English
creator English
some value
source of file English
original creation by uploader English
data size English
73,846 byte
height English
2,183 pixel
width English
1,500 pixel
media type English
image/png
checksum English
441b0ccb992cd08218f5f3a9217d9c134bc77844
Nakaraan ng file
Pindutin ang isang petsa/oras para makita ang file noong puntong yon.
| Petsa/Oras | Thumbnail | Sukat | Tagagamit | Komento | |
|---|---|---|---|---|---|
| ngayon | 03:57, 25 Mayo 2007 | 1,500 × 2,183 (72 KB) | wikimediacommons>Oleg Alexandrov | Make exact curve smooth |
Paggamit sa file
Ginagamit ng sumusunod na pahina ang file na ito: