# How to write case, in piecewise function, correctly [closed]

I want to plot graph of this piecewise function in Methematica:

$f: [0, 1] \mapsto \mathbb{R}$

$f(x)= \begin{cases} \frac{1}{x - \frac{1}{3} } & \text{ if } x \in [0, \frac{1}{3}> \newline -1 & \text{ if } x = \frac{1}{3} \newline 18x-9 & \text{ if } x \in<\frac{1}{3}, \frac{2}{3}>\backslash \{ \frac{4}{9},\frac{5}{9} \} \newline 1 & \text{ if } x = \frac{2}{3} \newline \frac{1}{x - \frac{2}{3} } & \text{ if } x \in <\frac{2}{3}, 1] \end{cases}$

So I wrote this:

Plot[Piecewise[{{1/(x - 1/3), 0 <= x < 1/3},
{-1, x = 1/3},
{18 x - 9, 1/3 < x < 2/3  },
{1, x = 2/3},
{1/(x - 2/3), 2/3 < x <= 1}}],
{x, 0, 1}]

Wolfram only plots the first case{1/(x - 1/3), 0 <= x < 1/3}. I figured out that the {-1, x = 1/3} and {1, x = 2/3} cases make problem. How can I write them down correctly? Thanks!

-

## closed as too localized by rm -rf♦Jan 29 '13 at 20:56

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

First thing to do : replace x=1/3 by x==1/3 and x=2/3 by x==2/3. –  andre Jan 29 '13 at 20:18

You have used single-equal assignment where you meant to use double-equal comparison.

Plot[Piecewise[{{1/(x - 1/3), 0 <= x < 1/3},
{-1, x == 1/3},
{18 x - 9, 1/3 < x < 2/3  },
{1, x == 2/3},
{1/(x - 2/3), 2/3 < x <= 1}}],
{x, 0, 1}]
-
Great. :) As in many programming languages... –  kr85 Jan 29 '13 at 20:22