# How to plot piecewise function in Wolfram|Alpha?

**URL:** <https://community.wolfram.com/t/how-to-plot-piecewise-function-in-wolfram-alpha/21760>\
**Category:** Questions\
**Tags:** wolfram-alpha, algebra, graphics-and-visualization\
**Created:** [March 16, 2023, 11:34am UTC](https://community.wolfram.com/t/how-to-plot-piecewise-function-in-wolfram-alpha/21760 "2023-03-16T11:34:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![khabib9968](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@khabib9968](https://community.wolfram.com/u/khabib9968)\
**Post date:** [March 16, 2023, 11:34am UTC](https://community.wolfram.com/t/how-to-plot-piecewise-function-in-wolfram-alpha/21760/1 "2023-03-16T11:34:54Z")

</div>

f(x)=[ x^2 x\<0  
[ x+2 0≤x≤2  
[4 x\>2

I want to draw a graph of this function through Wolfram Alpha.  
I googled it for 3 hours, but I have no idea.  
I’d appreciate it if you could tell me the commands to enter.

 ![wolfram com.jpg](https://global.discourse-cdn.com/wolfram/original/3X/c/0/c0fb217e85a7f185e8f227071d0e6c5174f62011.jpeg)  
 ![wolfram com2.png](https://global.discourse-cdn.com/wolfram/original/2X/4/434429e90d3ca3d43d6b856ba5c91776a0068b87.png)

---

<div class="post-metadata">

**Author:** ![dontdont9](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@dontdont9](https://community.wolfram.com/u/dontdont9)\
**Post date:** [March 16, 2023, 2:40pm UTC](https://community.wolfram.com/t/how-to-plot-piecewise-function-in-wolfram-alpha/21760/2 "2023-03-16T14:40:24Z")

</div>

WA understands some Mathematica commands.

You can search for those commands [here](https://reference.wolfram.com/language/?source=nav)

Searching for piecewise there provides documentation.

This appears to work in WA

```
piecewise[{{x^2,x<0},{x+2,0<=x<=2},{4,x>2}}]

```

---

<div class="post-metadata">

**Author:** ![lumlerdv](https://avatars.discourse-cdn.com/v4/letter/l/b487fb/32.png) [@lumlerdv](https://community.wolfram.com/u/lumlerdv)\
**Post date:** [March 16, 2023, 4:47pm UTC](https://community.wolfram.com/t/how-to-plot-piecewise-function-in-wolfram-alpha/21760/3 "2023-03-16T16:47:33Z")

</div>

This might be what you want.

`f[x_] := Piecewise[{{x^2, x < 0}, {x + 2, 0 <= x <= 2}, {4, x > 2}}] Plot[f\[x\], {x, -4, 4}]`

---

<div class="post-metadata">

**Author:** ![khabib9968](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@khabib9968](https://community.wolfram.com/u/khabib9968)\
**Post date:** [March 17, 2023, 3:13am UTC](https://community.wolfram.com/t/how-to-plot-piecewise-function-in-wolfram-alpha/21760/4 "2023-03-17T03:13:56Z")

</div>

thank you so much,I didn’t know that English speakers call this a piecewise.  
now i know

---

<div class="post-metadata">

**Author:** ![khabib9968](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@khabib9968](https://community.wolfram.com/u/khabib9968)\
**Post date:** [March 17, 2023, 3:16am UTC](https://community.wolfram.com/t/how-to-plot-piecewise-function-in-wolfram-alpha/21760/5 "2023-03-17T03:16:30Z")

</div>

Thank you for your very kind reply. I copied and pasted it and it came out right away.

---

<div class="post-metadata">

**Author:** ![robinhofficial](https://avatars.discourse-cdn.com/v4/letter/r/ce7236/32.png) [@robinhofficial](https://community.wolfram.com/u/robinhofficial)\
**Post date:** [March 17, 2023, 11:39am UTC](https://community.wolfram.com/t/how-to-plot-piecewise-function-in-wolfram-alpha/21760/6 "2023-03-17T11:39:00Z")

</div>

Thank you for your thoughtful response[.](https://bizzvibes.com/how-to-add-friend-on-venmo/) I copied and pasted it, and it appeared immediately.
