Does anyone know what does /; mean for example:V[n_][i_/;i<=imax,0];=V[n][i,0]=0
in Mathematica?
It's part of a program to draw the eletrical potential function of a rectangular metal trough using the finite-difference methods.
Here's the improved one, but still cannot work.
V[0][i_, j_] := 0;
tol = 0.0025;
imax = 20; jmax = 20;
V[n_][i_, 0] := V[n][i, 0] = 0;
V[n_][i_, jmax] := V[n][i, jmax] = 100*Sin[0.05*Pi*i];
V[n_][0, j_] := V[n][0, j] = 0;
V[n_][imax, j_] := V[n][imax, j] = 0;
V[n_][i_, j_] := V[n][i, j] = (1/4)*(V[n - 1][i + 1, j] +
V[n - 1][i - 1, j] + V[n - 1][i, j + 1] + V[n - 1][i, j - 1]);
For[m = 1, Max[Table[Abs[V[m][i, j] - V[m - 1][i, j]], {i, 1, imax - 1}, {j, 1, jmax - 1}]] >= tol, m++;
If[m > 20, Break[]]];
Print[m];
Show[ListPlot3D[Table[V[m][i, j], {j, 0, 20}, {i, 0, 20}]], BoxRatios -> {1, 1, 0.85}, PlotRange -> {0, 1}, Axes -> True, AxesLabel -> {"x", "y", "V"}]
I've already get the point through the reference of Wolfram. And here is the web
https://reference.wolfram.com/language/ref/Condition.html
. Thanks for @agentp help