views:

156

answers:

1

I made this graph in wolfram alpha by accident:

Graph

Can you write code to produce a larger version of this pattern?

Can you make similar looking patterns?

Readable code in any language is good, but something that can be run in a browser would be best (i.e. JavaScript / Canvas). If you write code in other languages, please include a screenshot.

Notes:

  • The input formula for the above image is: arg(sin(x+iy)) = sin^(-1)((sqrt(2) cos(x) sinh(y))/sqrt(cosh(2 y)-cos(2 x))) (link)
  • You don't have to use to use the above formula. Anything which produces a similar result would be cool. But "reverse engineering" Wolfram Alpha would be best
  • The two sides of the equation are equal (I think), So WA should have probably only returned 'true' instead of the graph
  • The pattern is probably the result of rounding errors.
  • I don't know if the pattern was generated by iterating over every pixel or if it's vector based (points and lines). My guess is with vector.
  • I don't know what causes this type of pattern ('Rounding errors' is the best guess.)
  • IEEE floating point standard does not say how sin or cos, etc should work, so trig functions vary between platforms and architectures.
  • No brownian motion plots please

Finally, here's another example which might help in your mission: (link)

Graph 2

+3  A: 

As you asked for similar looking patterns in any language, here is the Mathematica code (really easy since Wolfram Alpha is based on Mathematica)

alt text

Edit

It is indeed a roundoff effect:

If we set:

alt text

and make a plot

Plot3D[f[x, y], {x, 7, 9}, {y, -8, -9},WorkingPrecision -> MachinePrecision]

The result is:

alt text

But if we extend the precision of the plot to 30 digits:

Plot3D[f[x, y], {x, 7, 9}, {y, -8, -9},WorkingPrecision -> 30]  

We get

alt text

and the roughness is gone (which caused your scribbly pattern)

BTW, your f[x,y] is a very nice function:

alt text

So if I managed to copy your formulas without errors (which should be considered a miracle), both sides of your equation are equal only in certain periodic ranges in x, probably of the form [2 n Pi, (2 n + 1) Pi]

belisarius
+1 and -1: I was tempted but thought it too easy and too unhelpful. Well done to you @belisarius for being bold enough to post this.
High Performance Mark
@High Performance Mark I just thought that the OP may benefit from learning that the plot is in the form "ContourPlot[f[x,y] == 0]" because Wolfram Alpha doesn't show that ... but yes ... -1 :)
belisarius
Not quite when I had in mind :) But it does help clarify things and does give a better (larger) image of the pattern, so it's appreciated still.
Qubei
@Qubei See edit
belisarius
@High Performance Mark Your -1 was a stab in my heart :). See edit
belisarius
Thanks again! "equal only in certain periodic ranges"I suspect it might just be the wrong sign (those squart roots should probably have +/- in front of them?) I'm just speculating though.
Qubei
@belisarius: I shall continue to goad you into better answers :-)
High Performance Mark
@Qubei your problem seems to be something related to multivalued functions. If you take Sin[] of both sides, your equality holds.
belisarius