sarra

270 Reputation

6 Badges

11 years, 128 days

MaplePrimes Activity


These are replies submitted by sarra

@Carl Love 

Thank you very much for the answer.

 

@Carl Love 

Hi Carl Love,

Thank you for the answer.

@acer 

Thank you for your remarks and answer. I make all the change and I used unapply to define the function alpha.

I think all the lines of the code work very well. But only the problem when I put Kernel(x,y)=ln(abs(x-y)) there is something strange... "infinity " is found everywhere in my computation... How can I avoird this problem.

This is the code.   It's work very well, but when I change the kernel function ln(abs(x-y)) there is a problem. How can is solve this problem

Fred.mw

@mehdi jafari 

Thank you for your answer.

 

@acer 

thank your for the answer.

@Mac Dude 

 

Thank you for your answer.

For me, when i put alpha(1,1) I must bet a numeric value but in the code alpha(1,1) is a function pf n and m.

 

@Mac Dude 

 

Thank you for your remark.

restart:
with(LinearAlgebra):
with(plots):
with(PDEtools):
with(IntegrationTools):
interface(rtablesize=20):
d:=1: N:=2: a:=1: h:=a/N:
Kernel(x,y):=ln(abs(x-y)):

 eq2:=int(Kernel(x,y)*phi(y),y=-a..a)=sum(int(Kernel(x,y)*phi(y),y=n*h..(n+d)*h),n=-N..N-d):

Approximate the integral
eq3:=phi->int(Kernel(x,y)*phi(y),y=n*h..(n+d)*h)=add(beta[i,n]*phi((n+i-1)*h),i=1..d+1):
eq4:=int(Kernel(x,y)*phi(y),y=n*h..(n+d)*h)=add(alpha[m,n,i]*phi((n+i-1)*h),i=1..d+1):

Compute the coefficients  beta[i]

Vct_basis:=[seq(x^i,i=0..d+1)]:
fct:=[seq(unapply(Vct_basis[i],x),i=1..d+2)]:


sys:=[seq(eq3(fct[i]),i=1..d+1)]:
x:=m*h:
w := [seq(beta[i,n],i=1..d+1)]:
M,b := GenerateMatrix(sys,w):

M1:=-M: V:=-b:

Vect_beta:=(M1)^(-1).V:# Vect_beta is a vector.

beta[1]:=Vect_beta[1]:  
alpha:=(n,m)->beta[1];
(n, m) -> beta[1]
alpha(1,1);
                                alpha(1, 1)  No display.

@Mac Dude 

Okay, thank you, it's solved.

@mehdi jafari 

Thank you for your answer. It's okay.

@mehdi jafari 

Hi Mehdi, thank you for your answer.

Initialisation

U[i+1,0] := 0;
U[i+1,M+1] := 0;
U[jj,M+2]:=U[jj,M];
U[jj+1,-1]:=U[jj+1,1];
#Loop
for jj from 1 to M do:
  sys[jj] := eval(BTCS_general,j=jj);
od;

Wen I run Mt code U get. I want that all the results in the loop use my initialisation and remplace where ir's necessary  for example U[jj+1,-1]:=U[jj+1,1];

                                U[jj + 1, 1]
                    s u[i + 1, -1]   4 s u[i + 1, 0]   6 s u[i + 1, 1]
   sys1:=   u[i + 1, 1] + -------------- - --------------- + ---------------
                           4                4                 4       
                          h                h                 h        

           4 s u[i + 1, 2]   s u[i + 1, 3]          
         - --------------- + ------------- = u[i, 1]
                  4                4                
                 h                h                 
                     s u[i + 1, 0]   4 s u[i + 1, 1]   6 s u[i + 1, 2]
       sys2:= u[i + 1, 2] + ------------- - --------------- + ---------------
                           4                4                 4       
                          h                h                 h        

                  s u[i + 1, 3]   s u[i + 1, 4]          
                - --------------- + ------------- = u[i, 2]
                   4                4                
                  h                h                 
                     s u[i + 1, 1]   4 s u[i + 1, 2]   6 s u[i + 1, 3]
      sys3:= u[i + 1, 3] + ------------- - --------------- + ---------------
                           4                4                 4       
                          h                h                 h        

            4 s u[i + 1, 4]   s u[i + 1, 5]          
          - --------------- + ------------- = u[i, 3]
                   4                4                
                  h                h                 
                     s u[i + 1, 2]   4 s u[i + 1, 3]   6 s u[i + 1, 4]
     sys4:=   u[i + 1, 4] + ------------- - --------------- + ---------------
                           4                4                 4       
                          h                h                 h        

            4 s u[i + 1, 5]   s u[i + 1, 6]          
          - --------------- + ------------- = u[i, 4]
                   4                4                
                  h                h         

@Joe Riel 

Initialisation

U[i+1,0] := 0;
U[i+1,M+1] := 0;
U[jj,M+2]:=U[jj,M];
U[jj+1,-1]:=U[jj+1,1];
#Loop
for jj from 1 to M do:
  sys[jj] := eval(BTCS_general,j=jj);
od;

Wen I run Mt code U get. I want that all the results in the loop use my initialisation and remplace where ir's necessary  for example U[jj+1,-1]:=U[jj+1,1];

                                U[jj + 1, 1]
                    s u[i + 1, -1]   4 s u[i + 1, 0]   6 s u[i + 1, 1]
   sys1:=   u[i + 1, 1] + -------------- - --------------- + ---------------
                           4                4                 4       
                          h                h                 h        

           4 s u[i + 1, 2]   s u[i + 1, 3]          
         - --------------- + ------------- = u[i, 1]
                  4                4                
                 h                h                 
                     s u[i + 1, 0]   4 s u[i + 1, 1]   6 s u[i + 1, 2]
       sys2:= u[i + 1, 2] + ------------- - --------------- + ---------------
                           4                4                 4       
                          h                h                 h        

                  s u[i + 1, 3]   s u[i + 1, 4]          
                - --------------- + ------------- = u[i, 2]
                   4                4                
                  h                h                 
                     s u[i + 1, 1]   4 s u[i + 1, 2]   6 s u[i + 1, 3]
      sys3:= u[i + 1, 3] + ------------- - --------------- + ---------------
                           4                4                 4       
                          h                h                 h        

            4 s u[i + 1, 4]   s u[i + 1, 5]          
          - --------------- + ------------- = u[i, 3]
                   4                4                
                  h                h                 
                     s u[i + 1, 2]   4 s u[i + 1, 3]   6 s u[i + 1, 4]
     sys4:=   u[i + 1, 4] + ------------- - --------------- + ---------------
                           4                4                 4       
                          h                h                 h        

            4 s u[i + 1, 5]   s u[i + 1, 6]          
          - --------------- + ------------- = u[i, 4]
                   4                4                
                  h                h                 

@mehdi jafari 

Hi Mehdi, thank you very much for your answer.


@mehdi jafari 

Hi Mehdi,

Please, put N=M=2. Then make run in my laptop I get ( Also, the approx solution depend of u[i,j] it's not normal).  Thank you.


 

 

@Preben Alsholm 

Hi Preben,

Thank you for the answer.

 

@itsme 

Hi itsme.

This my code.

TESTESTEst.mw
Many thinks.

2 3 4 5 6 7 8 Page 4 of 10