HP Forums
Solver - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Solver (/thread-4921.html)



Solver - Powersoft - 10-11-2015 03:54 PM

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


RE: Solver - cyrille de brébisson - 10-12-2015 05:43 AM

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


RE: Solver - Powersoft - 10-12-2015 07:16 AM

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


RE: Solver - cyrille de brébisson - 10-12-2015 03:13 PM

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


RE: Solver - Powersoft - 10-12-2015 03:21 PM

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


RE: Solver - cyrille de brébisson - 10-13-2015 05:18 AM

hello,

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

Cyrille


RE: Solver - Powersoft - 10-13-2015 05:49 AM

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.


RE: Solver - cyrille de brébisson - 10-14-2015 05:45 AM

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