How Do I Solve A*(Uxx+Uyy)-B(x)*Ux=0 in Mathematica?

  • Thread starter Thread starter JG
  • Start date Start date
JG
Messages
2
Reaction score
0
I must solve A*(Uxx+Uyy)-B(x)*Ux=0 , where Uxx means ssecond partial derivative of U on x and U(x,y); Ais constant and B(x) is function of x! The eq has BC dU/dz=0 and dU/dy=0 IC U(0,y)=1 for -1<y<0 and U(0,y)=1 for 0<y<1 in Mathematica!
Can anybody help me with some example? Thanks, Jan mail: jan_golob@email.si
 
Physics news on Phys.org
JG said:
I must solve A*(Uxx+Uyy)-B(x)*Ux=0 , where Uxx means ssecond partial derivative of U on x and U(x,y); Ais constant and B(x) is function of x! The eq has BC dU/dz=0 and dU/dy=0 IC U(0,y)=1 for -1<y<0 and U(0,y)=1 for 0<y<1 in Mathematica!
Can anybody help me with some example? Thanks, Jan mail: jan_golob@email.si

Hey JG, don't know why others aren't commenting about your problem but for me it is a bit awkwardly posed. This is what I would consider well-posed:

\text{DE:}\quad Au_{xx}+Au_{yy}-B(x)u_x=0\quad 0\le x \le L

\text{BC:}\quad u_x(0,t)=0\quad u_x(L,t)=0

\text{IC:}\quad u(x,0)=f(x)\quad u_t(x,0)=g(x)

Now saying that's yours but if the problem were this, then I'd use separation of variables and proceed.
 
Last edited:


Sure, I can provide an example for solving this equation in Mathematica. First, we need to define the variables and constants:

A = 2; (*constant*)
B[x_] := x^2; (*function of x*)
U[x_, y_] := u[x, y]; (*defining U as a function of x and y*)

Next, we can use the built-in function DSolve to solve the equation:

DSolve[A*(D[U[x, y], {x, 2}] + D[U[x, y], {y, 2}]) - B[x]*D[U[x, y], x] == 0, U[x, y], {x, y}]

This will give us the general solution to the equation:

{{U[x, y] -> C[1] + C[2]*y + (A*Integrate[B[x], x] + C[3])*x + (A*Integrate[B[x], x, x] + C[4])*y^2}}

Next, we can use the boundary conditions to solve for the constants C[1], C[2], C[3], and C[4]. In this case, we have two boundary conditions at x=0 and three unknown constants, so we will need to use a numerical method to solve for the constants. For example, we can use the finite difference method:

(*creating a grid for x and y*)
xgrid = Table[i, {i, -1, 1, 0.1}];
ygrid = Table[j, {j, -1, 1, 0.1}];

(*creating a matrix for the finite difference method*)
matrix = Table[0, {i, Length[xgrid]}, {j, Length[ygrid]}];

(*filling in the matrix with the equation*)
Do[
If[i == 1, matrix[[i, j]] = D[U[xgrid[], ygrid[[j]]], y]; (*boundary condition at x=0*)
matrix[[i, j]] = 0; (*boundary condition at y=0*)
,
matrix[[i, j]] = A*(D[U[xgrid[], ygrid[[j]]], {x, 2}] + D[U[xgrid[], ygrid[[j]]], {y, 2}]) - B[xgrid[]]*D[U[xgrid[[i
 
Back
Top