0
$\begingroup$

I wrote the code for the function $T$ defined on $[0,1]$ by $T(x)=\frac{x+2}{3}$ if $x\neq\frac{1}{2}$ and $T(\frac{1}{2})=1$ as follows.

T[x_] := If[x != 1/2, (2*x + 1)/3, 1];

I am not sure if the code I wrote defines the function $T$ correctly as the command `Plot' fails to highlight the discontinuity at $\frac{1}{2}$.

A clarification to my doubt will be highly appreciated. Thanks!

$\endgroup$

closed as off-topic by MarcoB, m_goldberg, Henrik Schumacher, march, bobthechemist Dec 19 '18 at 19:05

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, m_goldberg, Henrik Schumacher, bobthechemist
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ Probably better to use Piecewise[] $\endgroup$ – Michael E2 Dec 17 '18 at 14:47
  • 1
    $\begingroup$ You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is useful for learning how to format your questions and answers. You may also find this meta Q&A helpful $\endgroup$ – Michael E2 Dec 17 '18 at 14:47
  • $\begingroup$ Use Piecewise and see the answers here. $\endgroup$ – march Dec 17 '18 at 16:42
  • $\begingroup$ Possible duplicate of Plot a piecewise function with black and white disks marking discontinuities $\endgroup$ – march Dec 19 '18 at 17:25
2
$\begingroup$
f[x_] := Piecewise[{{(x + 2)/3, x != 1/2}, {1, x == 1/2}}]
Plot[f[x], {x, 0, 1}, 
 ExclusionsStyle -> {Dotted, Directive[Black, AbsolutePointSize[5]]}]

enter image description here

$\endgroup$
  • $\begingroup$ @Bob Hanlon. Thanks for fixing my typo. $\endgroup$ – Rohit Namjoshi Dec 17 '18 at 17:01
  • 1
    $\begingroup$ To show the actual value at the discontinuity: Plot[f[x], {x, 0, 1}, ExclusionsStyle -> {Dotted, Directive[White, AbsolutePointSize[3]]}, Epilog -> {Red, AbsolutePointSize[5], Point[{1/2, f[1/2]}]}] $\endgroup$ – Bob Hanlon Dec 17 '18 at 17:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.