{{Short description|Equation in polar coordinates}} {{About|a generalization of the superellipse|the Japanese formula racing series|Super Formula Championship}} The '''superformula''' is a generalization of the [[superellipse]] and was proposed by [[Johan Gielis (Mathematician)|Johan Gielis]] in 2003.<ref>{{Citation | last1=Gielis | first1=Johan | title=A generic geometric transformation that unifies a wide range of natural and abstract shapes | year=2003 | url= https://bsapubs.onlinelibrary.wiley.com/doi/10.3732/ajb.90.3.333 | journal=[[American Journal of Botany]] | issn=0002-9122 | volume=90 | issue=3 | pages=333–338 | doi=10.3732/ajb.90.3.333 | pmid=21659124| url-access=subscription }} {{open access}}</ref> Gielis suggested that the formula can be used to describe many complex shapes and curves that are found in nature. Gielis has filed a patent application related to the synthesis of patterns generated by the superformula, which expired effective 2020-05-10.<ref>{{cite patent | country=EP |number=1177529 |status=patent | title = Method and apparatus for synthesizing patterns | invent1 = Gielis, Johan | gdate = 2005-02-02 | pridate = 1999-05-10 | fdate = 2000-05-10 }}</ref>

In [[polar coordinates]], with <math>r</math> the radius and <math>\varphi</math> the angle, the superformula is:

<math display="block">r\left(\varphi\right) = \left( \left| \frac{\cos\left(\frac{m\varphi}{4}\right)}{a} \right| ^{n_2} + \left| \frac{\sin\left(\frac{m\varphi}{4}\right)}{b} \right| ^{n_3} \right) ^{-\frac{1}{n_{1}}}. </math> By choosing different values for the parameters <math>a, b, m, n_1, n_2,</math> and <math>n_3,</math> different shapes can be generated.

The formula was obtained by generalizing the superellipse, named and popularized by [[Piet Hein (scientist)|Piet Hein]], a [[Denmark|Danish]] [[mathematician]].

== 2D plots ==

In the following examples the values shown above each figure should be ''m'', ''n''<sub>1</sub>, ''n''<sub>2</sub> and ''n''<sub>3</sub>.

[[Image:Sf2d.png|480px]]

A [[GNU Octave]] program for generating these figures

<syntaxhighlight lang="matlab"> function sf2d(n, a) u = [0:.001:2 * pi]; raux = abs(1 / a(1) .* abs(cos(n(1) * u / 4))) .^ n(3) + abs(1 / a(2) .* abs(sin(n(1) * u / 4))) .^ n(4); r = abs(raux) .^ (- 1 / n(2)); x = r .* cos(u); y = r .* sin(u); plot(x, y); end </syntaxhighlight>

== Extension to higher dimensions == It is possible to extend the formula to 3, 4, or ''n'' dimensions, by means of the [[spherical product]] of superformulas. For example, the [[dimension|3D]] [[parametric surface]] is obtained by multiplying two superformulas ''r''<sub>1</sub> and ''r''<sub>2</sub>. The coordinates are defined by the relations:

<math display="block"> x = r_1(\theta)\cos\theta \cdot r_2(\phi)\cos\phi,</math> <math display="block"> y = r_1(\theta)\sin\theta \cdot r_2(\phi)\cos\phi,</math> <math display="block"> z = r_2(\phi)\sin\phi,</math>

where <math>\phi</math> ([[latitude]]) varies between −''π''/2 and ''π''/2 and ''θ'' ([[longitude]]) between −''π'' and ''π''.

== 3D plots ==

3D superformula: ''a'' = ''b'' = 1; ''m'', ''n''<sub>1</sub>, ''n''<sub>2</sub> and ''n''<sub>3</sub> are shown in the pictures.

<gallery> Image:Sf3d_3257.svg Image:Sf3d_3.5.5.5.svg Image:Sf3d_3301515.svg Image:Sf3d_7284.svg Image:Sf3d_5111.svg Image:sf3d_4.5.54.svg Image:sf3d_8.5.58.svg Image:Sf3d_4121515.svg </gallery>

A [[GNU Octave]] program for generating these figures: <syntaxhighlight lang="matlab"> function sf3d(n, a) u = [- pi:.05:pi]; v = [- pi / 2:.05:pi / 2]; nu = length(u); nv = length(v); for i = 1:nu for j = 1:nv raux1 = abs(1 / a(1) * abs(cos(n(1) .* u(i) / 4))) .^ n(3) + abs(1 / a(2) * abs(sin(n(1) * u(i) / 4))) .^ n(4); r1 = abs(raux1) .^ (- 1 / n(2)); raux2 = abs(1 / a(1) * abs(cos(n(1) * v(j) / 4))) .^ n(3) + abs(1 / a(2) * abs(sin(n(1) * v(j) / 4))) .^ n(4); r2 = abs(raux2) .^ (- 1 / n(2)); x(i, j) = r1 * cos(u(i)) * r2 * cos(v(j)); y(i, j) = r1 * sin(u(i)) * r2 * cos(v(j)); z(i, j) = r2 * sin(v(j)); endfor; endfor; mesh(x, y, z); endfunction; </syntaxhighlight>

== Generalization == The superformula can be generalized by allowing distinct ''m'' parameters in the two terms of the superformula. By replacing the first parameter <math>m</math> with ''y'' and second parameter <math>m</math> with ''z'':<ref>* {{Citation | last1=Stöhr | first1=Uwe | title=SuperformulaU | year=2004 | url=http://ftp.lyx.de/Lectures/SuperformulaU.pdf | archive-date=December 8, 2017 | url-status=dead | archive-url=https://web.archive.org/web/20171208231427/http://ftp.lyx.de/Lectures/SuperformulaU.pdf }}</ref> <math display="block">r\left(\varphi\right) = \left( \left| \frac{\cos\left(\frac{y\varphi}{4}\right)}{a} \right| ^{n_2} + \left| \frac{\sin\left(\frac{z\varphi}{4}\right)}{b} \right| ^{n_3} \right) ^{-\frac{1}{n_{1}}} </math>

This allows the creation of rotationally asymmetric and nested structures. In the following examples a, b, <math>{n_2}</math> and <math>{n_3}</math> are 1:

[[File:SuperformulaU-several-structures.svg|500px]]

== References == {{Reflist}}

== External links == {{Commons category|Superformula}} * [http://ssrn.com/abstract=913667 Some Experiments on Fitting of Gielis Curves by Simulated Annealing and Particle Swarm Methods of Global Optimization] * [http://ssrn.com/abstract=917762 Least Squares Fitting of Chacón-Gielis Curves By the Particle Swarm Method of Optimization] * [http://www.perbang.dk/superformula/ Superformula 2D Plotter & SVG Generator] * [http://jsxgraph.uni-bayreuth.de/wiki/index.php/Superformula Interactive example using JSXGraph] * [https://sourceforge.net/projects/supershaper SuperShaper: An OpenSource, OpenCL accelerated, interactive 3D SuperShape generator with shader based visualisation (OpenGL3)]

[[Category:Geometric shapes]] [[Category:Curves]] [[Category:Surfaces]]