So I got a gift for a friend based on Mathematica code.

Rose[x_, theta_] := 
     {phi = (Pi/2)Exp[-theta/(8 Pi)], 
      X = 1 - (1/2)((5/4)(1 - Mod[3.6 theta, 2 Pi]/Pi)^2 - 1/4)^2}, 
    y = 1.95653 x^2(1.27689 x - 1)^2 Sin[phi]; 
    r = X(x Sin[phi] + y Cos[phi]); 
    {r Sin[theta], r Cos[theta], X (x Cos[phi] - y Sin[phi]), EdgeForm[]}];

ParametricPlot3D[Rose[x, theta], {x, 0, 1}, {theta, -2 Pi, 15 Pi},
  PlotPoints -> {25, 576}, 
  LightSources -> {{{0, 0, 1}, RGBColor[1, 0, 0]}}, 
  Compiled -> False]

And I want to translate this code to LaTeX. I have never used Mathematica before, but I've managed to find a computer with Mathematica, and I've managed to use the "copy as LaTeX" option. I couldn't figure out how to use TeXform, unfortumately :/

ANYWHO, I've managed to get this in my attempt to translate Rose(x,theta):

$\text{Rose}(x,\theta):=\left[\begin{array}{c}\left\{ \phi =\frac{1}{2} \pi \exp \left(-\frac{\theta }{8 \pi}\right), X = 1-\frac{1}{2}\left(\frac{5}{4} \left(1-\frac{((3.6 \theta ) \bmod (2 \pi ))}{\pi }\right)^2-\frac{1}{4}\right)^2\right\},\\ y=1.95653 x^2 (1.27689 x-1)^2 \sin(\phi );\\ r=X (x \sin (\phi )+y \cos (\phi ));\{r \sin (\theta ),r \cos (\theta ),X (x \cos (\phi )-y \sin (\phi ))\} \end{array}\right]$

(note the copy to latex option wasn't super helpful in formatting)

This is the result of directly pasting the copy result and trying to clean up the function. I'm wondering if this cleanup is correct, and also...what exactly is going on in the function?

What I think is going on:

1) We use $\theta$ to calculate $\phi$ and big $X$

2) We then calculate $y$ using $\phi$ and little $x$

3) Then $r$ is calculated using big $X$, little $x$, $y$, and $\phi$

4) The euclidean coordinates of points on the graph are represented by: $\{r \sin(\theta ),r \cos(\theta),X (x \cos(\phi )-y \sin(\phi ))\}$ , and that depends on big $X$, little $x$, $y$, $\theta$, $\phi$, and $r$

Is this right? Am I missing something? Did I translate something wrong? What does mod mean? Is it modding $3.6\theta$ by $2\pi$?

Also, what does the plot mean? I'm guessing LightSources and RGBcolor refer to how the graph looks aesthetically. Does the second part of the code mean that x ranges from 0 to 1, and theta ranges from -2 Pi and 15 Pi? What does PlotPoints mean? The fineness of the plot/ number of points in each variable?

I need to verify this specific equation with human eyes that know how to read Mathematica code. :/

EDIT: Sorry for the lack of citation-- this is Mathematica code from Paul Nylander -- a formula for the "Nylander Rose" -- I had no part in making this code at all.

  • 5
    $\begingroup$ Are you trying to understand the Mathematica code by translating it to $\LaTeX$? That's not a good idea. You can't learn Mathematica that way. Have you looked at any tutorials for the language? Maybe I misunderstood and you simply want this But your subsequent questions appear to be completely unrelated to $\LaTeX$. $\endgroup$
    – Jens
    Jun 5, 2016 at 4:52
  • $\begingroup$ If you wanted to use TeXForm, you need to prevent the evaluation of SetDelayed (:=). To do that, simply put Unevaluated around the entire code then put TeXForm around it. However, I agree with @Jens that it is not a good idea to learn the Wolfram Language / Mathematica through $\LaTeX$. $\endgroup$ Jun 5, 2016 at 5:01
  • $\begingroup$ @Jens : I'm not trying to learn Mathematica at all! I just want to know what this specific equation means (and literally nothing else). I want to translate this code into something readable, so that I personally know what's going on, without spending hours parsing through mathematica tutorials. I mean, at this point, I don't even know how to do whatever the Mathematica equivalent of Hello World is. $\endgroup$ Jun 5, 2016 at 5:13
  • 1
    $\begingroup$ "I'm not trying to learn Mathematica at all!" and "I mean, at this point, I don't even know how to do whatever the Mathematica equivalent of Hello World is." indicate to me that this might not be the right site for you then... this site is only for people who are trying to learn/use Mathematica and know more than the hello world :) Perhaps, gift your friend a real rose? ;) (Here's an example output of the code i.sstatic.net/C3Bfe.png) $\endgroup$
    – rm -rf
    Jun 5, 2016 at 5:52
  • 4
    $\begingroup$ You probably should have mentioned that you got this from Paul Nylander. $\endgroup$ Jun 5, 2016 at 6:57

1 Answer 1


This is not answer, but an extended comment that displays a graphic.

The code you post in your question does not work in any recent version of Mathematica. It is syntactically and semantically incorrect.

The following modified code does work. My question is: does it produce the plot you want to translate into LaTeX?

rose[x_, theta_] :=
     {phi = (Pi/2) Exp[-theta/(8 Pi)],
      u = 1 - (1/2) ((5/4) (1 - Mod[3.6 theta, 2 Pi]/Pi)^2 - 1/4)^2,
      y, r},
   y = 1.95653 x^2 (1.27689 x - 1)^2 Sin[phi];
   r = u (x Sin[phi] + y Cos[phi]); 
   {r Sin[theta], r Cos[theta], u (x Cos[phi] - y Sin[phi])}]

ParametricPlot3D[rose[x, theta], {x, 0, 1}, {theta, -2 Pi, 15 Pi},
  PlotStyle -> {Glow[Red]},
  PlotTheme -> {"NoAxis", "ZMesh"},
  Lighting -> {{"Directional", GrayLevel[.4], {{0, 0, 1}, {0, 0, 0}}}},
  PlotPoints -> {25, 250}]

Note: this code was built using your textual description as a guide to modifying your code, so if it does what you expect, your understanding of the code is essentially correct.


  • $\begingroup$ THIS IS EXACTLY THE THING I AM INTENDING TO TRANSLATE TO LaTeX THANK YOU!!!!! Thank you for verifying that my understanding was essentially correct :) Much appreciated $\endgroup$ Jun 5, 2016 at 6:45
  • 2
    $\begingroup$ This'd look better with Mesh -> False. In any case, Nylander's code was intended for older versions, and indeed it runs as it is on 5.2; it is nice that you've shown the necessary changes for it to run on the current version. $\endgroup$ Jun 5, 2016 at 11:08
  • $\begingroup$ If there ever was a chance to use the new 12.3 functionality MaterialShading then this would be it! $\endgroup$ Jun 9, 2021 at 10:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.