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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Filtering out unwanted results

DaveWooff
10-Marble

Filtering out unwanted results

Please see attached worksheet (I'm using Prime 3.0).

 

I would like "fd()" to return only positive real results.

 

Is my problem perhaps that in function "fd()" that it cannot know whether or not the solved variable (x in this case) is real, imaginary or negative etc.?  And if this is the case is there a more appropriate or accepted way to filter out the unwanted results?

 

Thank you.

7 REPLIES 7
Werner_E
25-Diamond I
(To:DaveWooff)

How about this:

Werner_E_0-1580747551392.png

 

Werner_E
25-Diamond I
(To:Werner_E)

You may also consider using a numeric solver. Either a solve block or the "root" command in one of its two flavors (providing a range or providing a guess)

Werner_E_0-1580748126666.png

 

Maybe even without fb and fc using numerical derivative

Werner_E_0-1580748560970.png

 

 

Thanks Werner_E,

thanks for your suggestion but of course, I have simplified and sanitised my problem for the forum post so some of what I am doing has been lost which may not have helped much.

 

I think the thing I am taking away from this is: when a solve statement is used inside a generalised function, the set of solutions is necessarily also generalised and assumptions about certain variables will only go so far to minimise that set.  In reality, to boil down further you have to run the solve with the actual values - does this make sense?  In other words, when using a solve staement in a function, the solution is determined only once when the function is defined and not each time it is called.

 

LucMeekes
23-Emerald III
(To:DaveWooff)

"In other words, when using a solve statement in a function, the solution is determined only once when the function is defined and not each time it is called."

I guess so.

If you insist on using the symbolic solve, you could do:

LucMeekes_0-1580753075713.png

Notice that I had to filter out the complex values first, before comparing with 0.

 

Success!
Luc

 

Werner_E
25-Diamond I
(To:DaveWooff)


In other words, when using a solve staement in a function, the solution is determined only once when the function is defined and not each time it is called.

 


That's correct. An option may be to copy the symbolic evaluation in a program line

Werner_E_0-1580767938691.png

 

Unfortunately this is only possible in Mathcad and cannot be done any more in Prime.

 

The other problem is that Mathcads symbolic will ever so often ignore any "assume" modifiers if it has to switch to numeric mode. The modifier simply does nor work as expected.

Of course you can always use a user written program to filter the positives values from a vector

Werner_E_0-1580768210933.png

 

 

 

LucMeekes
23-Emerald III
(To:Werner_E)

Beware, you have to check for complex values.

Apparently (Mathcad and) Prime allow to check signs for purely imaginary numbers, but try this out with a general complex number, one that has nonzero real AND imaginary parts...

LucMeekes_0-1580768188541.png

In Prime (4):

LucMeekes_1-1580768286440.png

 

Success!
Luc

Werner_E
25-Diamond I
(To:LucMeekes)

You are right, so something like this would do the job (it also addresses round off errors which may results in real values being stored with a very small imaginary part)

Werner_E_0-1580782480318.png

 

Announcements

Top Tags