Skip to content

Instantly share code, notes, and snippets.

@dz1984
Created January 24, 2018 14:55
Show Gist options
  • Save dz1984/976dd1a5b9276ab9f94c6c6deaab8d0f to your computer and use it in GitHub Desktop.
Save dz1984/976dd1a5b9276ab9f94c6c6deaab8d0f to your computer and use it in GitHub Desktop.
魏爾斯特拉斯函數(Weierstrass function)是一類處處連續而處處不可導的實值函數。 https://imgur.com/w9RNrxO
# Weierstrass function
# Ref - https://zh.wikipedia.org/wiki/魏尔斯特拉斯函数
g = function(x) unlist(Map(function(n) 0.5^n * cos(3^n * pi * x),seq(0,644)))
f = function(x) Reduce(function (x, y) x+y, g(x))
x = seq(-2,2,0.001)
plot(x,lapply(x,f),type='l')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment