1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Mathematica help

  1. Jul 3, 2009 #1
    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
    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: Jul 3, 2009
  2. jcsd
  3. Jul 4, 2009 #2


    User Avatar
    Homework Helper

    You can make use of the If statement.

    Last edited: Jul 4, 2009
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook