cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

When iI try to create an array with defined symbols, I get an error message that the symbos shoule be real althouh they have been assigned real values

nvsuryan
1-Newbie

When iI try to create an array with defined symbols, I get an error message that the symbos shoule be real althouh they have been assigned real values

When I define real numbers and try to use it in an array I get the message that one of the symbols needs to be a real number, They are all real numbers. See attached Mathcad file Example.What am I doing incorrectly?

47 REPLIES 47

Narasipur Suryanarayana wrote:

When I try to create y(subscript)series as shown in to create initial series with n = 11, I get the message "this variable is undefined." What am I doing wrong?

Can't tell as i don't see what you are actually doing.

The attached file shows what I am trying to do and where I am stuck. I shall look forward to getting your clarification.

I am attaching another file where I have reproduced your suggestion up to creating an initial array when I run into a problem. Could you kindly let me know where I am going wrong?

The index in my S.old is not a vector/matrix index but a literal index. You get it by simply typing a period "." after "S" and then continue with "old" (all without the quotes).

Thank you for the clarification. I tried it it works up to a point. But it looks like I may still have a problem as I proceed. I will work on it to see if I can resolve it by myself. If I cannot I hope I can get back to you.

Hello Mr. Werner

I was able to navigate the remaining parts successfully. The responses by Mr. Diaz and yourself are greatly appreciated.

I still have a small problem. Increasing the value of n I find the array of the results become huge. Is there any way that only last two or three columns of the results can be displayed?

Narasipur Suryanarayana wrote:

I still have a small problem. Increasing the value of n I find the array of the results become huge. Is there any way that only last two or three columns of the results can be displayed?

Sure!

I modified my routine "shanks()" so that the second argument now controls how many of the last iteration columns are returned. If this value is zero (or negative) the result is just the last calculated value (as was the case in the older routine when the argument mode was 0).

Find the modified worksheet attached.

P.S.: I lost track about the filed in play here so I, modified the first version I posted. The modification could be applied to the other version I posted in exactly the same way - its only the last few lines which have to be changed.

Sorry to be bugging you Mr. Werner; I am still having a problem even though I am trying to copy your second version faithfully. Could you kindly tell me where I am going wrong and also if there are other problems where I may have issues?

OK, here we go:

1) BLUE: Its the letter O, not a zero. It does not harm in your case, as you have ORIGIN=0 anyway. The only reason for using O (which is set to the current value of ORIGIN at the beginning of the program) instead of zero is, so that you can use the very same program unchanged in a sheet which has set ORIGIN to something different.

2) GREEN: You changed the 1 to 3 which will make one additional iteration even though our vector is just consisting of a single element. You would get an error es of using an invalid index.

3) YELLOW: Sorry for that. We have 1 x 2 matrices on both sides here! That way we can assign values to multiple variables using just one line. I think I was doing this because I was working on a monitor with rather low resolution and wanted to save space to be able to make a screenshot without having to capture a scrolling window. You may change both back to normal two-lines assignments.

4) RED: This is not an exponentiation like "^ T" but you can get the transpose operator from the menu (Matrix toolbar) or by typing Ctrl + 1. The reason for transposing the result vector is because I think that thats a better way to present the result.

Hope this helps.

Hello Mr. Werner

Thanks a million for your assistance. It worked beautifully.

One thing I did not understand in one your comments that increasing n to 22 mathcad crashed. I did not use any value for epsilon but have tried values of n up to 31 and no problem.

One other comment. As I told Mr. Diaz I am an old person (85+) still learning Mathcad (now you know why I came to frequently for assistance. Your explanations were easy to follow. Now I have to understand the programming part, which I hope to do on my own.

Is Mathcad results limited to 17 digits or is there any way to increase the number of digits?

One last comment. Your patience is commendable. Have you considered teaching as a profession - not much money there but a great deal of satisfaction if you can find students who would like to learn. I am saying this as I myself taught at a university for over 30 years.

Again thanks for all your assistance.

> One thing I did not understand in one your comments that increasing n to 22 mathcad crashed.

I was talking about my second variant of that routine.

In my first version I was doing iterations  until the vector is just 2 or 1 rows in length.

In the other version I stopped iterations when the values in the vector are all equal (according to a given tolerance epsilon).

> Is Mathcad results limited to 17 digits or is there any way to increase the number of digits?

As in every software which uses IEEE number formats numerical accuracy is about 16-16 digits.

Only way to get better precision is when you use symbolic evaluation, but you may run into other problems doing so.

> now you know why I came to frequently for assistance.

feel free to come back whenever you have a question or experience any problem. Thats what this forum is all about.

> Have you considered teaching as a profession -

Wouldn't mean much change. My work consists of teaching to a great part - for nearly 30 years now 😉

Regards

Werner

I implemented your program shanks2 with separate lines for n and s(subscript)O and it worked. But when I try to have both in one line as you have done (n s(subscript) or s. it does not work. How do you introduce space between the two?

You have to insert a 1 x 2 matrix first (Matrix palette or pressing Ctrl-M) and then fill the placeholders. You have to do this on the left and on the right side of the assigning arrow.

Thanks Mr. Watner. Implemented your suggestion and works beautifully.

MJG
18-Opal
18-Opal
(To:nvsuryan)

Sorry. I made a mistake in my query. I would like to create two range variables (not arrays) the second one using the first one.

k = 1..10

n = 10

j = 1..(n-2).k

When I try evaluate j I get the error message that k needs to be real.

What do you want the last element of j to be?

Hi Werner.

Very interesting implementation, with the introduction of the epsilon, and the mean function.

Also, it seems that you can implement, from there, a general purpose transformation routine. For that, in the while, rows > 2 don't work, but probably can implement an on error statement, for detect when the neccesary rows are not enough for a general transformation T. With more programming tools, like a kind of lasterror function, can catch what error occur evaluating T, but we don't have it.

Best regards.

Alvaro.

I am pretty sure that we could implement a more general transformation routine. I would add the transformation function and epsilon as function arguments.

We could also get rid of the mode parameter and default it to 0. That way it would not be necessary to store all intermediate matrices but we would use just 2 (the current and the last one). The transformation function should return two results, the vector and an error number which could be used in the main routine for termination in the while loop, replacing the rows>2 condition. As an alternative the tranform function could simply be written so that the input vector is returned in case the number of rows is to small. The main routine would check if the new vector is equal to the last and stop iteration if thats the case.

I am not sure about the mean function I introduced, though. Probably it would be a better idea to just return the last value in the remaining vector.

I also noticed that it does not help to increase the number n of elements in the initial vector of partial sums and decrease epsilon. The accuracy of the result is not increased. Guess we run into numerical round offs and while it would be possible to evaluate symbolically, calculation time is prohibiting (and right now my Mathcad crashed after increasing n just up to 22).

Werner

Top Tags