# Plotting magnitude of a vector

**URL:** <https://community.freefem.org/t/plotting-magnitude-of-a-vector/723>\
**Category:** General Discussion\
**Created:** [January 4, 2021, 10:44am UTC](https://community.freefem.org/t/plotting-magnitude-of-a-vector/723 "2021-01-04T10:44:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeonardoDipilato](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/leonardodipilato/32/361_2.png) [@LeonardoDipilato](https://community.freefem.org/u/LeonardoDipilato)\
**Post date:** [January 4, 2021, 10:44am UTC](https://community.freefem.org/t/plotting-magnitude-of-a-vector/723/1 "2021-01-04T10:44:06Z")

</div>

Given a vector [ux, uy] as the solution to a variational problem, is there any way to plot sqrt(ux^2+uy^2)?  
I can’t find anything in the documentation nor in this forum, which seems really strange compared to how common a thing it should be.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [January 4, 2021, 10:52am UTC](https://community.freefem.org/t/plotting-magnitude-of-a-vector/723/2 "2021-01-04T10:52:39Z")

</div>

So common that it writes literally as you want it to be written.

```auto
mesh Th = square(10, 10);
fespace Wh(Th, [P2, P2]);
fespace Vh(Th, P2);
Wh [ux, uy] = [x, y];
Vh magnitude = sqrt(ux^2+uy^2);
plot(magnitude);

```

---

<div class="post-metadata">

**Author:** ![LeonardoDipilato](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/leonardodipilato/32/361_2.png) [@LeonardoDipilato](https://community.freefem.org/u/LeonardoDipilato)\
**Post date:** [January 4, 2021, 10:56am UTC](https://community.freefem.org/t/plotting-magnitude-of-a-vector/723/3 "2021-01-04T10:56:58Z")

</div>

I see, I tried to do that inside the plot function and it didn’t work, didn’t think about declaring and initilizing it first. Thanks!
