[Date Index]
[Thread Index]
[Author Index]
Re: How to plot discontinuous functions?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg90182] Re: How to plot discontinuous functions?
*From*: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
*Date*: Tue, 1 Jul 2008 07:02:34 -0400 (EDT)
*Organization*: The Open University, Milton Keynes, UK
*References*: <g4a6tv$8uh$1@smc.vnet.net>
Aaron Fude wrote:
> If a function is defined via If, then when plotted it does not
> acknowledge the discontinuity. E.g.
>
> f[x_] := If[x < 1, 1, 2];
> Plot[f[x], {x, 0, 2}, PlotRange -> {0, 3}]
>
> Defined via Piecewise, it does, but in my experience, not always:
> f[x_] := Piecewise[{{{1, 1}, x < 1}}, {2, 2}];
> Plot[f[x][[1]], {x, 0, 2}, PlotRange -> {0, 3}]
>
> How do I make the Plot function try to acknowledge the discontuity by
> not connecting the left limit and the right limit?
Does it make really sense to define your function as vector valued?
If not, Plot does not face any major hurdles to spot the discontinuities
of a real valued function.
f[x_] := Piecewise[{{1, x < 1}}, 2];
Plot[f[x], {x, 0, 2}, PlotRange -> {0, 3}]
Otherwise, you may have to tell Plot where to look for discontinuities
and exclude them.
f[x_] := Piecewise[{{{1, 1}, x < 1}}, {2, 2}];
Plot[f[x][[1]], {x, 0, 2}, PlotRange -> {0, 3}, Exclusions -> 1]
Regards,
-- Jean-Marc
Prev by Date:
**Draw two functions in a graph, one of them does also have a parameter.**
Next by Date:
**Re: display Floor in StandardForm**
Previous by thread:
**Re: How to plot discontinuous functions?**
Next by thread:
**Re: How to plot discontinuous functions?**
| |