diff options
author | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-02-25 14:42:55 +0100 |
---|---|---|
committer | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-02-25 14:42:55 +0100 |
commit | 9477dbe667f250ecd23f8fc0d56b942191526421 (patch) | |
tree | a4b50c9a726f415f835f5311c11c5d66e95f688c /Semestr 3/anm/horner.jl | |
parent | 1968c1e590077bd51844eacfac722d7963848cb8 (diff) |
Stare semestry, niepoukladane
Diffstat (limited to 'Semestr 3/anm/horner.jl')
-rw-r--r-- | Semestr 3/anm/horner.jl | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Semestr 3/anm/horner.jl b/Semestr 3/anm/horner.jl new file mode 100644 index 0000000..a3fb69b --- /dev/null +++ b/Semestr 3/anm/horner.jl @@ -0,0 +1,16 @@ +function horner(w, n, x0)
+ p = w[n + 1]
+ q = 0
+ r = w[n + 1]
+ t = 0
+ for i in range(n, 1, step=-1)
+ q = p + x0 * q
+ p = w[i] + x0 * p
+ t = r + x0 * t
+ r = p + x0 * r
+ end
+ return [p, q, r, t]
+end
+
+
+println(horner([-13, 10, -7, 2], 3, 2))
\ No newline at end of file |