- #1

- 44

- 0

Hi, not sure where to put this, so i'll just put it here.

i was wondering if there is a way to define functions of this sort in mathematica.

For example.

f(x)=x if x>0 and f(x)=2x if x<=0.

I know you can break it up into 2 functions and go something like

g[x_]:=x;

h[x_]:=2x;

but those are 2 different functions with different domain ranges (0,Inf), (-Inf,0].

what i want is just 1 function in mathematica with domain (-Inf, Inf) that knows to use g if x>0, and h if x<=0 in my example.

Thank you.

*edit i figured it out,

PS how do i delete my post?

i was wondering if there is a way to define functions of this sort in mathematica.

For example.

f(x)=x if x>0 and f(x)=2x if x<=0.

I know you can break it up into 2 functions and go something like

g[x_]:=x;

h[x_]:=2x;

but those are 2 different functions with different domain ranges (0,Inf), (-Inf,0].

what i want is just 1 function in mathematica with domain (-Inf, Inf) that knows to use g if x>0, and h if x<=0 in my example.

Thank you.

*edit i figured it out,

PS how do i delete my post?

Last edited: