Plotting a part of curves (with possible solution as an attempt) I may mess up with this question!
I plotted them using http://www.desmos.com/calculator

How to plot only a part of some curves?

For example:
Plot of $y=x^2$:


But if i want to plot the curve from $x=1$ to $x=2$ which will look something like:

How to achieve it?


My attempt:
I can only do $[n,\infty)$, that is starting from $x=n$ but ending up in $\infty$. [first limitation]
Lets take a function say $f(x)=x$...
So suppose if i want to plot it from $x=3$...what i do is plot
$y=({\sqrt{x-3}})^2 + 3$
thus giving me :

But it also does not work on even degree equation like $y=x^2$ which gives: [second limitation]
($y=({\sqrt{x^2-3}})^2 + 3$ )

And also does not work with curves like $\sin{x}$ as using $y=({\sqrt{f(x)-n}})^2 + n$ (as i have been using) makes the values non-real if $n\geq 1$. [third limitation]

My 2nd attempt:

I plotted $y=x^2+0{\sqrt{x-1}}^2+0{\sqrt{3-x}}^2$ to get :


which is exactly what i want but i guess the method is a little crude.

Hence final method : $y=f(x)+0{\sqrt{x-a}}^2+0{\sqrt{b-x}}^2$ ... am i right?


Let $f$ be a function and $[a,b]$ be the domain in which you want to plot the function.
In most programming languages with type conversion between booleans and numbers you could define the desired function as f_restricted(x) = f(x)*(x >= a && x <= b),since (x >= a && x <= b) will be converted to 0 or 1 if it is evaluated to be true or false respectively.
