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.
How about this:
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)
Maybe even without fb and fc using numerical derivative
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.
"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:
Notice that I had to filter out the complex values first, before comparing with 0.
Success!
Luc
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
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
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...
In Prime (4):
Success!
Luc
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)