The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function

 How to evaluate a function in a given point
10-05-2019, 02:54 PM
Post: #1
 ailoher Junior Member Posts: 4 Joined: Oct 2019
How to evaluate a function in a given point
Hello everyone,

I have just acquired my HP Prime, and this weekend I decided to spend some time learning how to implement some basic numeric methods on it.

While doing so with Regula Falsi, despite my code is apparently correct, I am continuously being given the message 'Incorrect argument type' when running it on my device. You can find it attached below:

EXPORT REGULA_FALSI()
BEGIN
LOCAL n,a,b,xnew,tol,N,f;

N := 100;
tol := .001;

IF INPUT(
{{f,[8]},{a,[0]},{b,[0]},{tol,[0]},{N,[0,1]}},
"Regula falsi's method",
{"f(X)=", "Left guess=", "Right guess=", "Tolerance=", "Max iter.="},
{
"Enter the function surrounded by single quotes",
"Enter the initial left guess",
"Enter the initial right guess",
"Enter the tolerance",
"Enter the maximum number of iterations"
},
{f,a,b,tol,N}
) THEN

F0 := expr(f);
L1 := {};
L1(1) := a;
FOR n from 2 to N+1 DO
xnew := a - F0(a)*(b-a)/(F0(b)-F0(a));
IF F0(a)*F0(xnew) < 0
THEN b := xnew;
ELSE a := xnew;
END;
L1(n) := xnew;
IF F0(a) < tol
THEN BREAK;
END;
END;
editlist(L1);

END;

END;

Do you have any clue about why isn't it correct?

Thank you so much in a advance, and may you have a nice day.

With kind regards,
Aitor
 « Next Oldest | Next Newest »

 Messages In This Thread How to evaluate a function in a given point - ailoher - 10-05-2019 02:54 PM RE: How to evaluate a function in a given point - Tyann - 10-06-2019, 06:06 AM

User(s) browsing this thread: 1 Guest(s)