# problem with NDsolve of piecewise function

Posted 9 years ago
4369 Views
|
1 Reply
|
0 Total Likes
|
 Hi, I have a problem trying to solve a differentail equation: neff2a[x_] = Piecewise[{{0.0, x <= zero}, {neff2[x][[2, 1, 2, 1]], zero < x < d}, {0.0, x >= d}}] where neff2[x] element is a constant value, so it is a step function:.I define differential equation: ps2 = D[D[V2[x], x], x] == neff2a[x]/\[Kappa] So it is defined like that:I'm trying to solve the equation: psres2 = NDSolve[{ps2, V2[0] == 0.0, V2[d] == U}, V2[x], {x, 0.0, d}] but I get: NDSolve::bvdisc: NDSolve is not currently able to solve boundary value problems with discrete variables. >> why? Is there any way to solve this equation by Mathematica?Thanks in advance, Mariusz
1 Reply
Sort By:
Posted 9 years ago
 If U isn't defined, you're asking a numerical algorithm, NDSolve, to handle a symbolic problem. I was able to do a problem similar to yours using DSolve.f[x_] = UnitStep[x] - UnitStep[x - 1];In[12]:= sln = DSolve[{y''[x] == f[x], y[0] == 0, y[1] == u}, y, x]Out[12]= {{y -> Function[{x}, 1/2 (-1 + 2 u) x + 1/2 (-1 + x + 2 u x) + 1/2 (1 - 2 u) x UnitStep[x] + UnitStep[ 1 - x] (1/2 (1 - x - 2 u x) + 1/2 (-x + 2 u x + x^2) UnitStep[x])]}}
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments