Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Jun 19, 2017
01:26 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 19, 2017
01:26 AM

I am getting error as this value must be a scalar in polyroots function

Hi all,

I am getting error as 'This value must be a scalar

in polyroots function'.

Please can anyone help me.

I attached my mathcad code below.

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

Jun 19, 2017
05:37 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 19, 2017
05:37 AM

Which version and maintenance release of Mathcad are you using?

Maybe the problem is due to a bug in an older version which already is fixed?

Do you get the error already in the last line of your sheet when you just define the function r or when you try to evaluate it via r(10)=

I also experience no problem in evaluating your function r (Mathcad 15, M045).

When calculating your various coefficients a(i), b(i), etc. every call evaluates the solve blocks again and again. This could be speeded up significantly by creating a function which calls the solve blocks just once and then calculates and returns ALL of the necessary coefficients in a vector.

Doing so would be quite some work in rewriting the sheet but probably worth the time spent.

Her a small example - the function I1(i): Your version of this function calls the solve block for f three times while the version below calls it only once (and we don't need the function x1(i) and x2(i) you defined above anymore):

using this new function I1 and a similar one for I2 already cuts the time to calculate r to one third and the whole sheet could be speeded up much, much more, I guess.

Nevertheless you experience that strange error. So lets try some changes (I am just poking around in the dark):

What do you get when you evaluate B(10)=? Do you get

If yes, try to reformulate your function r

Do you get the result or do you still experience that error?

11 REPLIES 11

Jun 19, 2017
04:53 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 19, 2017
04:53 AM

Hi vetri,

It seems to me that there are no problems. It only takes a long time to compute ..

Greetings

Franc

Jun 19, 2017
04:58 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 19, 2017
04:58 AM

Dear Franc,

Thank you for your reply.

But, for me I am getting the same error as 'This value must be a scalar'

Could you please attach your code.

Thanks.

Jun 19, 2017
05:06 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 19, 2017
05:06 AM

The polynomial is of the third degree, so we have three roots (all real or one real and two c.c.) for each i value. I have erroneously traced the root vector module. To trace the module of each root, varying i, it takes a long time.

Jun 19, 2017
06:57 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 19, 2017
06:57 PM

F.M. wrote:

Try the version here

Solved: Re: I am getting error as this value must be a sca... - PTC Community

for a speed boost 😉

Jun 19, 2017
05:17 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 19, 2017
05:17 AM

Hi Vetri,

I'm getting no errors as well.

And yes, as Frank said: It takes a lot of time for computing.

Can you simplify or reduce your equations?

Greetings, Volker

Volker

Jun 19, 2017
05:37 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 19, 2017
05:37 AM

Which version and maintenance release of Mathcad are you using?

Maybe the problem is due to a bug in an older version which already is fixed?

Do you get the error already in the last line of your sheet when you just define the function r or when you try to evaluate it via r(10)=

I also experience no problem in evaluating your function r (Mathcad 15, M045).

When calculating your various coefficients a(i), b(i), etc. every call evaluates the solve blocks again and again. This could be speeded up significantly by creating a function which calls the solve blocks just once and then calculates and returns ALL of the necessary coefficients in a vector.

Doing so would be quite some work in rewriting the sheet but probably worth the time spent.

Her a small example - the function I1(i): Your version of this function calls the solve block for f three times while the version below calls it only once (and we don't need the function x1(i) and x2(i) you defined above anymore):

using this new function I1 and a similar one for I2 already cuts the time to calculate r to one third and the whole sheet could be speeded up much, much more, I guess.

Nevertheless you experience that strange error. So lets try some changes (I am just poking around in the dark):

What do you get when you evaluate B(10)=? Do you get

If yes, try to reformulate your function r

Do you get the result or do you still experience that error?

Jun 19, 2017
06:29 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 19, 2017
06:29 AM

Here is a sheet where i have speeded up the second solve block which called the first one over an over again and was one main reason for the slow claculation.

The evaluation of r is now accelerated by a factor between 100 and 200 and there is still great potential for further improvements, once your problem with the polyroot function is solved.

Jun 19, 2017
08:16 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 19, 2017
08:16 AM

Dear all,

Thank you very much for your valuable comments.

Werner Exinger, As you mentioned in your reply,

I tried for B(10) and I got the same result as you got,

But, when I try to reformulate 'r' as you mentioned in the second line,

I experience the same type of error.

I am using mathcad 15.

Thanks.

PS.

Could you please attach the code for this,

https://www.ptcusercommunity.com/servlet/JiveServlet/showImage/2-492393-117216/pastedImage_3.png

Jun 19, 2017
09:09 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 19, 2017
09:09 AM

> Could you please attach the code for this,

Why? There is nothing special about it and easily typed in.

If I understand your answer right you already tried it without success.

Furthermore that code is included in my second answer (I used co instead of coeff out of laziness.

Jun 19, 2017
08:23 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 19, 2017
08:23 AM

Dear Werner Exinger,

I opened several mathcad programs.

So, due to that I got that type of error.

I closed all the mathcad program and I restarted Mathcad

again, then I found that there is no such type of error.

Thanks again and all for your valuable comments.

Jun 19, 2017
09:10 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 19, 2017
09:10 AM

Glad you found such an easy solution to your problem!