# [Scilab-users] How to fix the round off error of "intg" Classic List Threaded 3 messages Open this post in threaded view
|

## [Scilab-users] How to fix the round off error of "intg" My objective is to find a variable x which set the derivative of the function f (x) with respect to x to zero. The function f (x) is the integration of g(x, z) from a to b with respect to z., that is, f (x) = ∫g(x, z) dz over  (a, b). The function g (x, z) is a well-behaved function that has one peak with respect to z. I used "intg" to calculate ∫g(x, z)dz. I used  "numuderivatibe" to calculate f '(x) I used   "fsoleve" to find x where f '(x) = 0. When executed it, it stopped with the following warning. "fsolve: numderivative: Error while evaluating the function: "intg: Error: Round-off error detected, the requested tolerance (or default) cannot be achieved. Try using bigger tolerances." I would like to ask two questions. 1. Can I investigate the cause of rounding error by adding "disp" line in macros "numderivative" or "intg" in order to monitor the variables? 2. Where can I modify to increase the tolerances of "intg"? Thank you. -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html_______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users Le 18/11/2019 à 06:44, fujimoto2005 a écrit : > My objective is to find a variable x which set the derivative of the function > f (x) with respect to x to zero. > The function f (x) is the integration of g(x, z) from a to b with respect to > z., that is, > f (x) = ∫g(x, z) dz over  (a, b). > The function g (x, z) is a well-behaved function that has one peak with > respect to z. > I used "intg" to calculate ∫g(x, z)dz. > I used  "numuderivatibe" to calculate f '(x) > I used   "fsoleve" to find x where f '(x) = 0. > > When executed it, it stopped with the following warning. > > "fsolve: numderivative: Error while evaluating the function: "intg: Error: > Round-off error detected, the requested tolerance (or default) cannot be > achieved. Try using bigger tolerances." > > I would like to ask two questions. > 1. Can I investigate the cause of rounding error by adding "disp" line in > macros "numderivative" Yes, why not. > or "intg" No, since it's a hard-coded function, not a macro > in order to monitor the variables? > 2. Where can I modify to increase the tolerances of "intg"? There are named "ea" and "er" in the help page: https://help.scilab.org/docs/6.0.2/en_US/intg.html_______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users In reply to this post by fujimoto2005 Dear Samuel Thank you for your reply. Inside the function f(x),I added "disp" to display the value of x and error flag "ierr" after "intg" line . The "fsolve" and "numderivative" called f many times for many x around the correct solution x, and the values of x and ierr were displayed for many calls. I couldn't find regularity because ierr = 2 occurs for x very close to x with ierr = 0. I couldn't find the cause of the rounding error. I couldn't proceed further since the inside of "intg" could not be monitored. However, when "ierr" is output, it turns out that the code did not stop even if the rounding error occurs. As a result, fsolve could find the correct x. I adopted this ad-hoc solution. Since the inside of g (x, z) have not been improved so that rounding errors do not occur reliably, similar problems may occur in the future, but I decided to satisfy this ad-hoc solution. Best regards, Masahiro Fujimoto -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html_______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users