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.

Thx in advance

  • 1
    $\begingroup$ Have a look at Piecewise. $\endgroup$ – Henrik Schumacher May 22 '18 at 10:21
  • $\begingroup$ 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. $\endgroup$ – rhermans May 22 '18 at 10:59
  • $\begingroup$ 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. $\endgroup$ – rhermans May 22 '18 at 11:00
  • $\begingroup$ 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. $\endgroup$ – 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.

Mathematica graphics

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

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

Mathematica graphics

  • $\begingroup$ 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 ? $\endgroup$ – J.A May 22 '18 at 11:04
  • 2
    $\begingroup$ @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! $\endgroup$ – rhermans May 22 '18 at 11:07
  • $\begingroup$ Sorry, I'll try to do better next time $\endgroup$ – J.A May 22 '18 at 11:15
  • 2
    $\begingroup$ @J.A We all learn something new every day. Don't feel bad, just keep trying. $\endgroup$ – rhermans May 22 '18 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.