Guest User

Untitled

a guest
Jun 20th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1. 1 1 -> 2
  2.  
  3. 2 3 -> 28,27
  4.  
  5. 3 1 -> 4,19
  6.  
  7. 3 4,5 -> 381,70
  8.  
  9. 1 9.379 -> 18.758
  10.  
  11. 0 48 -> 1
  12.  
  13. ÷2µØP*÷!
  14. ç×*@
  15.  
  16. ÷2µØP*÷! - Link 1: n, r
  17. ÷2 - n / 2
  18. µ - monadic chain separation
  19. ØP - π (3.141592653589793)
  20. * - exponentiate: π^(n/2)
  21. ! - Pi(n/2): Gamma(n/2 + 1)
  22. ÷ - divide: π^(n/2) / Gamma(n/2 + 1)
  23.  
  24. ç×*@ - Main link: n, r
  25. ç - call last link (1) as a dyad: π^(n/2) / Gamma(n/2 + 1)
  26. *@ - exponentiate with reversed @rguments: r^n
  27. × - multiply: r^n * π^(n/2) / Gamma(n/2 + 1)
  28.  
  29. Pi^(a=.5#)/a!#2^#&
  30.  
  31. N[Pi^(#/2)/Gamma[#/2 + 1] #2^#] &
  32. Pi^(.5#)/Gamma[.5# + 1] #2^# & (* replace exact with approximate numbers*)
  33. Pi^(.5#)/(.5#)! #2^# & (* n! == Gamma[n + 1] *)
  34. Pi^(a=.5#)/a! #2^# & (* replace repeated .5# *)
  35. Pi^(a=.5#)/a!#2^#& (* remove whitespace *)
  36.  
  37. function(n,r)pi^(n/2)/gamma(n/2+1)*r^n
  38.  
  39. function(n,r)c(1,pi,4/3*pi)[n]*r^n
  40.  
  41. 0%r=1
  42. 1%r=2*r
  43. n%r=2*pi*r^2/n*(n-2)%r
  44.  
  45. n%r=(max 1$1-(-1)**n)*(2*pi)^(floor$n/2)*r**n/product[n,n-2..1.1]
  46.  
  47. d=(n,r)=>r**n*(n<2?n+1:Math.PI*(n<3?1:4/3))
  48.  
  49. 3:^[2P4*P/3]*1hi)
  50.  
  51. 3: % Push array [1 2 3]
  52. % STACK: [1 2 3]
  53. ^ % Take r implicitly, and raise it to [1 2 3] element-wise
  54. % STACK: [3 9 27]
  55. [2P4*P/3] % Push array [2 pi 4*pi/3]
  56. % STACK: [3 9 27], [2 pi 4*pi/3]
  57. * % Multiply element-wise
  58. % STACK: [6 28.2743 113.0973]
  59. 1h % Append 1
  60. % STACK: [6 28.2743 113.0973, 1]
  61. i) % Input n and use it as modular index into the array. Display implicitly
  62. % STACK: 28.2743
  63.  
  64. v 0 r=1
  65. v 1 r=2*r
  66. v n r=2*pi*r*r*v(n-2)r/n
  67.  
  68. let v 0 r=1
  69. v 1 r=2*r
  70. v n r=2*pi*r*r*(v(n-2)r)/n
  71.  
  72. (define(v d r)(match d[0 1][1(* 2 r)][_(/(* 2 pi r r(v(- d 2)r))d)]))
  73.  
  74. (define(v d r)
  75. (match d
  76. [0 1]
  77. [1 (* 2 r)]
  78. [_ (/ (* 2 pi r r (v (- d 2) r) )
  79. d)]
  80. ))
  81.  
  82. (v 1 1)
  83. (v 2 3)
  84. (v 3 1)
  85. (v 3 4.5)
  86. (v 1 9.379)
  87. (v 0 48)
  88.  
  89. 2
  90. 28.274333882308138
  91. 4.1887902047863905
  92. 381.7035074111599
  93. 18.758
  94. 1
  95.  
  96. @a=1..2;push@a,6.283/$_*@a[$_-2]for 2..($b=<>);say$a[$b]*<>**$b
  97.  
  98. {import math._;(n,r)=>pow(r,n)*Seq(1,2,Pi,Pi*4/3)(n)}
  99.  
  100. { //define a block, the type of this is the type of the last expression, which is a function
  101. import math._; //import everything from math, for pow and pi
  102. (n,r)=> //define a function
  103. pow(r,n)* //r to the nth power multiplied by
  104. Seq(1,2,Pi,Pi*4/3)(n) //the nth element of a sequence of 1, 2, Pi and Pi*4/3
  105. }
  106.  
  107. (n,r)=>[1,r+r,a=Math.PI*r*r,a*r*4/3][n]
  108.  
  109. from math import*
  110. f=lambda n,r:n*r*2*(n<2or pi*r/n/n*(f(n-2,r)or 1))
  111.  
  112. from math import*
  113. f=lambda n,r:1*(n<1)or r*2*(n<2)or 2*pi*r*r/n*f(n-2,r)
  114.  
  115. from math import*
  116. lambda n,r:pi**(n/2)*r**n/gamma(n/2+1)
  117.  
  118. #N,R::((if (< N 2) ((? (!= 0 N) (* 2 R) 1)) ((/ (* (* (* (* (f (- N 2) R) 2)
  119. 3.1416) R) R) N))))
  120.  
  121. % n-circle.lithp
  122. (
  123. (def f #N,R::((if (< N 2) ((? (!= 0 N) (* 2 R) 1)) ((/ (* (* (* (* (f (- N 2) R) 2) 3.1416) R) R) N)))))
  124. (print (f 1 1))
  125. (print (f 2 3))
  126. (print (f 3 1))
  127. (print (f 3 4.5))
  128. (print (f 1 9.379))
  129. (print (f 0 48))
  130. )
  131.  
  132. #./run.js n-circle.lithp
  133. 2
  134. 28.274333882308138
  135. 4.1887902047863905
  136. 381.7035074111598
  137. 18.758
  138. 1
  139.  
  140. {1$_[2dP]*<f*,:)-2%./1+:*}
  141.  
  142. { e# Begin block: stack holds d r
  143. 1$_[2dP]*< e# Build a list which repeats [2 pi] d times and take the first d elements
  144. f* e# Multiply each element of the list by r
  145. ,:)-2% e# Build a list [1 ... d] and take every other element starting at the end
  146. ./ e# Pointwise divide. The d/2 elements of the longer list are untouched
  147. 1+:* e# Add 1 to ensure the list is non-empty and multiply its elements
  148. }
Add Comment
Please, Sign In to add comment