# Question:How to solve second order PDE depending on two variables with finite difference in maple

## Question:How to solve second order PDE depending on two variables with finite difference in maple

Maple

i follow

http://www.maplesoft.com/applications/view.aspx?SID=4706

and edit existing code to solve a equation and got some questions and error, How to solve pde with finite difference in maple?

r := 0.03;
K := 20;
Smax := 20;
T := 1;
ex1 := diff(y(x,t), t) + r*x*diff(y(x,t), x) + 1/2*sigma^2*x^2*diff(y(x,t), x\$2) + x*diff(y(x,t), x)*diff(y(x,t), t) = r*y(x,t);

bc1 := y(0,0)=K*exp(-r), y(Smax,0)=0;
a := 0;
b := 1;
N := 10;
h := (b-a)/N;
dt := T/N;

i am not sure how to change X := i -> a+i*h:

X := i -> a+i*h:
'X'[i] = X(i);
Yt  := (i,j) -> (y[i,j]-y[i,j-1])/dt;
Yp  := (i,j) -> (y[i+1,j]-y[i-1,j])/2/h;
Ypp := (i,j) -> (y[i+1,j]-2*y[i,j]+y[i-1,j])/h^2;
for k from 1 to N-1 do
eq[i,j] := eval( ex1,
{x=X(i), y(x,t)=y[i,j],
diff(y(x,t),t)=Yt(i,j),
diff(y(x,t),x)=Yp(i,j),
diff(y(x,t),x\$2)=Ypp(i,j)} );
end do;

*** what do the following five lines do?
*** is it needed for exact_sol1 := combine(pdsolve( { ex1, bc1 }, y(x,t) ));?
***
eq[0] := y[0] = rhs(bc1[1]);
eq[N] := y[N] = rhs(bc1[2]);
fd_sol1 := fsolve( {seq( eq[k], k=0..N )}, {seq( y[k], k=0..N )} );
fd_table1 := eval( seq([X(k),y[i,j]],i=0..N,j=0..N), fd_sol1 );
Matrix([fd_table1]);
**************

infolevel[pdsolve] := 3:
exact_sol1 := combine(pdsolve( { ex1, bc1 }, y(x,t) ));
infolevel[pdsolve] := 0:

Error, (in pdsolve/sys/info) found functions with same name but depending on different arguments in the given DE system: {y(0, 0), y(20, 0), y(x, t)}

﻿