0

I would like to plot this function:

$\sqrt[\gamma]{(\frac{x}{a})^{\gamma}+(\frac{y}{b})^{\gamma}}=\mu \,$ where $\, \gamma, a,b\in \mathbb{R} \,$ and $\, \mu \in \mathbb{Z}$

I have tried to plot this function in MATLAB considering $\gamma=0.43$, $ a=0.2$, $b=0.55$, $\mu=2$, but it looks so ugly. I am wonder if my method is correct. Here is what I do:
First) Rearrange the equation .
Second) Plot it with a simple code:

$y=\pm b\times\sqrt[{\gamma}]{{\mu^{\gamma}-(\frac{x}{a})^{\gamma}}}$

Here is a code I use in MATLAB to plot this function:

g=0.2; a =0.4; b=0.6; m=1;

x= - a*m :0.01: a*m;

y=  +b*(m^g-(x/a).^g).^(1/g);
yy= -b*(m^g-(x/a).^g).^(1/g);

plot(x,y,x,yy)

The result should be a nice closed shape called superellipse. But it is not.

Is what I've done mathematically correct?

enter image description here

Masan
  • 161
  • Why $,\pm b,$? $$ \left(\frac{x}{a}\right)^{\gamma}+\left(\frac{y}{b}\right)^{\gamma}=\mu^{\gamma} \implies y=\sqrt[{\gamma}]{\left(b,\mu\right)^{\gamma}-\left(\frac{b,x}{a}\right)^{\gamma}} $$ – Hazem Orabi Mar 03 '17 at 00:30
  • because it is not a closed shape with no +_, the answer should be a superellipse @HazemOrabi – Masan Mar 03 '17 at 05:48

2 Answers2

1

Firstly your function needs absolute values in it if you want to evaluate the fractional powers correctly.

$$\sqrt[\gamma]{(\frac{|x|}{a})^{\gamma}+(\frac{|y|}{b})^{\gamma}}=\mu \,$$

Also your function does not need the $\mu$ term as it can be rearranged as:

$$\sqrt[\gamma]{(\frac{|x|}{a\cdot\mu})^{\gamma}+(\frac{|y|}{b\cdot\mu})^{\gamma}}=1$$

Regardless your function can then be written as:

$$y=\pm b\cdot\mu\times\sqrt[{\gamma}]{{1-(\frac{|x|}{a\cdot\mu})^{\gamma}}}$$

This shows that your range of $x$ should be $[-a\cdot\mu,a\cdot\mu]$ whereas in your example you have used a much bigger range for $x$. This may be the cause of your problem.

Lastly most computer programs will have difficulty near $x=0$ as the slope of the curve there is approaching infinity and any small increment in the $x$ direction can result in a large change in the $y$ which may be calculated poorly. This is probably also contributing to your problem.

Without a picture to tell exactly what you graph looks like there isn't much more I can say.

Ian Miller
  • 11,844
  • how to ease the singularity problem around x=0? Pic is added. @ian-miller – Masan Mar 03 '17 at 21:43
  • 1
    Your picture looks fine. If you were concerned about it the vertical component you could try plotting it parametrically with polar coordinates. Alternately you could graph $x^\gamma+y^\gamma=1$ from $x=\frac{1}{\sqrt[\gamma)]{2}}$ to $x=1$ to give you one eighth of the graph then fill in the rest via reflection, rotation and finally use an dilation by $a$ and $b$ horizontally and vertically respectively.. – Ian Miller Mar 04 '17 at 15:10
  • good idea! @ian-miller – Masan Mar 06 '17 at 21:59
1

To answer your specific question, what have I done wrong?, the answer is that you need the abs(x/a) in the expressions for y and yy.

For a more thoughtful discussion of the superellipse and related curves see my posting here: Polar form of generalized superellipse.

Cye Waldman
  • 7,524