Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
fezro: tolerance??

Subject: fezro: tolerance??

From: Hermano Cappa

Date: 3 Jul, 2011 10:46:10

Message: 1 of 8

Hi,

I'm using the fzero command for calculating the zero of a non-linear problem. With the command "TolX" I set the tolerance on the x-value. My question is: Is there a way to set the tolerance on the zero-value instead on x? Because when your function is really flat around zero, the tolerance on x does not ensure that this value is short to the zero of the function.

Kind regards,

Steven

Subject: fezro: tolerance??

From: Matt J

Date: 3 Jul, 2011 12:15:10

Message: 2 of 8

"Hermano Cappa" wrote in message <iuph9i$3cv$1@newscl01ah.mathworks.com>...
> Hi,
>
> I'm using the fzero command for calculating the zero of a non-linear problem. With the command "TolX" I set the tolerance on the x-value. My question is: Is there a way to set the tolerance on the zero-value instead on x? Because when your function is really flat around zero, the tolerance on x does not ensure that this value is short to the zero of the function.
===============

I think you're looking for TolFun.

Subject: fezro: tolerance??

From: Hermano Cappa

Date: 4 Jul, 2011 07:26:09

Message: 3 of 8

"Matt J" wrote in message <iupmgd$fat$1@newscl01ah.mathworks.com>...
> "Hermano Cappa" wrote in message <iuph9i$3cv$1@newscl01ah.mathworks.com>...
> > Hi,
> >
> > I'm using the fzero command for calculating the zero of a non-linear problem. With the command "TolX" I set the tolerance on the x-value. My question is: Is there a way to set the tolerance on the zero-value instead on x? Because when your function is really flat around zero, the tolerance on x does not ensure that this value is short to the zero of the function.
> ===============
>
> I think you're looking for TolFun.

Hi Matt,

There's a table listing the five options that FZERO uses from the options
structure: Display, FunValCheck, OutputFcn, PlotFcns, and TolX. TolFun is
not listed in that table.

Subject: fezro: tolerance??

From: Torsten

Date: 4 Jul, 2011 08:08:28

Message: 4 of 8

On 4 Jul., 09:26, "Hermano Cappa" <cappaste...@gmail.com> wrote:
> "Matt J" wrote in message <iupmgd$fa...@newscl01ah.mathworks.com>...
> > "Hermano Cappa" wrote in message <iuph9i$3c...@newscl01ah.mathworks.com>...
> > > Hi,
>
> > > I'm using the fzero command for calculating the zero of a non-linear problem. With the command "TolX" I set the tolerance on the x-value. My question is: Is there a way to set the tolerance on the zero-value instead on x? Because when your function is really flat around zero, the tolerance on x does not ensure that this value is short to the zero of the function.
> > ===============
>
> > I think you're looking for TolFun.
>
> Hi Matt,
>
> There's a table listing the five options that FZERO uses from the options
> structure:  Display, FunValCheck, OutputFcn, PlotFcns, and TolX.  TolFun is
> not listed in that table.


fzero uses bisection - thus choosing a smaller value for TolX will
automatically
decrease |f(x)|.

Best wishes
Torsten.

Subject: fezro: tolerance??

From: Torsten

Date: 4 Jul, 2011 09:25:09

Message: 5 of 8

On 4 Jul., 10:08, Torsten <Torsten.Hen...@umsicht.fraunhofer.de>
wrote:
> On 4 Jul., 09:26, "Hermano Cappa" <cappaste...@gmail.com> wrote:
>
> > "Matt J" wrote in message <iupmgd$fa...@newscl01ah.mathworks.com>...
> > > "Hermano Cappa" wrote in message <iuph9i$3c...@newscl01ah.mathworks.com>...
> > > > Hi,
>
> > > > I'm using the fzero command for calculating the zero of a non-linear problem. With the command "TolX" I set the tolerance on the x-value. My question is: Is there a way to set the tolerance on the zero-value instead on x? Because when your function is really flat around zero, the tolerance on x does not ensure that this value is short to the zero of the function.
> > > ===============
>
> > > I think you're looking for TolFun.
>
> > Hi Matt,
>
> > There's a table listing the five options that FZERO uses from the options
> > structure:  Display, FunValCheck, OutputFcn, PlotFcns, and TolX.  TolFun is
> > not listed in that table.
>
> fzero uses bisection - thus choosing a smaller value for TolX will
> automatically
> decrease |f(x)|.
>
> Best wishes
> Torsten.


... and - assuming that your function is continuous -
you can be sure that there really _is_ a zero
in the TolX-neighborhood of the solution found by fzero.

Best wishes
Torsten.

Subject: fezro: tolerance??

From: Hermano Cappa

Date: 4 Jul, 2011 10:18:07

Message: 6 of 8

Torsten <Torsten.Hennig@umsicht.fraunhofer.de> wrote in message <3bb79a57-8648-4e0e-84e5-8f773ce4c402@29g2000yqb.googlegroups.com>...
> On 4 Jul., 10:08, Torsten <Torsten.Hen...@umsicht.fraunhofer.de>
> wrote:
> > On 4 Jul., 09:26, "Hermano Cappa" <cappaste...@gmail.com> wrote:
> >
> > > "Matt J" wrote in message <iupmgd$fa...@newscl01ah.mathworks.com>...
> > > > "Hermano Cappa" wrote in message <iuph9i$3c...@newscl01ah.mathworks.com>...
> > > > > Hi,
> >
> > > > > I'm using the fzero command for calculating the zero of a non-linear problem. With the command "TolX" I set the tolerance on the x-value. My question is: Is there a way to set the tolerance on the zero-value instead on x? Because when your function is really flat around zero, the tolerance on x does not ensure that this value is short to the zero of the function.
> > > > ===============
> >
> > > > I think you're looking for TolFun.
> >
> > > Hi Matt,
> >
> > > There's a table listing the five options that FZERO uses from the options
> > > structure:  Display, FunValCheck, OutputFcn, PlotFcns, and TolX.  TolFun is
> > > not listed in that table.
> >
> > fzero uses bisection - thus choosing a smaller value for TolX will
> > automatically
> > decrease |f(x)|.
> >
> > Best wishes
> > Torsten.
>
>
> ... and - assuming that your function is continuous -
> you can be sure that there really _is_ a zero
> in the TolX-neighborhood of the solution found by fzero.
>
> Best wishes
> Torsten.

Torsten thanks for the input. But regarding your answer, setting a value to TolX , even it is very small, don't say anything on the accuracy of your zero. This totally depends on the steepness of the function. So if in one case, the function is steeper, the accuracy of the zero will be different (worse). Therefore I need to set the tolerance on the zero value.

Subject: fezro: tolerance??

From: Torsten

Date: 4 Jul, 2011 10:28:38

Message: 7 of 8

On 4 Jul., 12:18, "Hermano Cappa" <cappaste...@gmail.com> wrote:
> Torsten <Torsten.Hen...@umsicht.fraunhofer.de> wrote in message <3bb79a57-8648-4e0e-84e5-8f773ce4c...@29g2000yqb.googlegroups.com>...
> > On 4 Jul., 10:08, Torsten <Torsten.Hen...@umsicht.fraunhofer.de>
> > wrote:
> > > On 4 Jul., 09:26, "Hermano Cappa" <cappaste...@gmail.com> wrote:
>
> > > > "Matt J" wrote in message <iupmgd$fa...@newscl01ah.mathworks.com>...
> > > > > "Hermano Cappa" wrote in message <iuph9i$3c...@newscl01ah.mathworks.com>...
> > > > > > Hi,
>
> > > > > > I'm using the fzero command for calculating the zero of a non-linear problem. With the command "TolX" I set the tolerance on the x-value. My question is: Is there a way to set the tolerance on the zero-value instead on x? Because when your function is really flat around zero, the tolerance on x does not ensure that this value is short to the zero of the function.
> > > > > ===============
>
> > > > > I think you're looking for TolFun.
>
> > > > Hi Matt,
>
> > > > There's a table listing the five options that FZERO uses from the options
> > > > structure:  Display, FunValCheck, OutputFcn, PlotFcns, and TolX.  TolFun is
> > > > not listed in that table.
>
> > > fzero uses bisection - thus choosing a smaller value for TolX will
> > > automatically
> > > decrease |f(x)|.
>
> > > Best wishes
> > > Torsten.
>
> > ... and - assuming that your function is continuous -
> > you can be sure that there really _is_ a zero
> > in the TolX-neighborhood of the solution found by fzero.
>
> > Best wishes
> > Torsten.
>
> Torsten thanks for the input. But regarding your answer, setting a value to TolX , even it is very small, don't say anything on the accuracy of your zero. This totally depends on the steepness of the function. So if in one case, the function is steeper, the accuracy of the zero will be different (worse). Therefore I need to set the tolerance on the zero value.- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

Usually it suffices to know that a zero is located within [x-TolX;x
+TolX] where x is the solution provided by fzero -
and this is guaranteed by the bisection method.
A way to improve accuracy is to evaluate f at the suggested solution x
and - if |f(x)| is too big - choose
a smaller value for TolX.
Or you use MATLAB's fsolve which has the option to choose the error
tolerance TolFun on the function value .

Best wishes
Torsten.

Subject: fezro: tolerance??

From: Matt J

Date: 4 Jul, 2011 11:34:09

Message: 8 of 8

"Hermano Cappa" wrote in message <ius40v$j4n$1@newscl01ah.mathworks.com>...
>
> Torsten thanks for the input. But regarding your answer, setting a value to TolX , even it is very small, don't say anything on the accuracy of your zero. This totally depends on the steepness of the function. So if in one case, the function is steeper, the accuracy of the zero will be different (worse). Therefore I need to set the tolerance on the zero value.
================

No, that's unlikely.

Suppose FZERO gives you a solution x* that you do like and abs(f(x*)) has some very small value, epsilon, that you like as well.

But you could have found that exact same x* by applying FZERO to the steeper function g(x) = 10*f(x). You would have obtained a "worse" value of
10*epsilson when the algorithm stops. Does this mean you like the solution x* less?

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us