# Writing a function with a variable [closed]

trying to write this function, while b,d are known numbers and hj is the variable

thank you very much

• Use Piecewise, i.e., Dj[hj_] := Piecewise[{{hj + b, hj <= 2 d - b}, {(hj + b)/2 + d, hj > 2 d - b}}] May 19 at 17:27

Try functionName[variable_]:=If[variable>something, what to do if true, what to do else].