# How can I define a Step-Wise function in Mathematica (Not using Heaviside Step Function)? [closed]

I need to define a function, which has very different behaviour in different regions. There are about 13 different regions. A sample of my function is the foloowing table:

I want to define it as a function of x, and I demand that for example for 0<=x<=1221.5, f[x_]:=13.088-8.84*x^2, and for 1221.5<=x<=3480, f[x_]:=12.58-1.26*x-3.64*x^2-5.53*x^3 and .... .

How can I do it in a wise way in Mathematica?

-
Take a look at Piecewise. –  VLC Mar 19 '13 at 18:44
@VLC, Thanks for your fast reply. You meen for example f[x_]:=Piecewise[{{x^2, x < 0}, {x, x > 0}}] ? –  ZKT Mar 19 '13 at 18:46
Indeed, that's how you can use it. –  VLC Mar 19 '13 at 18:48
@VLC Thanks a lot again. I love this forum, my problem got solved just 1 minute after posting my question in here! :) –  ZKT Mar 19 '13 at 18:51

## closed as too localized by Artes, m_goldberg, Jens, Oleksandr R., rm -rf♦Mar 21 '13 at 20:23

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Your function is double valued at x=1221.5 but if you are happy to chose one of the limits to be strictly greater than (or less than), then you can define your function as:
f[x_]=Piecewise[{{13.088-8.84x^2,0<=x<1221.5},{12.58-1.26x-3.64x^2-5.53x^3,1221.5<=x<=3480}}]

If you're defining a function, it is important to use the SetDelayed command: f[x_]:= Piecewise[(* the rest *)] –  zentient Mar 20 '13 at 7:05
If this function stands alone, and you don't want to do anything else with f[x_] or x elsewhere, then it appears to produce the same result. However, among other things this may cause scoping issues. The difference can produce unexpected results elsewhere in your code. SetDelayed,f[x_] := Piecewise[(* the rest *)], will keep all x's in the RHS local (they stay green). If you use Set, f[x_] = Piecewise[(* the rest *)], then RHS x's are global (they're blue) and may conflict with your use of x elsewhere. See Documentation > SetDelayed > Properties > ...scope –  zentient Mar 20 '13 at 9:03
Try executing x = 1. before your definition using =, and see what happens. :) That is why you need :=. –  Ｊ. Ｍ. Mar 23 '13 at 16:17