# Question ) Mathematical equivalence, but different results of fixed point?

**URL:** <https://discourse.julialang.org/t/question-mathematical-equivalence-but-different-results-of-fixed-point/65628>\
**Category:** General Usage\
**Created:** [August 1, 2021, 12:44pm UTC](https://discourse.julialang.org/t/question-mathematical-equivalence-but-different-results-of-fixed-point/65628 "2021-08-01T12:44:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zerosum](https://avatars.discourse-cdn.com/v4/letter/z/b2d939/32.png) [@Zerosum](https://discourse.julialang.org/u/Zerosum)\
**Post date:** [August 1, 2021, 12:44pm UTC](https://discourse.julialang.org/t/question-mathematical-equivalence-but-different-results-of-fixed-point/65628/1 "2021-08-01T12:44:23Z")

</div>

I am working on my own project, and I proved the following recursive equation has a  
unique fixed point (due to the Banach Fixed Point Theorem).

Here is the equation with simplified notations. I couldn’t find any option to write mathematical equations in a nice way. Please let me know if this matters for your understanding.

```julia
Way1 : v(x) = -c + s*n*max(F(v(x)),v(x)) + s*m*max(G(v(x)),v(x)) + s*(1-n-m)*v(x)

```

where all the parameters are in (0,1) with n+m in (0,1). Unless there is a mathematical mistake, I believe this exacts to

```julia
Way2 : v(x) = -c/(1-s) + s/(1-s)*n*max(F(v(x))-v(x),0) + s/(1-s)*m*max(G(v(x))-v(x),0)

```

However somehow when I use **while** function to get the fixed point, whereas **Way1** attains the fixed point, **Way2** does not.

I would very much like to know if this difference is whether coming from some error in my codes or from the way iteration works differently. Just in case, I leave my real codes.

Way 1

```julia
m_A = 0.15
m_B = 0.8
maxiter = 5000
tolerance = 1e-10
v_iv = collect(1:n) ./1000 # initial condition

# setup the algorithm
v_old = v_iv
normdiff = Inf
iter = 1

while normdiff > tolerance && iter <= maxiter
    v_new = -c .+ s .* m_A .* max.(im_sur(v_old),v_old) .+ s.*m_B .* max.(na_splus(v_old),v_old) .+ s .* (1-m_A-m_B) .* v_old 
    normdiff = norm(v_new - v_old)
    v_old = v_new
    iter = iter + 1
end

```

```julia
# Way 2
c_new = -c / (1-s)
m_A_new = m_A * s / (1-s)
m_B_new = m_B * s / (1-s)

while normdiff > tolerance && iter <= maxiter
    v_new = c_new .+ m_A_new .* max.(im_sur(v_old) .- v_old , 0) .+ m_B_new .* max.(na_splus(v_old) .- v_old , 0)
    normdiff = norm(v_new - v_old)
    v_old = v_new
    iter = iter + 1
end

```

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 3, 2021, 8:53am UTC](https://discourse.julialang.org/t/question-mathematical-equivalence-but-different-results-of-fixed-point/65628/2 "2021-08-03T08:53:36Z")

</div>

It would be easier to help with self-contained MWE (we don’t know what `c`, `s`, `F`, … are).

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …
