From 0619e579c3e52414c7173b957d1c409dc5708518 Mon Sep 17 00:00:00 2001 From: Patrik Tesarik Date: Thu, 6 Sep 2018 23:10:07 +0200 Subject: [PATCH 1/9] Delete monte_carlo_pi.f90 --- contents/monte_carlo_integration/code/fortran/monte_carlo_pi.f90 | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 contents/monte_carlo_integration/code/fortran/monte_carlo_pi.f90 diff --git a/contents/monte_carlo_integration/code/fortran/monte_carlo_pi.f90 b/contents/monte_carlo_integration/code/fortran/monte_carlo_pi.f90 deleted file mode 100644 index e69de29bb..000000000 From 3e86449900be9d6007506ae341ae17e20f3d7022 Mon Sep 17 00:00:00 2001 From: depate Date: Wed, 12 Sep 2018 22:50:19 +0200 Subject: [PATCH 2/9] init --- contents/bubble_sort/code/fortran/bubble.f90 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 contents/bubble_sort/code/fortran/bubble.f90 diff --git a/contents/bubble_sort/code/fortran/bubble.f90 b/contents/bubble_sort/code/fortran/bubble.f90 new file mode 100644 index 000000000..1031a3617 --- /dev/null +++ b/contents/bubble_sort/code/fortran/bubble.f90 @@ -0,0 +1,15 @@ +SUBROUTINE bubblesort(array) + IMPLICIT NONE + INTEGER :: len_array + REAL(8), ALLOCATABLE, DIMENSION(:,:) :: array + + + for i +END SUBROUTINE bubblesort + +PROGRAM + IMPLICIT NONE + INTEGER :: cols, rows + + +END PROGRAMM From 5d1602aa2c4e38df55f2e5f3adaad5761751b18d Mon Sep 17 00:00:00 2001 From: Patrik Tesarik Date: Sun, 23 Sep 2018 02:52:46 +0200 Subject: [PATCH 3/9] further implementation --- contents/bubble_sort/code/fortran/bubble.f90 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/contents/bubble_sort/code/fortran/bubble.f90 b/contents/bubble_sort/code/fortran/bubble.f90 index 1031a3617..bf28f4dd0 100644 --- a/contents/bubble_sort/code/fortran/bubble.f90 +++ b/contents/bubble_sort/code/fortran/bubble.f90 @@ -1,15 +1,18 @@ SUBROUTINE bubblesort(array) IMPLICIT NONE - INTEGER :: len_array + INTEGER :: len_array REAL(8), ALLOCATABLE, DIMENSION(:,:) :: array - for i + DO + + END DO END SUBROUTINE bubblesort -PROGRAM - IMPLICIT NONE - INTEGER :: cols, rows +PROGRAM main + +IMPLICIT NONE +INTEGER :: cols, rows END PROGRAMM From 1ea8e186748cadef359def352046566145838660 Mon Sep 17 00:00:00 2001 From: Patrik Tesarik Date: Sun, 23 Sep 2018 16:36:06 +0200 Subject: [PATCH 4/9] next --- contents/bubble_sort/code/fortran/bubble.f90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contents/bubble_sort/code/fortran/bubble.f90 b/contents/bubble_sort/code/fortran/bubble.f90 index bf28f4dd0..9e6733bb1 100644 --- a/contents/bubble_sort/code/fortran/bubble.f90 +++ b/contents/bubble_sort/code/fortran/bubble.f90 @@ -1,8 +1,9 @@ SUBROUTINE bubblesort(array) IMPLICIT NONE - INTEGER :: len_array + INTEGER :: array_length, array_shape REAL(8), ALLOCATABLE, DIMENSION(:,:) :: array + len_array = size(array) DO From 824060b5210140b7345a71ed4995923dc013366c Mon Sep 17 00:00:00 2001 From: depate Date: Tue, 2 Oct 2018 12:39:52 +0200 Subject: [PATCH 5/9] hopefully fixes things --- contents/bubble_sort/code/fortran/bubble.f90 | 22 -------------------- 1 file changed, 22 deletions(-) diff --git a/contents/bubble_sort/code/fortran/bubble.f90 b/contents/bubble_sort/code/fortran/bubble.f90 index 001ce6f94..fb903f0d3 100644 --- a/contents/bubble_sort/code/fortran/bubble.f90 +++ b/contents/bubble_sort/code/fortran/bubble.f90 @@ -1,24 +1,3 @@ -<<<<<<< HEAD -SUBROUTINE bubblesort(array) - IMPLICIT NONE - INTEGER :: array_length, array_shape - REAL(8), ALLOCATABLE, DIMENSION(:,:) :: array - - len_array = size(array) - - DO - - END DO -END SUBROUTINE bubblesort - -PROGRAM main - -IMPLICIT NONE -INTEGER :: cols, rows - - -END PROGRAMM -======= PROGRAM main IMPLICIT NONE @@ -61,4 +40,3 @@ SUBROUTINE bubblesort(array) END SUBROUTINE bubblesort END PROGRAM main ->>>>>>> 44181dc533101507167ae8fe2c97329100941098 From 252f9c3afa2193f44dd8508ef8fe1e80ff9e5492 Mon Sep 17 00:00:00 2001 From: depate Date: Tue, 2 Oct 2018 16:37:56 +0200 Subject: [PATCH 6/9] implementation & documentaiion --- .../code/javascript/euler.js | 32 +++++++++++++++++++ .../forward_euler_method.md | 2 ++ 2 files changed, 34 insertions(+) create mode 100644 contents/forward_euler_method/code/javascript/euler.js diff --git a/contents/forward_euler_method/code/javascript/euler.js b/contents/forward_euler_method/code/javascript/euler.js new file mode 100644 index 000000000..14026e04e --- /dev/null +++ b/contents/forward_euler_method/code/javascript/euler.js @@ -0,0 +1,32 @@ +function forward_euler(time_step, n) { + var arr = []; + arr[0] = 1; + for (var i = 1; i <= n; i++) { + arr[i] = arr[i - 1] - 3 * arr[i - 1] * time_step; + } + return arr; +} + +function check_euler(arr, time_step, threshold) { + var is_approx = true; + for (var i = 1; i <= arr.length; i++) { + var solution = Math.exp(-3 * time_step * i); + + if (Math.abs(arr[i] - solution) > threshold) { + alert(arr[i], solution); + is_approx = false; + } + } + return is_approx; +} + +function main() { + time_step = 0.01; + threshold = 0.01; + n = 100; + var euler_result = forward_euler(time_step, n); + var check_result = check_euler(euler_result, time_step, threshold); + alert(check_result); +} + +main(); diff --git a/contents/forward_euler_method/forward_euler_method.md b/contents/forward_euler_method/forward_euler_method.md index 25210e1d1..c7a00d4f9 100644 --- a/contents/forward_euler_method/forward_euler_method.md +++ b/contents/forward_euler_method/forward_euler_method.md @@ -121,6 +121,8 @@ Full code for the visualization follows: [import, lang:"matlab"](code/matlab/euler.m) {% sample lang="swift" %} [import, lang:"swift"](code/swift/euler.swift) +{% sample lang="js" %} +[import, lang:"javascript"](code/javascript/euler.js) {% endmethod %}