sarra

270 Reputation

6 Badges

11 years, 131 days

MaplePrimes Activity


These are replies submitted by sarra

@Preben Alsholm 

Thank you for your answer.

I have two remarks,

first: To show that the error is O(h^2), we give the expansion of abs(E-Exact) "taylor(abs(E-Exact),h=0)" instead of taylor(Exact,h=0).

Second: if what I say is true,  When I try to compute taylor(abs(E-Exact),h=0); I get this message Error, (in series/abs) no series at 0.  But if I add assume(h, real); I get the taylor expansion of  abs(E-Exact), and exacty I get  1/2*h^2+O(h^4).

Are you agree with me.

 

 

 

 

@Preben Alsholm 

First, Thank you  very much, for your help.

I see y[1] is computed using Euler Method. Also, I agrre i means the imaginary unit  I.

Now, I want:  Plotting the discrepancy between the numeric and exact values of y(1) versus h on log log plot

For me, I must add a loop  versus  h, only to compute y[1] using Euler Method. Then compute the   discrepancy between the numeric and exact values of y(1) . If this is true, How can I definie the difference between tow complex number in this case. 

I see that a loop must be added ( according to h) but How???

Thank you very much for your help.

 

 

 

@YasH 

Finaly, the first steps work.

> MidpointMethod := proc (f, a, b, N) local x, y, n, h, datamidpoint; y := array(0 .. N); h := evalf(b-a)/N; x[0] := a; y[0] := 1; x[1] := a+h; y[1] := 2; for n to N-1 do x[n+1] := a+(n+1)*h; y[n+1] := y[n-1]+2*h*f(x[n], y[n]) end do; datamidpoint := [seq([x[n], y[n]], n = 0 .. N)] end proc;

proc(f, a, b, N)  ...  end;
> NULL;
> f := proc (x, y) options operator, arrow; x+y end proc;
(x, y) -> x + y
> MidpointMethod(f, 0, 1, 12);
        [[0, 1], [0.08333333333, 2], [0.1666666667, 1.347222222],

          [0.2500000000, 2.252314815], [0.3333333333, 1.764274691],

          [0.4166666666, 2.601916152], [0.5000000000, 2.267371827],

          [0.5833333333, 3.063144790], [0.6666666666, 2.875118181],

          [0.7500000000, 3.653442265], [0.8333333333, 3.609025225],

          [0.9166666666, 4.393835358], [1.000000000, 4.494108896]]
> plot(MidpointMethod(f, 0, 1, 12));
It's work... OKAY, thanks for your help and your remarks.

 

First, thanks for your help.  I would like to give an answer about this question:

Problem :y'(x)=i*y with y(0)=-i;

Plotting the discrepancy between the numeric and exact values of y(1) versus h on log log plot.

Note you will have to use some other method to complete the first step such as forward Euler or The Huen method.

I have not any idea.

Thanks for your remarks.

 

 

 

 

 

 

 

Thanks in advance for your help.

 

@Preben Alsholm 

Please, I don't understant why this procedure doesn't work. Thanks for your help

 MidpointMethod:=proc(f,a,b, N)
y:=array(0..N):
h:=evalf(b-a)/N;
x[0]:=a;
y[0]:=1:
x[1]=a+h;
y[1]=2;
 for n from 1 to N-1 do
    x[n] := a+n*h;
    y[n+1] = y[n-1] +  2h f( x[n], y[n] );
od;
end proc;
F:=(x,y)-> i*y;
 MidpointMethod(F,0,1,20);
// Generate the sequence of approximations for Midpoint Method.
data_midpoint := [seq([x[n],y[n]],n=0..N)]:
//Generate plot which is not displayed but instead stored under the name fig_midpoint for example
fig_midpoint:= plot(data_midpoint,style=

point,color=blue)

@Preben Alsholm 

 

First, Thanks for your remarks.

My proc is:

 MidpointMethod=proc(f,a,b, N)
y:=array(0..N):
h:=evalf(b-a)/N;
x[0]:=a;
y[0]:=1:
x[1]=a+h;
y[1]=2;
 for n from 1 to N-1 do
    x[n] := a+n*h;
    y[n+1] = y[n-1] +  2h f( x[n], y[n] );
od:
y
end proc:

f:=(x,y)->2*x+y;

MidpointMethod(f,0,1,20)

// Generate the sequence of approximations for Midpoint Method.
data_midpoint := [seq([x[n],y[n]],n=0..20)]:

//Generate plot which is not displayed but instead stored under the name fig_midpoint for example
fig_midpoint:= plot(data_midpoint,style=point,color=blue)

 

But does not work, I don't undersantd the problem. Any help please. thanks very much.

 

 

 

 

 

@YasH  My goal is to give an answer of the following questions,

I arrive to fnish the code, but I have something which not clear for me.

@Preben Alsholm 

 

Thanks for the link, I will see now. Thanks one again.

 

 

Thanks for your remarks.  It's is corrected now. Your remarks are very welcome.

I have a second question,  I don't understand It. please can someone help me please.

Design your Own 3-stage Explicit Runge Kutta Method  with one step  error 0(h^4)

 

 

First 8 9 10 Page 10 of 10