Skip to main content
10-Marble
February 3, 2020
Question

Filtering out unwanted results

  • February 3, 2020
  • 2 replies
  • 3342 views

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.

2 replies

25-Diamond I
February 3, 2020

How about this:

Werner_E_0-1580747551392.png

 

25-Diamond I
February 3, 2020

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

 

 

DaveWooff10-MarbleAuthor
10-Marble
February 3, 2020

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.

 

23-Emerald IV
February 3, 2020

"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