Skip to main content
24-Ruby IV
July 3, 2020
Solved

Is it an error in Mathcad?

  • July 3, 2020
  • 2 replies
  • 1596 views

Err.png

Best answer by Werner_E

@ValeryOchkov wrote:

Is it an error in Mathcad?


Not at all. Its the behaviour as it should be.

Note that the global b and the local b have nothing to do with each other! The local b is a new variable created by the program and as you don't provide a value for the element with index 0, this element is initialized with 0 as usual.

If you want a global variable to be used in a program you have to either provide it as an argument of your function or you must use it on the right hand side of a local assignment as you did with variable a.

In your program "a" is local only for a sort moment. after the fist assignment which introduces the global "a" on the right hand side it turns into the global variable. As ttokoro showed, just "mentioning" b (his first program line) does the job as well. I am not sure if this behaviour is OK from a purists point of view. The "normal" way to do it used to be the dummy assignment  b <-- b.

Werner_E_0-1593822062169.png

P.S.: It looks like you are using a 4K monitor like me (in combination with a large windows zoom factor). Thats the reason your screenshots are far too large when you embed them here. To make your post better readable I would advice that you either scale down the pics with an appropriate program or at least resize them after you embed them in your post.

2 replies

ttokoro
21-Topaz I
21-Topaz I
July 3, 2020

Prime.6

image.png

t.t.
Werner_E25-Diamond IAnswer
25-Diamond I
July 4, 2020

@ValeryOchkov wrote:

Is it an error in Mathcad?


Not at all. Its the behaviour as it should be.

Note that the global b and the local b have nothing to do with each other! The local b is a new variable created by the program and as you don't provide a value for the element with index 0, this element is initialized with 0 as usual.

If you want a global variable to be used in a program you have to either provide it as an argument of your function or you must use it on the right hand side of a local assignment as you did with variable a.

In your program "a" is local only for a sort moment. after the fist assignment which introduces the global "a" on the right hand side it turns into the global variable. As ttokoro showed, just "mentioning" b (his first program line) does the job as well. I am not sure if this behaviour is OK from a purists point of view. The "normal" way to do it used to be the dummy assignment  b <-- b.

Werner_E_0-1593822062169.png

P.S.: It looks like you are using a 4K monitor like me (in combination with a large windows zoom factor). Thats the reason your screenshots are far too large when you embed them here. To make your post better readable I would advice that you either scale down the pics with an appropriate program or at least resize them after you embed them in your post.