fixed-point-iteration

Converting explicit euler to implicit euler (via fixed-point iteration)

…衆ロ難τιáo~ 提交于 2021-01-05 11:29:34
问题 So I have a school task where I need to calculate the position of a bunch of cars following each other on a road (AKA driving in a line, so if Car 10 [the car that is first in line] brakes, then Car 9 brakes and when Car 9 brakes, Car 8 has to brake etc.). Each car follows the "three second rule" (except the car that is first in line, he can drive as fast as he wants and all other cars in line adjust their velocity accordingly). Each cars velocity is represented by the expression: where 'i'

Converting explicit euler to implicit euler (via fixed-point iteration)

ぃ、小莉子 提交于 2021-01-05 11:26:51
问题 So I have a school task where I need to calculate the position of a bunch of cars following each other on a road (AKA driving in a line, so if Car 10 [the car that is first in line] brakes, then Car 9 brakes and when Car 9 brakes, Car 8 has to brake etc.). Each car follows the "three second rule" (except the car that is first in line, he can drive as fast as he wants and all other cars in line adjust their velocity accordingly). Each cars velocity is represented by the expression: where 'i'

What is fixed point?

孤街浪徒 提交于 2020-01-04 04:12:24
问题 I'm rewatching some of the earlier lectures on SICP. The notion of a fixed-point is a bit confusing to me. The fixed-point procedure: should I be thinking about it this way, "it's the way to find a fixed-point of a given function." So given f(2) = 2 ? Also why is it stated in this lecture, that a new function y that maps to x / y is a fixed point? 回答1: According to Fixed point (mathematics) on Wikipedia: In mathematics, a fixed point (sometimes shortened to fixpoint, also known as an

Solve this equation with fixed point iteration

╄→尐↘猪︶ㄣ 提交于 2019-12-21 04:04:15
问题 How can I solve this equation x 3 + x - 1 = 0 using fixed point iteration? Is there any fixed-point iteration code (especially in Python) I can find online? 回答1: Using scipy.optimize.fixed_point: import scipy.optimize as optimize def func(x): return -x**3+1 # This finds the value of x such that func(x) = x, that is, where # -x**3 + 1 = x print(optimize.fixed_point(func,0)) # 0.682327803828 The Python code defining fixed_point is in scipy/optimize/minpack.py. The exact location depends on

How do I iterate until a fixed point in Clojure?

徘徊边缘 提交于 2019-12-11 02:33:23
问题 I'm frequently in the position that my code reads like so: (iterate improve x) And I'm looking for the first value that no longer is an improvement over the previous. Neither filter nor take-while lend themselves to an obvious solution. However, I'm hesitant to write out: (loop [current x next (improve x)] (if (= current next) current (recur next (improve next)))) or: (let [improvements (iterate improve x)] (->> (map vector improvements (rest improvements)) (filter (partial apply =)) (ffirst)

Fixed point combinator in Haskell

十年热恋 提交于 2019-11-27 17:50:55
问题 The fixed point combinator doesn't always produce the right answer given the definition: fix f = f (fix f) The following code does not terminate: fix (\x->x*x) 0 Of course, fix can't always produce the right answer, but I was wondering, can this be improved? Certainly for the above example, one can implement some fix that looks like fix f x | f x == f (f x) = f x | otherwise = fix f (f x) and gives the correct output. What is the reason the above definition (or something even better, as this