Skip to main content
5-Regular Member
May 3, 2024
Solved

Help with summation (converted sheet from MC15 to Prime)

  • May 3, 2024
  • 1 reply
  • 2293 views

Hi,

 

I am converting an old Mathcad 15 sheet to Mathcad Prime 9.0 and am working through it resolving errors that have popped up in the conversion. Currently im stumped by an

error that comes up with a summation in a program. See attached picture.

 

The program worked perfectly fine in MC15 but in Prime it throws me a "this value must be an integer" error. I've tried backtracking what could be causing the error and the only thing i could come up with is if the error get's thrown in a step where it's trying to summarise from n=460->0... ? However the same formula worked fine in MC15.

 

Kind regards,

Johan

Best answer by LucMeekes

First: You should always attach the Mathcad/Prime sheet to your problem description.

 

Then to the error message:

I think your problem lies with how you create the value 'n' that you use to index the rows of matrix U.i.netto.

This index n is calculated by taking one of the values in the matrix BA and dividing that by steg, which is defined as 0.01.

Let's take an example. One of the BA values is 4.6; divided by steg (0.01) that should result in 460, isn't it?

Well here is what Prime calculates:

LucMeekes_0-1714757213488.png

OK, that looks like 460, but is it? Let's compare:

LucMeekes_1-1714757259584.png

Gives a 0 (false, so NOT true), indicating that 4.6/steg is NOT equal to 460. Apparently when n is 4.6/steg, it is not an integer value. How much does it differ:

LucMeekes_2-1714757353199.png

(This value is in the order of the numerical resolution, due to digital representation of numbers, internally, with a limited number of bits.) So the difference is not much, but still. Prime notices that n in this case is not an integer and flags the error.

Since Mathcad 15 uses much the same numerical methods, I should think that Mathcad 15 would also see such n as not an integer, and flag an error. You say it worked, I wonder what you changed, going from Mathcad to Prime...

 

What can you do about it? One approach could be:

Increase the values in BA by a factor of 100 and use those, without division by steg, to index the U.i.netto matrix. Everywhere else where you need those 100 times smaller values of the original BA, multiply them by steg.

 

Success!
Luc

1 reply

24-Ruby III
May 3, 2024

Hi,

check ui.netto matrix .

LucMeekes23-Emerald IVAnswer
23-Emerald IV
May 3, 2024

First: You should always attach the Mathcad/Prime sheet to your problem description.

 

Then to the error message:

I think your problem lies with how you create the value 'n' that you use to index the rows of matrix U.i.netto.

This index n is calculated by taking one of the values in the matrix BA and dividing that by steg, which is defined as 0.01.

Let's take an example. One of the BA values is 4.6; divided by steg (0.01) that should result in 460, isn't it?

Well here is what Prime calculates:

LucMeekes_0-1714757213488.png

OK, that looks like 460, but is it? Let's compare:

LucMeekes_1-1714757259584.png

Gives a 0 (false, so NOT true), indicating that 4.6/steg is NOT equal to 460. Apparently when n is 4.6/steg, it is not an integer value. How much does it differ:

LucMeekes_2-1714757353199.png

(This value is in the order of the numerical resolution, due to digital representation of numbers, internally, with a limited number of bits.) So the difference is not much, but still. Prime notices that n in this case is not an integer and flags the error.

Since Mathcad 15 uses much the same numerical methods, I should think that Mathcad 15 would also see such n as not an integer, and flag an error. You say it worked, I wonder what you changed, going from Mathcad to Prime...

 

What can you do about it? One approach could be:

Increase the values in BA by a factor of 100 and use those, without division by steg, to index the U.i.netto matrix. Everywhere else where you need those 100 times smaller values of the original BA, multiply them by steg.

 

Success!
Luc

Joaberg5-Regular MemberAuthor
5-Regular Member
May 6, 2024

This is actually exactly what happens. Many thanks!

 

Why does this happen though? I've checked and the values of BA and steg is exactly 4.6 and 0.01 respectively but just like you said the 4.6/0.01 does not equal 460. I solved it by adding rounding to the values in the summation definition. Funny thing is Mathcad 15 also shows that the value of BA/steg (step) is not equal to 460 however that program does not throw an error due to it, see applied picture.

 

About supplying sheets to the problem description: How do people go about this when the sheet could be considered a trade secret?

 

Kind regards,

Johan