Thread: Piecewise defined discontinuous functions in Mathematica

  1. #1
    .........
    Join Date
    Nov 2002
    Posts
    303

    Piecewise defined discontinuous functions in Mathematica

    Anyone know how to graph a piecewise defined discontinuous function in Mathematica so that the discontinuities actually show up?


    I googled and found a solution here but it doesn't work. I've been editing the graphs with microsoft paint to make them look discontinuous but it is very time consuming, especially since I need to create so many graphs.

    Anyone have any experience with this?

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Did you try what was shown in that document at the bottom of page 9?

    In order to create a discontinuous graph, plot the portions separately and then combine using the Show command.
    Last edited by hk_mp5kpdw; 03-16-2005 at 09:23 AM.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    .........
    Join Date
    Nov 2002
    Posts
    303
    Yup it errors out

  4. #4
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    I remember that document also saying something about errors because of the domain being used for a particular function. Show us the function along with the command you are using to plot it.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  5. #5
    .........
    Join Date
    Nov 2002
    Posts
    303
    I tried to plot the same one they had there and it didn't work.

  6. #6
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Excatly what do you mean by "discontinuities actually show up"?

    I barely know any Mathematica but I just did this:
    Code:
    p1 := Plot[ x , {x, -1, 1}];
    p2 := Plot[x + 2, {x, 1, 3}];
    Show[p1, p2];
    In the last plot a discontinuous function is shown. To me, the discontinuity is clearly shown.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  7. #7
    .........
    Join Date
    Nov 2002
    Posts
    303
    Thank you!

    For some reason when I used the code in that pdf it did not work. Next time I should try rereading about the show function in the documentation.

    I still have to edit the graphs though because I want to indicate whether there is a hole in the graph at a certain point but that is no big deal I guess.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Attaching functions to a class/struct
    By VirtualAce in forum Tech Board
    Replies: 2
    Last Post: 08-04-2003, 10:56 AM
  2. Expression Manipulator v0.2 (bug fixes, functions)
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 05-26-2003, 04:52 PM
  3. Help! User defined functions
    By AdrenalinFlow in forum C Programming
    Replies: 3
    Last Post: 02-22-2003, 07:36 PM
  4. API "Clean Up" Functions & delete Pointers :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-10-2002, 06:53 PM
  5. functions defined as a string
    By river-wind in forum C Programming
    Replies: 2
    Last Post: 11-21-2001, 10:36 AM