This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Twitter @thinkphp | |
* | |
* Approximate the function sin with series Taylor! | |
* sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ....(-1)^n+1*x^(2n+1)/(2n+1)!; | |
* | |
*/ | |
function fact($n) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
cos(x) = 1-x^2/2!+x^4/4!-x^6/6!+..- | |
''' | |
import math | |
def fact(n): | |
if n==0: | |
return 1 | |
else: | |
return n*fact(n-1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
sin(x) = x-x^3/3!+x^5/5!-x^7/7!+..- | |
''' | |
import math | |
def fact(n): | |
if n==0: | |
return 1 | |
else: | |
return n*fact(n-1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Pseudocode of the complete algorithm | |
Twitter : http://twitter.com/thinkphp | |
Website : http://thinkphp.ro | |
Google Plus : http://gplus.to/thinkphp | |
MIT Style License | |
*/ | |
INSERTION-SORT(V) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Insertion Sort | |
Twitter : http://twitter.com/thinkphp | |
Website : http://thinkphp.ro | |
Google Plus : http://gplus.to/thinkphp | |
MIT Style License | |
''' | |
def insertionSort(arr): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Insertion Sort in PHP | |
Twitter : http://twitter.com/thinkphp | |
Website : http://thinkphp.ro | |
Google Plus : http://gplus.to/thinkphp | |
MIT Style License | |
*/ | |
function insertionSort($arr){ | |
$n = count($arr); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Insertion Sort in JavaScript | |
Twitter : http://twitter.com/thinkphp | |
Website : http://thinkphp.ro | |
Google Plus : http://gplus.to/thinkphp | |
MIT Style License | |
*/ | |
function insertionSort(arr) { | |
var n = arr.length-1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Computes SQuare RooT in Python SQRT | |
s = (s+nr/s)1/2 | |
Twitter : http://twitter.com/thinkphp | |
Website : http://thinkphp.ro | |
Google Plus : http://gplus.to/thinkphp | |
MIT Style License | |
''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
x | |
f(x) = e - a | |
if f(0)*f(a) < 0 then exists the solution (0,a] | |
''' | |
import math | |
import sys | |
def loge(n,li,ls): | |
if math.fabs(li-ls) <= 0.000001: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Computes the value of e(2.718281827...) using infinite series | |
Twitter: @thinkphp | |
Website: http://thinkphp.ro | |
G+ : http://gplus.to/thinkphp | |
MIT Style License | |
1 + 1/1! + 1/2! + 1/3! + ... | |
2 + 1/2! + 1/3!+ ... | |
''' |