HP Forums

Full Version: Solver
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have wrote a function inside my program.
Code:

EXPORT TEST(x)
BEGIN
  RETURN ..........CODE..............
END;
Now I would solved this function for a value like this

TEST(x)-0,5=0

Is this posible to do this inside my program?

Wich solver do I use? (My function is not linear)

Is it also posible to give the error for stopping the solver?

Cheers,

Jan
Hello,

The following will work.
Please note that FNC must be either EXPORTED, or you must fully qualify it in the call to Solve.SOLVE.

EXPORT FNC(A)
BEGIN
return COS(A);
END;

EXPORT test()
BEGIN
Solve.SOLVE(FNC(X),X);
END;

Cyrille
Cyrille,

Thanks for the response.
But I won't to use the solver to search between boundaries.

(Like a binary search)

Is that posible?

Cheers,

Jan
Hello,

The solver can be given 1 or 2 guesses to get started, HOWEVER, it does NOT (as a general rule) do a binary search, it uses 3 types of methods:
Quadratic, hyperbolic and Newton, basically, it tries first to ascertain what the function looks like and then pick one of the 3 methods to try to zero on the solution.
When it feels that it is very close, then it uses dichotomy search.

The net result is that there is no guaranties that the zero found (if the function has more than 1) will be close to the provided guesses (although it generally is).

Cyrille
Cyrille

Please can you help me with the syntax.

My Function name id SunPos, and I won't found a zero between
5763.9 <= x <= 5764.9.

Try to find an example but could notting found!

Thanks,

Jan
hello,

Can you post your program? or at least the function code?

Cyrille
Hi,

This is my function code;

Code:

F(t)
BEGIN
//--------------------------------------------
//Sunposition gives the Azimuth back
//Sove SunPosition(t)-0.8=0
//--------------------------------------------
RETURN SunPosition(t)-0.8;
END;


Thanks for any help.

Regards.
Hello,

As I said in my first posting:
>Please note that [the evaluation function] must be either EXPORTED, or you must fully qualify it in the call to Solve.SOLVE.

so, if you EXPORT F, you should be able to do:

Solve.SOLVE(F(X),X);

However, I would suggest that you rename it to something else than F in order to avoid any possible funny business with the build in F variable.

Cyrille
Reference URL's