I haven't worn underwear
in quite some time
somebody help me
finish this rhyme
About this Entry
Posted by: taste_the_lotus

Visit taste_the_lotus's Xanga Site

Original: 7/10/2009 4:27 PM
Views: 7
Comments: 0
eProps: 0

Read Comments
Post a Comment
Back to Your Xanga Site

Tags
  •  R



Friday, July 10, 2009

What I Wondered When I Woke Up This Morning

 
Currently
Worldwild
By Pterodactyl
see related

R



Defining recursive sine functions


(inelegantly)



> sin1 <- function(x)
+ { x0 <- sin(x); x1 <- sin(pi*x0); return(x1)}
> sin2 <- function(x)
+ { x0 <- sin(x); x1 <- sin(pi*x0); x2 <- sin(pi*x1); return(x2)}
> sin3 <- function(x)
+ { x0 <- sin(x); x1 <- sin(pi*x0); x2 <- sin(pi*x1); x3 <- sin(pi*x2); return(x3)}


(Timesing by π is to match the range of the output to the domain of the next input. Sin returns [-1,1] but reads in from [-π, π].)

Plotting them



par(mfrow=c(2,2)); plot(sin,-pi,pi); plot(sin1, -pi,pi); plot(sin2, -pi, pi); plot(sin3, -pi, pi)

Recursive Sines



One more trick



I want to see what sin50 would look like, or generally sin_i.

> sinai <- function(x, n)
+ {p <- sin(x); for(i in 1:n){ p <- sin(pi*p); i<- i+1} ; return(p)}

(p is the internal input/output of the recursive sines)


Now to print that...

> sin50 <- function(x) {return(sinai(x,50))}
> sin100 <- function(x) { return ( sinai (x, 100))}
> sin1000 <- function(x) {return( sinai (x, 1000))}
> sin10000 <- function(x) {return(sinai (x, 10000))}
> par(mfrow=c(2,2)); plot(sin50, -pi, pi); plot(sin100, -pi, pi); plot(sin1000, -pi, pi); plot(sin10000, -pi, pi)


Recursive Sines ^



And scene.
 Posted 7/10/2009 4:27 PM - 7 Views - 0 eProps - 0 comments

Give eProps or Post a Comment

Choose Identity
(?)
 
Give eProps (?)
Post a Comment
Add Link | Preview HTML comment help 
Profile Pic:
Default  |  Choose »  (?)



Back to taste_the_lotus's Xanga Site!
Note: your comment will appear in taste_the_lotus's local time zone:
GMT -05:00 (Eastern Standard - US, Canada)