34 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
재훈 vor etwa 17 Stunden
Bearbeitet: Torsten vor etwa 7 Stunden
In MATLAB Online öffnen
Hello, I am looking for the estimation error of Simpson's rule of thirds. When dx is 1.01, the integral value is 2908800 and the error is 0.01, but the estimation error is 7.0844e-21. Where did it go wrong? I think In this part, the 5th coefficient is verry verry small, so it seems that the value will always be low. Isn't the estimation error always accurate?
clc; clear all; close all;
a = -1.93317553181561E-24;
b = 3.788630291530091e-21;
c = -2.3447910280083294e-18
d = -0.019531249999999518;
e = 18.74999999999999
fun = @(t) a.*t.^5 + b.*t.^4 + c.*t.^3 + d.*t.^2+e.*t
x = 0:0.1:960;
fx =fun(x);
n=960;
dx=1.01;
int=0;
for i =1:n
plot(x, fx,'k','linewidth',2);
mid=((i-1)+i)/2;
fx_mid = fun(mid);
fx_left = fun(i-1);
fx_right = fun(i);
area_temp = dx/6*(fx_left +4*fx_mid+fx_right);
int = int + area_temp;
x_segment = linspace(i-1, i,100);
Px = fx_left * ((x_segment-mid).*(x_segment-i))/((i-1-mid)*(i-1-i))...
+ fx_mid*((x_segment-i+1)).*(x_segment-i)/((mid-i+1)*(mid-i))...
+ fx_right * ((x_segment-i+1).*(x_segment-mid))/((i-i+1)*(i-mid));
area(x_segment,Px); hold on;
end
C=480;
E_a = -((960.^5)/(2880.*(960/1.01).^4)).*(a.*120.*C+24.*b);%Is there a problem here?
disp('E_a');
disp(E_a);
disp(int);
int_true = 2880000
rel_error=norm(int_true-int)/norm(int_true);
disp('rel_error');
disp(rel_error);
4 Kommentare 2 ältere Kommentare anzeigen2 ältere Kommentare ausblenden
2 ältere Kommentare anzeigen2 ältere Kommentare ausblenden
Torsten vor etwa 17 Stunden
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/2121401-the-estimation-error-is-strangely-obtained-from-simpson-s-1-3-rule#comment_3168641
Bearbeitet: Torsten vor etwa 12 Stunden
Why do you insert C = 480 in the formula ?
And did you think about all the errors that arise because the function evaluation is imprecise and because you lose precision when summing the 960 values in the variable "int" ?
Maybe using advanced precision with vpa can help.
재훈 vor etwa 14 Stunden
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/2121401-the-estimation-error-is-strangely-obtained-from-simpson-s-1-3-rule#comment_3168746
Oh I didn't know that.
재훈 vor etwa 14 Stunden
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/2121401-the-estimation-error-is-strangely-obtained-from-simpson-s-1-3-rule#comment_3168781
I chose 480, which is the middle value between 0 and 960.
I didn't know to think about all the errors that occur due to loss of precision when summing 960 values in variable "int".
I know this is really hard, but could you tell me about using advanced precision with vpa?
Torsten vor etwa 7 Stunden
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/2121401-the-estimation-error-is-strangely-obtained-from-simpson-s-1-3-rule#comment_3169231
Bearbeitet: Torsten vor etwa 7 Stunden
I didn't know to think about all the errors that occur due to loss of precision when summing 960 values in variable "int"
Plus the error in evaluating a polynomial with such small coefficients. You will have to go the symbolic way (see below).
Melden Sie sich an, um zu kommentieren.
Melden Sie sich an, um diese Frage zu beantworten.
Antworten (2)
recent works vor etwa 17 Stunden
The error calculation in your code should be
C = 480;
f4_max = -1.324287168211725E-19; % This is an approximation
h = 1.01;
E_a = -(960 / 180) * (h^4) * f4_max;
disp('E_a');
disp(E_a);
0 Kommentare -2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden
-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden
Melden Sie sich an, um zu kommentieren.
Torsten vor etwa 13 Stunden
Bearbeitet: Torsten vor etwa 13 Stunden
In MATLAB Online öffnen
syms a b c d e real
syms t real
f(t) = a*t^5 + b*t^4 + c*t^3 + d*t^2 + e*t;
s = 0;
i = -1/2;
while i < 959.5
i = i + 1;
tleft = i-1/2;
tmiddle = i;
tright = i+1/2;
fleft = f(tleft);
fmiddle = f(tmiddle);
fright = f(tright);
s = s + sym(1)/sym(6)*(fleft+sym(4)*fmiddle+fright);
end
s = simplify(s)
s=
s_exact = int(f,t,0,960)
s_exact=
difference = s-s_exact
difference=
double(subs(difference,[a,b],[-1.93317553181561E-24,3.788630291530091e-21]))
ans = -6.8079e-21
0 Kommentare -2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden
-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden
Melden Sie sich an, um zu kommentieren.
Melden Sie sich an, um diese Frage zu beantworten.
Es ist ein Fehler aufgetreten
Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom(English)
Asien-Pazifik
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
Kontakt zu Ihrer lokalen Niederlassung