# Plotting a function defined to be infinite over a sub-domain [duplicate]

I'm trying to plot the following function with the constraints shown,

$$f(x)=\begin{cases} \infty \quad x<0 \\ A\,x\quad x\ge 0 \end{cases}$$

However I can't work out how to show this in Mathematica, I tried using RegionPlot[] but it doesn't seem to work (or I'm missing something!). The other way I thought of would be to plot as two separate functions and then use Show[].

If someone has a smarter way that would be helpful!

• how do you want to represent the infinite value of the function for $x<0$? – glS Jan 2 '16 at 14:21
• On the plot it would just have to 'look' large. In reality I would just set to a high value and tweak the plot range. – Q.P. Jan 2 '16 at 14:23

Piecewise is built for exactly this purpose:

With[{a = 2, inf = 100},
Plot[
Piecewise[
{
{inf, x < 0},
{a x, x > 0}
}
],
{x, -2, 2}
]
]

Plot[Piecewise[{{2.0, x < 0}, {x^2, x > 0}}], {x, -1, 1},
PlotRange -> {Automatic, {0, 2}},
MeshFunctions -> {#2 &},
Mesh -> {{2, 0}},
MeshStyle -> None, 