2 added 857 characters in body
source | link

I am trying to achieve two things. The first thing is I want to define a function in Mathematica which is the solution of a PDE. A simple example:

sol := NDSolve[{D[f[x,y],x,y] == 2*x*y, f[0,y] == 0, f[x,0] == 0}, f,{x, 0, 10}, {y, 0, 10}]
g[x_,y_] := f[x,y] /. sol

But this doesn't work and I don't know why.

The second thing is, I want to solve a PDE with NDSolve which involves the derivative of a solution of another PDE. For example

 sol := NDSolve[{D[f[x,y],x,y] == D[g[x],x] * y, D[g[x],{x,2}] == 2, g[0] == 0, f[0,y] == 0, f[x,0] == 0}, f,{x, 0, 10}, {y, 0, 10}]

Does anyone know how to do that?

Thank you very much for your help!

I tried to use the suggestions to solve the following PDEs and it doesn't seem to work: I try to solve the following system of PDEs:

T = 1;
sigma = 1;
K = 10;
rho = 0.5;
gamma = 1;
mu = 1;
a = 1;

sol = NDSolve[{D[p[t,y,s],t] + (a - mu * rho - 
    - (1-rho^2) * sigma^2 * y * D[g[t,y],t])*D[p[t,y,s],y]
    + 0.5*sigma^2 * D[p[t,y,s],{y,2}] * y + sigma^2 * y * rho * s *   D[p[t,y,s],y,s] 
    + 0.5 * sigma^2 * y * s^2* D[p[t,y,s],{s,2}] +  
    0.5 * sigma^2 * gamma*(1-rho^2)* y * D[p[t,y,s],y]^2 == 0,
-D[g[t,y,z],t] + 0.5 * D[g[t,y,z],y]^2*(1-rho^2)*sigma^2*y 
    - 0.5 D[g[t,y],{y,2}]*sigma^2*y - D[g[t,y],y]*a 
    + D[g[t,y],y]*mu*rho - 0.5 (mu^2)/(sigma^2*y) == 0,
g[T,y] == 0, p[T,y,s] == Max[s-K,0],  p[t,y,0] == 0, 
p[t,y,100] == 100 - K ,
(D[p[t,y,s],s] /. s -> 100) == 1
        }, 
{p, g} , {t, 0 , 1}, {y,0.1,10}, {s, 10, 100} , PrecisionGoal -> 10]

I am trying to achieve two things. The first thing is I want to define a function in Mathematica which is the solution of a PDE. A simple example:

sol := NDSolve[{D[f[x,y],x,y] == 2*x*y, f[0,y] == 0, f[x,0] == 0}, f,{x, 0, 10}, {y, 0, 10}]
g[x_,y_] := f[x,y] /. sol

But this doesn't work and I don't know why.

The second thing is, I want to solve a PDE with NDSolve which involves the derivative of a solution of another PDE. For example

 sol := NDSolve[{D[f[x,y],x,y] == D[g[x],x] * y, D[g[x],{x,2}] == 2, g[0] == 0, f[0,y] == 0, f[x,0] == 0}, f,{x, 0, 10}, {y, 0, 10}]

Does anyone know how to do that?

Thank you very much for your help!

I am trying to achieve two things. The first thing is I want to define a function in Mathematica which is the solution of a PDE. A simple example:

sol := NDSolve[{D[f[x,y],x,y] == 2*x*y, f[0,y] == 0, f[x,0] == 0}, f,{x, 0, 10}, {y, 0, 10}]
g[x_,y_] := f[x,y] /. sol

But this doesn't work and I don't know why.

The second thing is, I want to solve a PDE with NDSolve which involves the derivative of a solution of another PDE. For example

 sol := NDSolve[{D[f[x,y],x,y] == D[g[x],x] * y, D[g[x],{x,2}] == 2, g[0] == 0, f[0,y] == 0, f[x,0] == 0}, f,{x, 0, 10}, {y, 0, 10}]

Does anyone know how to do that?

Thank you very much for your help!

I tried to use the suggestions to solve the following PDEs and it doesn't seem to work: I try to solve the following system of PDEs:

T = 1;
sigma = 1;
K = 10;
rho = 0.5;
gamma = 1;
mu = 1;
a = 1;

sol = NDSolve[{D[p[t,y,s],t] + (a - mu * rho - 
    - (1-rho^2) * sigma^2 * y * D[g[t,y],t])*D[p[t,y,s],y]
    + 0.5*sigma^2 * D[p[t,y,s],{y,2}] * y + sigma^2 * y * rho * s *   D[p[t,y,s],y,s] 
    + 0.5 * sigma^2 * y * s^2* D[p[t,y,s],{s,2}] +  
    0.5 * sigma^2 * gamma*(1-rho^2)* y * D[p[t,y,s],y]^2 == 0,
-D[g[t,y,z],t] + 0.5 * D[g[t,y,z],y]^2*(1-rho^2)*sigma^2*y 
    - 0.5 D[g[t,y],{y,2}]*sigma^2*y - D[g[t,y],y]*a 
    + D[g[t,y],y]*mu*rho - 0.5 (mu^2)/(sigma^2*y) == 0,
g[T,y] == 0, p[T,y,s] == Max[s-K,0],  p[t,y,0] == 0, 
p[t,y,100] == 100 - K ,
(D[p[t,y,s],s] /. s -> 100) == 1
        }, 
{p, g} , {t, 0 , 1}, {y,0.1,10}, {s, 10, 100} , PrecisionGoal -> 10]
1
source | link

How to define a function involving NDSolve (and another PDE)

I am trying to achieve two things. The first thing is I want to define a function in Mathematica which is the solution of a PDE. A simple example:

sol := NDSolve[{D[f[x,y],x,y] == 2*x*y, f[0,y] == 0, f[x,0] == 0}, f,{x, 0, 10}, {y, 0, 10}]
g[x_,y_] := f[x,y] /. sol

But this doesn't work and I don't know why.

The second thing is, I want to solve a PDE with NDSolve which involves the derivative of a solution of another PDE. For example

 sol := NDSolve[{D[f[x,y],x,y] == D[g[x],x] * y, D[g[x],{x,2}] == 2, g[0] == 0, f[0,y] == 0, f[x,0] == 0}, f,{x, 0, 10}, {y, 0, 10}]

Does anyone know how to do that?

Thank you very much for your help!