Skip to main content
15-Moonstone
August 22, 2020
Solved

Iteration

  • August 22, 2020
  • 2 replies
  • 3205 views

Dear all

i feel I can not do iteration x(h,i+1)=x(i)+h in Mathcad Prime
x1=2

N(h)=5/h

i(h)=1,...N(h)
x(h,i+1)=x(i)+h  (Error this point)

Thank you

 

    Best answer by Werner_E

    Maybe you can find here something you can use (still assuming you are looking for a result vector):

    Werner_E_0-1598093447233.png

    P6 worksheet attached

     

    2 replies

    23-Emerald IV
    August 22, 2020

    You cannot define a function with one of the formal parameters being an expression. 

    Try

    x(h, i):=x (h, i-1)+h

     

    Success!

    Luc

    15-Moonstone
    August 22, 2020

    And also x(h, i(h)):=x (h, i-1)+h

    25-Diamond I
    August 22, 2020

    Seems that you try to create a vector and are assuming ORIGIN=1.

    You are using x as a function with two arguments (h,i) in one place, but then as a function of only one argument in another.

    Are you looking for something like the following. If you are just interested in the last value, you can simply delete the last line (x) but of course the last value could be calculated more simply and direct.

    Werner_E_1-1598091304520.png

     

     

    15-Moonstone
    August 22, 2020

    I prefer like this

    x1=2

    N(h)=5/h

    i(h)=1,...N(h)
    x(h,i+1)=x(i)+h ( x is a function have h as a variable and i also  have h as a variable)

    15-Moonstone
    August 22, 2020

    And the answer I need x(i+1,h)