Skip to main content
deleted 73 characters in body
Source Link
David
  • 15k
  • 6
  • 51
  • 82

As far as I know Mathematica can only solve very special cases of partial differential equations exactly. However, since you want to render the solution, a numerical solution will be enough. Here's an example using the heat equation as a placeholder, since I don't know your initial conditions and don't feel like guessing.:

(* Differential equation *)
eqn = D[u[x, t], t] - D[u[x, t], x, x];
(* Boundary/Initial conditions:
   Absorbing boundaries, Gaussian bump *)
ic = {
    u[x, 0] == Exp[-x^2/2],
    u[-10, t] == u[10, t] == Exp[-10^2/2]
};
(* Unleash the fury *)
s = NDSolve[{eqn == 0}~Join~ic, u, {x, -10, 10}, {t, 0, 20}];
(* Visualize result *)
Plot3D[Evaluate[u[x, t] /. s], {x, -10, 10}, {t, 0, 20}]

enter image description here

NDSolve does not care about the type of differential equation, so your variable coefficients aren't a problem (modulo numerical instabilities of course). Replace eqn by your equation and add according initial conditions and you'll be fine. Here's an example of the same equation, only that now the diffusion constant is not $1$ but $e^{-t/3}$, making diffusion disappear over a time scale of $3$:

eqn = D[u[x, t], t] - E^(-t/3) D[u[x, t], x, x];
ic = {
    u[x, 0] == Exp[-x^2/2],
        u[-10, t] == u[10, t] == Exp[-10^2/2]
    };
s = NDSolve[{eqn == 0}~Join~ic, u, {x, -10, 10}, {t, 0, 20}];
Plot3D[Evaluate[u[x, t] /. s], {x, -10, 10}, {t, 0, 20}, AxesLabel -> Automatic, MaxRecursion -> 8, PlotPoints -> 32]

enter image description here

As far as I know Mathematica can only solve very special cases of partial differential equations exactly. However, since you want to render the solution, a numerical solution will be enough. Here's an example using the heat equation as a placeholder, since I don't know your initial conditions and don't feel like guessing.

(* Differential equation *)
eqn = D[u[x, t], t] - D[u[x, t], x, x];
(* Boundary/Initial conditions:
   Absorbing boundaries, Gaussian bump *)
ic = {
    u[x, 0] == Exp[-x^2/2],
    u[-10, t] == u[10, t] == Exp[-10^2/2]
};
(* Unleash the fury *)
s = NDSolve[{eqn == 0}~Join~ic, u, {x, -10, 10}, {t, 0, 20}];
(* Visualize result *)
Plot3D[Evaluate[u[x, t] /. s], {x, -10, 10}, {t, 0, 20}]

enter image description here

NDSolve does not care about the type of differential equation, so your variable coefficients aren't a problem (modulo numerical instabilities of course). Replace eqn by your equation and add according initial conditions and you'll be fine. Here's an example of the same equation, only that now the diffusion constant is not $1$ but $e^{-t/3}$, making diffusion disappear over a time scale of $3$:

eqn = D[u[x, t], t] - E^(-t/3) D[u[x, t], x, x];
ic = {
    u[x, 0] == Exp[-x^2/2],
        u[-10, t] == u[10, t] == Exp[-10^2/2]
    };
s = NDSolve[{eqn == 0}~Join~ic, u, {x, -10, 10}, {t, 0, 20}];
Plot3D[Evaluate[u[x, t] /. s], {x, -10, 10}, {t, 0, 20}, AxesLabel -> Automatic, MaxRecursion -> 8, PlotPoints -> 32]

enter image description here

As far as I know Mathematica can only solve very special cases of partial differential equations exactly. However, since you want to render the solution, a numerical solution will be enough. Here's an example using the heat equation as a placeholder:

(* Differential equation *)
eqn = D[u[x, t], t] - D[u[x, t], x, x];
(* Boundary/Initial conditions:
   Absorbing boundaries, Gaussian bump *)
ic = {
    u[x, 0] == Exp[-x^2/2],
    u[-10, t] == u[10, t] == Exp[-10^2/2]
};
(* Unleash the fury *)
s = NDSolve[{eqn == 0}~Join~ic, u, {x, -10, 10}, {t, 0, 20}];
(* Visualize result *)
Plot3D[Evaluate[u[x, t] /. s], {x, -10, 10}, {t, 0, 20}]

enter image description here

NDSolve does not care about the type of differential equation, so your variable coefficients aren't a problem (modulo numerical instabilities of course). Replace eqn by your equation and add according initial conditions and you'll be fine. Here's an example of the same equation, only that now the diffusion constant is not $1$ but $e^{-t/3}$, making diffusion disappear over a time scale of $3$:

eqn = D[u[x, t], t] - E^(-t/3) D[u[x, t], x, x];
ic = {
    u[x, 0] == Exp[-x^2/2],
        u[-10, t] == u[10, t] == Exp[-10^2/2]
    };
s = NDSolve[{eqn == 0}~Join~ic, u, {x, -10, 10}, {t, 0, 20}];
Plot3D[Evaluate[u[x, t] /. s], {x, -10, 10}, {t, 0, 20}, AxesLabel -> Automatic, MaxRecursion -> 8, PlotPoints -> 32]

enter image description here

variable coefficients example
Source Link
David
  • 15k
  • 6
  • 51
  • 82

As far as I know Mathematica can only solve very special cases of partial differential equations exactly. However, since you want to render the solution, a numerical solution will be enough. Here's an example using the heat equation as a placeholder, since I don't know your initial conditions and don't feel like guessing.

(* Differential equation *)
eqn = D[u[x, t], t] - D[u[x, t], x, x];
(* Boundary/Initial conditions:
   Absorbing boundaries, Gaussian bump *)
ic = {
    u[x, 0] == Exp[-x^2/2],
    u[-10, t] == u[10, t] == Exp[-10^2/2]
};
(* Unleash the fury *)
s = NDSolve[{eqn == 0}~Join~ic, u, {x, -10, 10}, {t, 0, 20}];
(* Visualize result *)
Plot3D[Evaluate[u[x, t] /. s], {x, -10, 10}, {t, 0, 20}]

enter image description here

NDSolve does not care about the type of differential equation, so your variable coefficients aren't a problem (modulo numerical instabilities of course). Replace eqn by your equation and add according initial conditions and you'll be fine. Here's an example of the same equation, only that now the diffusion constant is not $1$ but $e^{-t/3}$, making diffusion disappear over a time scale of $3$:

eqn = D[u[x, t], t] - E^(-t/3) D[u[x, t], x, x];
ic = {
    u[x, 0] == Exp[-x^2/2],
        u[-10, t] == u[10, t] == Exp[-10^2/2]
    };
s = NDSolve[{eqn == 0}~Join~ic, u, {x, -10, 10}, {t, 0, 20}];
Plot3D[Evaluate[u[x, t] /. s], {x, -10, 10}, {t, 0, 20}, AxesLabel -> Automatic, MaxRecursion -> 8, PlotPoints -> 32]

enter image description here

As far as I know Mathematica can only solve very special cases of partial differential equations exactly. However, since you want to render the solution, a numerical solution will be enough. Here's an example using the heat equation as a placeholder, since I don't know your initial conditions and don't feel like guessing.

(* Differential equation *)
eqn = D[u[x, t], t] - D[u[x, t], x, x];
(* Boundary/Initial conditions:
   Absorbing boundaries, Gaussian bump *)
ic = {
    u[x, 0] == Exp[-x^2/2],
    u[-10, t] == u[10, t] == Exp[-10^2/2]
};
(* Unleash the fury *)
s = NDSolve[{eqn == 0}~Join~ic, u, {x, -10, 10}, {t, 0, 20}];
(* Visualize result *)
Plot3D[Evaluate[u[x, t] /. s], {x, -10, 10}, {t, 0, 20}]

enter image description here

NDSolve does not care about the type of differential equation, so your variable coefficients aren't a problem (modulo numerical instabilities of course). Replace eqn by your equation and add according initial conditions and you'll be fine.

As far as I know Mathematica can only solve very special cases of partial differential equations exactly. However, since you want to render the solution, a numerical solution will be enough. Here's an example using the heat equation as a placeholder, since I don't know your initial conditions and don't feel like guessing.

(* Differential equation *)
eqn = D[u[x, t], t] - D[u[x, t], x, x];
(* Boundary/Initial conditions:
   Absorbing boundaries, Gaussian bump *)
ic = {
    u[x, 0] == Exp[-x^2/2],
    u[-10, t] == u[10, t] == Exp[-10^2/2]
};
(* Unleash the fury *)
s = NDSolve[{eqn == 0}~Join~ic, u, {x, -10, 10}, {t, 0, 20}];
(* Visualize result *)
Plot3D[Evaluate[u[x, t] /. s], {x, -10, 10}, {t, 0, 20}]

enter image description here

NDSolve does not care about the type of differential equation, so your variable coefficients aren't a problem (modulo numerical instabilities of course). Replace eqn by your equation and add according initial conditions and you'll be fine. Here's an example of the same equation, only that now the diffusion constant is not $1$ but $e^{-t/3}$, making diffusion disappear over a time scale of $3$:

eqn = D[u[x, t], t] - E^(-t/3) D[u[x, t], x, x];
ic = {
    u[x, 0] == Exp[-x^2/2],
        u[-10, t] == u[10, t] == Exp[-10^2/2]
    };
s = NDSolve[{eqn == 0}~Join~ic, u, {x, -10, 10}, {t, 0, 20}];
Plot3D[Evaluate[u[x, t] /. s], {x, -10, 10}, {t, 0, 20}, AxesLabel -> Automatic, MaxRecursion -> 8, PlotPoints -> 32]

enter image description here

Source Link
David
  • 15k
  • 6
  • 51
  • 82

As far as I know Mathematica can only solve very special cases of partial differential equations exactly. However, since you want to render the solution, a numerical solution will be enough. Here's an example using the heat equation as a placeholder, since I don't know your initial conditions and don't feel like guessing.

(* Differential equation *)
eqn = D[u[x, t], t] - D[u[x, t], x, x];
(* Boundary/Initial conditions:
   Absorbing boundaries, Gaussian bump *)
ic = {
    u[x, 0] == Exp[-x^2/2],
    u[-10, t] == u[10, t] == Exp[-10^2/2]
};
(* Unleash the fury *)
s = NDSolve[{eqn == 0}~Join~ic, u, {x, -10, 10}, {t, 0, 20}];
(* Visualize result *)
Plot3D[Evaluate[u[x, t] /. s], {x, -10, 10}, {t, 0, 20}]

enter image description here

NDSolve does not care about the type of differential equation, so your variable coefficients aren't a problem (modulo numerical instabilities of course). Replace eqn by your equation and add according initial conditions and you'll be fine.