Skip to content

Commit

Permalink
Merge branch 'develop_algorithm' of https://github.com/kayabaakihiko1…
Browse files Browse the repository at this point in the history
…3/CPP into develop_algorithm
  • Loading branch information
kayabaakihiko13 committed Jul 15, 2023
2 parents 8d4eae1 + c762c19 commit 06374ad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
13 changes: 13 additions & 0 deletions commit_msg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
feat: menambahkan algoritma cosinus

``Deskripsi``
cosinus merupakan salah satu fungsi trigonometri
dari sebuah titik. cosinus ini juga bisa dikatakan
merupakan bilangan real dari bentuk panjang dari garis
yang bergelombang dan juga bisa dimasukan salah satu di dalam
pembahasan infinite series.
kali ini saya menggunakan metode dari salah satu infitine series
yaitu taylor series.

[wikipedia](https://en.wikipedia.org/wiki/Sine_and_cosine)
[algoritm_Source](https://people.math.sc.edu/girardi/m142/handouts/10sTaylorPolySeries.pdf)
8 changes: 4 additions & 4 deletions math/cos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ int factorial(int n){


template <typename T> double cosinus(T sudut,int iterable=4){
float result = 0.0;
double result = 0.0;
for (int n = 0; n <= iterable; ++n){
numerator = pow(-1,n) * pow(sudut,2*n);
denumerator = factorial(2*n);
result +=(numerator/denumerator);
double numerator = pow(-1,n) * pow(sudut,2*n);
double denumerator = factorial(2*n);
result =result + (numerator/denumerator);
}
return result;
}
Expand Down

0 comments on commit 06374ad

Please sign in to comment.