Thread Closed

Mathematica: Plotting piecewise functions

 
Share Thread Thread Tools
May13-10, 06:42 AM   #1
 

Mathematica: Plotting piecewise functions


Hi guys

Take a look at

Code:
DensityPlot[If[x == 0 && y == 0, 1, 0], {x, -1, 1}, {y, -1, 1}]
This just gives me a uniform plot. Why does the peak at the origin not show up?

Sincerely,
Niles.
PhysOrg.com
PhysOrg
science news on PhysOrg.com

>> Galaxies fed by funnels of fuel
>> The better to see you with: Scientists build record-setting metamaterial flat lens
>> Google eyes emerging markets networks
May13-10, 10:03 AM   #2
 
There are two main reasons why you'll have trouble with attempting to plot functions like that using DensityPlot.
  • The function is zero everywhere but at a single point. DensityPlot[] is unsuitable for functions like this, as a few minutes thought should convince you.
  • Even for other function with jump discontinuities, the number of plot points and the maximum recursion depth you use for DensityPlot[] can have a significant effect on the approximation. For instance, if you try to use

    Code:
    DensityPlot[HeavisideTheta[x, y], {x, -1, 1}, {y, -1, 1}]
    you'll see that the resulting density plot exhibits approximation artifacts around the jump discontinuity in the 2D Heaviside function. This can be controlled using PlotPoints and MaxRecursion, but you should be aware that DensityPlot[] is more suited to functions that are at least [itex]C^1[/itex] everywhere in the region of interest.
May13-10, 11:42 AM   #3
 
Quote by shoehorn View Post
There are two main reasons why you'll have trouble with attempting to plot functions like that using DensityPlot.

The function is zero everywhere but at a single point. DensityPlot[] is unsuitable for functions like this, as a few minutes thought should convince you.
You are correct; I need to think a little more. Thanks; I'll try out your suggestions.
Thread Closed
Thread Tools


Similar Threads for: Mathematica: Plotting piecewise functions
Thread Forum Replies
Plotting piecewise parametric function Math & Science Software 5
mathematica plotting Math & Science Software 4
Plotting (& not plotting) Asymptotes in Mathematica Math & Science Software 2
Mathematica Q. Re Plotting Math & Science Software 1
Plotting in Mathematica Math & Science Software 9