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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

6-Contributor

## Restrict result to Positive Solutions?

Dear All

For the given attachment file how I can restrict the output results of minerr function to get positive only, as in my problem I need all the parameter that is calculated with minerr to be positive

Regards

Abdelazeem

1 ACCEPTED SOLUTION

Accepted Solutions
24-Ruby V
(To:Abdelazeem)

Sorry, I didn't save the file.

But you just need to change your guess of C:=0.2 to, lets say, C:=2 and you will get the positive results.

You may experiment with different values.

The reason I turned the solve block into a function of the guess for C was because I wanted to be able to show the effects of different guess values side by side without the need to make multiple screen shots.

If you want to do this, you just have to modify the last line in the solve block to read f(C):=minerr(...) and delete the = after the minerr command - you can see it in the screenshot I posted.

Of course you also have to delete the guess C:=0.2 on top of the solve block.

11 REPLIES 11
24-Ruby V
(To:Abdelazeem)

As far as I see the results already ARE all positive!

But you always can add constraints like   A>0, etc. in your solve block. A negative A is taken as an error and Prime will try to minimize the overall errors. Constraints are soft constraints and you can weight them by multiplication. A negative A=-1 ist maybe considered a small error but if your constraint reads 10^5*A>0 its taken as a far larger error and Prime will try to make it smaller.

6-Contributor
(To:Werner_E)

Firstly thank you indeed for your reply, secendly, I used another example and I attached another one

this is the new issue

I attached the file

24-Ruby V
(To:Abdelazeem)

I attached the file

But its the same file as in your first post. Still only positive results.

6-Contributor
(To:Werner_E)

I am sorry about that , I added all parameters >0 but still problem exist

as in the attachment file

24-Ruby V
(To:Abdelazeem)

Your system seems to be quite unstable and is VERY sensitive wrt the guess values.

I played around with the guesses and found that especially changing the guess for C has a great impact an the result. Some values for C like 1.41, 2, 5 gives you positive results but those results are quite different from each other. You'll have to decide if they are meaningful and trustworthy at all.

To make it easier to compare results for different guess values for C I turned the solve block into a function f(C) depending on the guess value. Thats what you see in the pic below.

6-Contributor
(To:Werner_E)

really thank you for your help, please could you send the mathcade file in the attachment with me

24-Ruby V
(To:Abdelazeem)

Sorry, I didn't save the file.

But you just need to change your guess of C:=0.2 to, lets say, C:=2 and you will get the positive results.

You may experiment with different values.

The reason I turned the solve block into a function of the guess for C was because I wanted to be able to show the effects of different guess values side by side without the need to make multiple screen shots.

If you want to do this, you just have to modify the last line in the solve block to read f(C):=minerr(...) and delete the = after the minerr command - you can see it in the screenshot I posted.

Of course you also have to delete the guess C:=0.2 on top of the solve block.

6-Contributor
(To:Werner_E)

Thank you for you fast help and your easy discussion

24-Ruby V
(To:Abdelazeem)

I played around with your sheet again and found, that if we weight the constraints A>0 very high by multiplying A with a high number, the solve block delivers a solution with all positive values even with the guess value C:=0.2.

The price is that the other constraints, your four equation, are now weighted much lower and if you check I guess the result is not satisfying:

Ideally all four results should be close to zero!

You may experiment with different guesses and maybe different values for "factor".

Prime6 worksheet attached 😉

The prove

6-Contributor
(To:Werner_E)