# Infinite potential, prevent value to go beyond zero, initial value problem

How do you make a wall potential in Mathematica. Meaning : I want my potential to have a wall at 0 :

$U(x)=\left\{ \begin{split} & x>0 : U(x) = f(x)\\ &x=0: U(x)=U_0 \\ & x<0: U(x)=+\infty \\ \end{split} \right.$

Actually, it is a general question about functions with walls.

• Have a look at Piecewise. – Henrik Schumacher May 22 '18 at 10:21
• Greetings! Make the most of Mma.SE and take the tour now. Help us to help you, write an excellent question. Edit if improvable, show due diligence, give brief context, include minimal working examples of code and data in formatted form. As you receive give back, vote and answer questions, keep the site useful, be kind, correct mistakes and share what you have learned. – rhermans May 22 '18 at 10:59
• This question will be easier to answer and more useful for others if you add a minimal working example of working code and data to show specifically what you are working with. Please edit your question to improve it. Include a minimum example of code that shows the problem and an example of the desired output. – rhermans May 22 '18 at 11:00
• I suggest that you delete the second part from this question and make it a new question, with proper tags and title, so you attract the attention of people with more experience in Differential equations and NDSolveValue. Include exactly the message you get from mathematica. i.e "NDSolveValue::bvdae, NDSolveValue::bvdae: Differential-algebraic equations must be given as initial value problems.". I can't answer further. Probably link to the new question from here. – rhermans May 22 '18 at 19:35

Generally NDSolve should NOT have any problems with functions defined properly using Piecewise. In particular to your problem, it's impossible to comment as you have not shared your code with enough specifics.

u[x_] := Piecewise[{{x^2, x > 0}, {1 - x/2, x < 0}}]

Plot[
u[x]
, {x, -1, 1}
, ExclusionsStyle -> {Red, Blue}
, Exclusions -> Automatic
, Frame -> True
, Axes -> False
]


• Thanks. Now, if I am using NDSolve, the programm writes to me : "NDSolveValue::bvdae: Differential-algebraic equations must be given as initial value problems." How could I avoid that issue, given that I do not want to give initial value, but rather impose values at different points ? – J.A May 22 '18 at 11:04
• @J.A In the future avoid shifting the goalpost. People feel frustrated to contribute effort to a specific question to then receive new requests not mentioned in the original question. You make the work others have done on your behalf seem irrelevant. Mma.SE is not a private consulting service but a public Q&A forum. Please, out of respect to the people trying to help you, either ask the question you need to ask properly the first time, or ask a new question, including you coded equations properly formatted. Cheers! – rhermans May 22 '18 at 11:07
• Sorry, I'll try to do better next time – J.A May 22 '18 at 11:15
• @J.A We all learn something new every day. Don't feel bad, just keep trying. – rhermans May 22 '18 at 11:25