开发者

How can I reproduce a scribbly pattern like this in code?

I made this graph in wolfram alpha by accident:

How can I reproduce a scribbly pattern like this in code?

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 on开发者_如何学编程ly 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)

How can I reproduce a scribbly pattern like this in code?


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

How can I reproduce a scribbly pattern like this in code?

Edit

It is indeed a roundoff effect:

If we set:

How can I reproduce a scribbly pattern like this in code?

and make a plot

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

The result is:

How can I reproduce a scribbly pattern like this in code?

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

How can I reproduce a scribbly pattern like this in code?

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

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

How can I reproduce a scribbly pattern like this in code?

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]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜