<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/mathematical-art-in-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://blog.revolutionanalytics.com/2018/04/mathematical-art-in-r-.html"> Revolutions</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p>Who says there's no art in mathematics? I've long admired the generative art that Thomas Lin Peterson occasionally posts (and that you can <a rel="nofollow" href="https://www.instagram.com/thomasp85_/" target="_blank">see on Instagram</a>), and though he's a prolific R user I'm not quite sure how he makes his art. Marcus Volz has another <a rel="nofollow" href="https://marcusvolz.com/" target="_blank">beautiful portfolio</a> of generative art, and has also created an R package you can use to create your own designs: the <a rel="nofollow" href="https://github.com/marcusvolz/mathart" target="_blank">mathart package</a>. </p>
<p>Generative art uses mathematical equations and standard graphical rendering tools (point and lines, color and transparency) to create designs. The mathart package provides a number of R functions to create some interesting designs from just a few equations. Complex designs emerge from just a few trigonometric functions, like this <a rel="nofollow" href="https://github.com/marcusvolz/mathart/blob/master/R/mollusc.R" target="_blank">shell</a>:</p>
<p><a rel="nofollow" href="https://github.com/marcusvolz/mathart" target="_blank"><img border="0" alt="Shell" title="Shell" src="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01b7c95db772970b-800wi"></a></p>
<p>Or this abstract harmonograph:</p>
<p><a rel="nofollow" href="https://github.com/marcusvolz/mathart" target="_blank"><img border="0" alt="Harmonograph" title="Harmonograph" src="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01bb0a00e597970d-800wi"></a></p>
<p>Amazingly, the image above, and an infinite collection of images similar to it, is generated by just two equations implemented in R:</p>
<pre>  x = A1*sin(t*f1+p1)*exp(-d1*t) + A2*sin(t*f2+p2)*exp(-d2*t),
  y = A3*sin(t*f3+p3)*exp(-d3*t) + A4*sin(t*f4+p4)*exp(-d4*t)
</pre>
<p>You can have a lot of fun playing around with the parameters to the <a rel="nofollow" href="https://github.com/marcusvolz/mathart/blob/master/R/harmonograph.R" target="_blank">harmonograph</a> function to see what other interesting designs you can find. You can find that function, and functions for designs of birds, butterflies, hearts, and more in the mathart package available on Github and linked below.</p>
<p>Github (marcusvolz): <a rel="nofollow" href="https://github.com/marcusvolz/mathart" target="_blank">mathart</a></p>
<p> </p>
</div>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://blog.revolutionanalytics.com/2018/04/mathematical-art-in-r-.html"> Revolutions</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/zNg90lZK83k" height="1"></a></div>