I am trying to define an equation one way under certain conditions and another way under different conditions. I am a little rusty with mathematica. Here is a simple example (not the actual equations I am using):
ClearAll["Global`*"];
b = 5;
If[a < b, pumpkin = 0, pumpkin = a + b]
Plot[pumpkin, {a, 0, 12}]
This is not behaving as I expected. Is there a different function I should be using, or did I make a small error?
ClearAll["Global`*"];
b = 5;
Plot[Piecewise[{{0, a < b}}, a + b], {a, 0, 12}]
Plot[If[a < b, 0, a + b], {a, 0, 12}]
I would suggest you to use piecewise, as this is designed for making piecewise functions, If was not. You can also see that they plot slightly differently at the transition a=b