SlideShare a Scribd company logo
1 of 19
Download to read offline
Fill out the missing entries in the following table with your answers.
Solution
Optimization Toolbox
fzero
Zero of a continuous function of one variable
Syntax
x = fzero(fun,x0)
x = fzero(fun,x0,options)
x = fzero(fun,x0,options,P1,P2,...)
[x,fval] = fzero(...)
[x,fval,exitflag] = fzero(...)
[x,fval,exitflag,output] = fzero(...)
Description
x = fzero(fun,x0) tries to find a zero of fun near x0, if x0 is a scalar. The value x returned by
fzero is near a point where fun changes sign, or NaN if the search fails. In this case, the search
terminates when the search interval is expanded until an Inf, NaN, or complex value is found.
If x0 is a vector of length two, fzero assumes x0 is an interval where the sign of fun(x0(1))
differs from the sign of fun(x0(2)). An error occurs if this is not true. Calling fzero with such an
interval guarantees fzero returns a value near a point where fun changes sign.
Note Calling fzero with an interval (x0 with two elements) is often faster than calling it with a
scalar x0.
x = fzero(fun,x0,options) minimizes with the optimization parameters specified in the structure
options.
x = fzero(fun,x0,options,P1,P2,...) provides for additional arguments, P1, P2, etc., which are
passed to the objective function, fun. Use options = [] as a placeholder if no options are set.
[x,fval] = fzero(...) returns the value of the objective function fun at the solution x.
[x,fval,exitflag] = fzero(...) returns a value exitflag that describes the exit condition.
[x,fval,exitflag,output] = fzero(...) returns a structure output that contains information about the
optimization.
Note For the purposes of this command, zeros are considered to be points where the function
actually crosses, not just touches, the x-axis.
Arguments
Input Arguments. Table 4-1, Input Arguments, contains general descriptions of arguments
passed in to fzero. This section provides function-specific details for fun and options:
fun
The function whose zero is to be computed. fun is a function that accepts a vector x and returns a
scalar f, the objective function evaluated at x. The function fun can be specified as a function
handle.
x = fzero(@myfun,x0)
where myfun is a MATLAB function such as
function f = myfun(x)
f = ... % Compute function value at x
fun can also be an inline object.
x = fzero(inline('sin(x*x)'),x0);
options
Optimization parameter options. You can set or change the values of these parameters using the
optimset function. fzero uses these options structure fields:
Display
Level of display. 'off' displays no output; 'iter' displays output at each iteration; 'final'
displays just the final output; 'notify' (default) dislays output only if the function does not
converge.
TolX
Termination tolerance on x.
Output Arguments. Table 4-2, Output Arguments, contains general descriptions of arguments
returned by fzero. This section provides function-specific details for exitflag and output:
exitflag
Describes the exit condition:
> 0
Indicates that fzero found a zero x.
< 0
No interval was found with a sign change, or a NaN or Inf function value was encountered
during the search for an interval containing a sign change, or a complex function value was
encountered during the search for an interval containing a sign change.
output
Structure containing information about the optimization. The fields of the structure are:
iterations
Number of iterations taken (for fzero, this is the same as the number of function evaluations).
funcCount
Number of function evaluations.
algorithm
Algorithm used.
Examples
Calculate by finding the zero of the sine function near 3.
x = fzero(@sin,3)
x =
3.1416
To find the zero of cosine between 1 and 2,
x = fzero(@cos,[1 2])
x =
1.5708
Note that cos(1) and cos(2) differ in sign.
To find a zero of the function
write an M-file called f.m.
function y = f(x)
y = x.^3-2*x-5;
To find the zero near 2
z = fzero(@f,2)
z =
2.0946
Since this function is a polynomial, the statement roots([1 0 -2 -5]) finds the same real zero, and
a complex conjugate pair of zeros.
2.0946
-1.0473 + 1.1359i
-1.0473 - 1.1359i
Optimization Toolbox
fzero
Zero of a continuous function of one variable
Syntax
x = fzero(fun,x0)
x = fzero(fun,x0,options)
x = fzero(fun,x0,options,P1,P2,...)
[x,fval] = fzero(...)
[x,fval,exitflag] = fzero(...)
[x,fval,exitflag,output] = fzero(...)
Description
x = fzero(fun,x0) tries to find a zero of fun near x0, if x0 is a scalar. The value x returned by
fzero is near a point where fun changes sign, or NaN if the search fails. In this case, the search
terminates when the search interval is expanded until an Inf, NaN, or complex value is found.
If x0 is a vector of length two, fzero assumes x0 is an interval where the sign of fun(x0(1))
differs from the sign of fun(x0(2)). An error occurs if this is not true. Calling fzero with such an
interval guarantees fzero returns a value near a point where fun changes sign.
Note Calling fzero with an interval (x0 with two elements) is often faster than calling it with a
scalar x0.
x = fzero(fun,x0,options) minimizes with the optimization parameters specified in the structure
options.
x = fzero(fun,x0,options,P1,P2,...) provides for additional arguments, P1, P2, etc., which are
passed to the objective function, fun. Use options = [] as a placeholder if no options are set.
[x,fval] = fzero(...) returns the value of the objective function fun at the solution x.
[x,fval,exitflag] = fzero(...) returns a value exitflag that describes the exit condition.
[x,fval,exitflag,output] = fzero(...) returns a structure output that contains information about the
optimization.
Note For the purposes of this command, zeros are considered to be points where the function
actually crosses, not just touches, the x-axis.
Arguments
Input Arguments. Table 4-1, Input Arguments, contains general descriptions of arguments
passed in to fzero. This section provides function-specific details for fun and options:
fun
The function whose zero is to be computed. fun is a function that accepts a vector x and returns a
scalar f, the objective function evaluated at x. The function fun can be specified as a function
handle.
x = fzero(@myfun,x0)
where myfun is a MATLAB function such as
function f = myfun(x)
f = ... % Compute function value at x
fun can also be an inline object.
x = fzero(inline('sin(x*x)'),x0);
options
Optimization parameter options. You can set or change the values of these parameters using the
optimset function. fzero uses these options structure fields:
Display
Level of display. 'off' displays no output; 'iter' displays output at each iteration; 'final'
displays just the final output; 'notify' (default) dislays output only if the function does not
converge.
TolX
Termination tolerance on x.
Output Arguments. Table 4-2, Output Arguments, contains general descriptions of arguments
returned by fzero. This section provides function-specific details for exitflag and output:
exitflag
Describes the exit condition:
> 0
Indicates that fzero found a zero x.
< 0
No interval was found with a sign change, or a NaN or Inf function value was encountered
during the search for an interval containing a sign change, or a complex function value was
encountered during the search for an interval containing a sign change.
output
Structure containing information about the optimization. The fields of the structure are:
iterations
Number of iterations taken (for fzero, this is the same as the number of function evaluations).
funcCount
Number of function evaluations.
algorithm
Algorithm used.
Examples
Calculate by finding the zero of the sine function near 3.
x = fzero(@sin,3)
x =
3.1416
To find the zero of cosine between 1 and 2,
x = fzero(@cos,[1 2])
x =
1.5708
Note that cos(1) and cos(2) differ in sign.
To find a zero of the function
write an M-file called f.m.
function y = f(x)
y = x.^3-2*x-5;
To find the zero near 2
z = fzero(@f,2)
z =
2.0946
Since this function is a polynomial, the statement roots([1 0 -2 -5]) finds the same real zero, and
a complex conjugate pair of zeros.
2.0946
-1.0473 + 1.1359i
-1.0473 - 1.1359i
Optimization Toolbox
fzero
Zero of a continuous function of one variable
Syntax
x = fzero(fun,x0)
x = fzero(fun,x0,options)
x = fzero(fun,x0,options,P1,P2,...)
[x,fval] = fzero(...)
[x,fval,exitflag] = fzero(...)
[x,fval,exitflag,output] = fzero(...)
Description
x = fzero(fun,x0) tries to find a zero of fun near x0, if x0 is a scalar. The value x returned by
fzero is near a point where fun changes sign, or NaN if the search fails. In this case, the search
terminates when the search interval is expanded until an Inf, NaN, or complex value is found.
If x0 is a vector of length two, fzero assumes x0 is an interval where the sign of fun(x0(1))
differs from the sign of fun(x0(2)). An error occurs if this is not true. Calling fzero with such an
interval guarantees fzero returns a value near a point where fun changes sign.
Note Calling fzero with an interval (x0 with two elements) is often faster than calling it with a
scalar x0.
x = fzero(fun,x0,options) minimizes with the optimization parameters specified in the structure
options.
x = fzero(fun,x0,options,P1,P2,...) provides for additional arguments, P1, P2, etc., which are
passed to the objective function, fun. Use options = [] as a placeholder if no options are set.
[x,fval] = fzero(...) returns the value of the objective function fun at the solution x.
[x,fval,exitflag] = fzero(...) returns a value exitflag that describes the exit condition.
[x,fval,exitflag,output] = fzero(...) returns a structure output that contains information about the
optimization.
Note For the purposes of this command, zeros are considered to be points where the function
actually crosses, not just touches, the x-axis.
Arguments
Input Arguments. Table 4-1, Input Arguments, contains general descriptions of arguments
passed in to fzero. This section provides function-specific details for fun and options:
fun
The function whose zero is to be computed. fun is a function that accepts a vector x and returns a
scalar f, the objective function evaluated at x. The function fun can be specified as a function
handle.
x = fzero(@myfun,x0)
where myfun is a MATLAB function such as
function f = myfun(x)
f = ... % Compute function value at x
fun can also be an inline object.
x = fzero(inline('sin(x*x)'),x0);
options
Optimization parameter options. You can set or change the values of these parameters using the
optimset function. fzero uses these options structure fields:
Display
Level of display. 'off' displays no output; 'iter' displays output at each iteration; 'final'
displays just the final output; 'notify' (default) dislays output only if the function does not
converge.
TolX
Termination tolerance on x.
Output Arguments. Table 4-2, Output Arguments, contains general descriptions of arguments
returned by fzero. This section provides function-specific details for exitflag and output:
exitflag
Describes the exit condition:
> 0
Indicates that fzero found a zero x.
< 0
No interval was found with a sign change, or a NaN or Inf function value was encountered
during the search for an interval containing a sign change, or a complex function value was
encountered during the search for an interval containing a sign change.
output
Structure containing information about the optimization. The fields of the structure are:
iterations
Number of iterations taken (for fzero, this is the same as the number of function evaluations).
funcCount
Number of function evaluations.
algorithm
Algorithm used.
Examples
Calculate by finding the zero of the sine function near 3.
x = fzero(@sin,3)
x =
3.1416
To find the zero of cosine between 1 and 2,
x = fzero(@cos,[1 2])
x =
1.5708
Note that cos(1) and cos(2) differ in sign.
To find a zero of the function
write an M-file called f.m.
function y = f(x)
y = x.^3-2*x-5;
To find the zero near 2
z = fzero(@f,2)
z =
2.0946
Since this function is a polynomial, the statement roots([1 0 -2 -5]) finds the same real zero, and
a complex conjugate pair of zeros.
2.0946
-1.0473 + 1.1359i
-1.0473 - 1.1359i
Optimization Toolbox
fzero
Zero of a continuous function of one variable
Syntax
x = fzero(fun,x0)
x = fzero(fun,x0,options)
x = fzero(fun,x0,options,P1,P2,...)
[x,fval] = fzero(...)
[x,fval,exitflag] = fzero(...)
[x,fval,exitflag,output] = fzero(...)
Description
x = fzero(fun,x0) tries to find a zero of fun near x0, if x0 is a scalar. The value x returned by
fzero is near a point where fun changes sign, or NaN if the search fails. In this case, the search
terminates when the search interval is expanded until an Inf, NaN, or complex value is found.
If x0 is a vector of length two, fzero assumes x0 is an interval where the sign of fun(x0(1))
differs from the sign of fun(x0(2)). An error occurs if this is not true. Calling fzero with such an
interval guarantees fzero returns a value near a point where fun changes sign.
Note Calling fzero with an interval (x0 with two elements) is often faster than calling it with a
scalar x0.
x = fzero(fun,x0,options) minimizes with the optimization parameters specified in the structure
options.
x = fzero(fun,x0,options,P1,P2,...) provides for additional arguments, P1, P2, etc., which are
passed to the objective function, fun. Use options = [] as a placeholder if no options are set.
[x,fval] = fzero(...) returns the value of the objective function fun at the solution x.
[x,fval,exitflag] = fzero(...) returns a value exitflag that describes the exit condition.
[x,fval,exitflag,output] = fzero(...) returns a structure output that contains information about the
optimization.
Note For the purposes of this command, zeros are considered to be points where the function
actually crosses, not just touches, the x-axis.
Arguments
Input Arguments. Table 4-1, Input Arguments, contains general descriptions of arguments
passed in to fzero. This section provides function-specific details for fun and options:
fun
The function whose zero is to be computed. fun is a function that accepts a vector x and returns a
scalar f, the objective function evaluated at x. The function fun can be specified as a function
handle.
x = fzero(@myfun,x0)
where myfun is a MATLAB function such as
function f = myfun(x)
f = ... % Compute function value at x
fun can also be an inline object.
x = fzero(inline('sin(x*x)'),x0);
options
Optimization parameter options. You can set or change the values of these parameters using the
optimset function. fzero uses these options structure fields:
Display
Level of display. 'off' displays no output; 'iter' displays output at each iteration; 'final'
displays just the final output; 'notify' (default) dislays output only if the function does not
converge.
TolX
Termination tolerance on x.
Output Arguments. Table 4-2, Output Arguments, contains general descriptions of arguments
returned by fzero. This section provides function-specific details for exitflag and output:
exitflag
Describes the exit condition:
> 0
Indicates that fzero found a zero x.
< 0
No interval was found with a sign change, or a NaN or Inf function value was encountered
during the search for an interval containing a sign change, or a complex function value was
encountered during the search for an interval containing a sign change.
output
Structure containing information about the optimization. The fields of the structure are:
iterations
Number of iterations taken (for fzero, this is the same as the number of function evaluations).
funcCount
Number of function evaluations.
algorithm
Algorithm used.
Examples
Calculate by finding the zero of the sine function near 3.
x = fzero(@sin,3)
x =
3.1416
To find the zero of cosine between 1 and 2,
x = fzero(@cos,[1 2])
x =
1.5708
Note that cos(1) and cos(2) differ in sign.
To find a zero of the function
write an M-file called f.m.
function y = f(x)
y = x.^3-2*x-5;
To find the zero near 2
z = fzero(@f,2)
z =
2.0946
Since this function is a polynomial, the statement roots([1 0 -2 -5]) finds the same real zero, and
a complex conjugate pair of zeros.
2.0946
-1.0473 + 1.1359i
-1.0473 - 1.1359i
Optimization Toolbox
fzero
Zero of a continuous function of one variable
Syntax
x = fzero(fun,x0)
x = fzero(fun,x0,options)
x = fzero(fun,x0,options,P1,P2,...)
[x,fval] = fzero(...)
[x,fval,exitflag] = fzero(...)
[x,fval,exitflag,output] = fzero(...)
Description
x = fzero(fun,x0) tries to find a zero of fun near x0, if x0 is a scalar. The value x returned by
fzero is near a point where fun changes sign, or NaN if the search fails. In this case, the search
terminates when the search interval is expanded until an Inf, NaN, or complex value is found.
If x0 is a vector of length two, fzero assumes x0 is an interval where the sign of fun(x0(1))
differs from the sign of fun(x0(2)). An error occurs if this is not true. Calling fzero with such an
interval guarantees fzero returns a value near a point where fun changes sign.
Note Calling fzero with an interval (x0 with two elements) is often faster than calling it with a
scalar x0.
x = fzero(fun,x0,options) minimizes with the optimization parameters specified in the structure
options.
x = fzero(fun,x0,options,P1,P2,...) provides for additional arguments, P1, P2, etc., which are
passed to the objective function, fun. Use options = [] as a placeholder if no options are set.
[x,fval] = fzero(...) returns the value of the objective function fun at the solution x.
[x,fval,exitflag] = fzero(...) returns a value exitflag that describes the exit condition.
[x,fval,exitflag,output] = fzero(...) returns a structure output that contains information about the
optimization.
Note For the purposes of this command, zeros are considered to be points where the function
actually crosses, not just touches, the x-axis.
Arguments
Input Arguments. Table 4-1, Input Arguments, contains general descriptions of arguments
passed in to fzero. This section provides function-specific details for fun and options:
fun
The function whose zero is to be computed. fun is a function that accepts a vector x and returns a
scalar f, the objective function evaluated at x. The function fun can be specified as a function
handle.
x = fzero(@myfun,x0)
where myfun is a MATLAB function such as
function f = myfun(x)
f = ... % Compute function value at x
fun can also be an inline object.
x = fzero(inline('sin(x*x)'),x0);
options
Optimization parameter options. You can set or change the values of these parameters using the
optimset function. fzero uses these options structure fields:
Display
Level of display. 'off' displays no output; 'iter' displays output at each iteration; 'final'
displays just the final output; 'notify' (default) dislays output only if the function does not
converge.
TolX
Termination tolerance on x.
Output Arguments. Table 4-2, Output Arguments, contains general descriptions of arguments
returned by fzero. This section provides function-specific details for exitflag and output:
exitflag
Describes the exit condition:
> 0
Indicates that fzero found a zero x.
< 0
No interval was found with a sign change, or a NaN or Inf function value was encountered
during the search for an interval containing a sign change, or a complex function value was
encountered during the search for an interval containing a sign change.
output
Structure containing information about the optimization. The fields of the structure are:
iterations
Number of iterations taken (for fzero, this is the same as the number of function evaluations).
funcCount
Number of function evaluations.
algorithm
Algorithm used.
Examples
Calculate by finding the zero of the sine function near 3.
x = fzero(@sin,3)
x =
3.1416
To find the zero of cosine between 1 and 2,
x = fzero(@cos,[1 2])
x =
1.5708
Note that cos(1) and cos(2) differ in sign.
To find a zero of the function
write an M-file called f.m.
function y = f(x)
y = x.^3-2*x-5;
To find the zero near 2
z = fzero(@f,2)
z =
2.0946
Since this function is a polynomial, the statement roots([1 0 -2 -5]) finds the same real zero, and
a complex conjugate pair of zeros.
2.0946
-1.0473 + 1.1359i
-1.0473 - 1.1359i
Optimization Toolbox
fzero
Zero of a continuous function of one variable
Syntax
x = fzero(fun,x0)
x = fzero(fun,x0,options)
x = fzero(fun,x0,options,P1,P2,...)
[x,fval] = fzero(...)
[x,fval,exitflag] = fzero(...)
[x,fval,exitflag,output] = fzero(...)
Description
x = fzero(fun,x0) tries to find a zero of fun near x0, if x0 is a scalar. The value x returned by
fzero is near a point where fun changes sign, or NaN if the search fails. In this case, the search
terminates when the search interval is expanded until an Inf, NaN, or complex value is found.
If x0 is a vector of length two, fzero assumes x0 is an interval where the sign of fun(x0(1))
differs from the sign of fun(x0(2)). An error occurs if this is not true. Calling fzero with such an
interval guarantees fzero returns a value near a point where fun changes sign.
Note Calling fzero with an interval (x0 with two elements) is often faster than calling it with a
scalar x0.
x = fzero(fun,x0,options) minimizes with the optimization parameters specified in the structure
options.
x = fzero(fun,x0,options,P1,P2,...) provides for additional arguments, P1, P2, etc., which are
passed to the objective function, fun. Use options = [] as a placeholder if no options are set.
[x,fval] = fzero(...) returns the value of the objective function fun at the solution x.
[x,fval,exitflag] = fzero(...) returns a value exitflag that describes the exit condition.
[x,fval,exitflag,output] = fzero(...) returns a structure output that contains information about the
optimization.
Note For the purposes of this command, zeros are considered to be points where the function
actually crosses, not just touches, the x-axis.
Arguments
Input Arguments. Table 4-1, Input Arguments, contains general descriptions of arguments
passed in to fzero. This section provides function-specific details for fun and options:
fun
The function whose zero is to be computed. fun is a function that accepts a vector x and returns a
scalar f, the objective function evaluated at x. The function fun can be specified as a function
handle.
x = fzero(@myfun,x0)
where myfun is a MATLAB function such as
function f = myfun(x)
f = ... % Compute function value at x
fun can also be an inline object.
x = fzero(inline('sin(x*x)'),x0);
options
Optimization parameter options. You can set or change the values of these parameters using the
optimset function. fzero uses these options structure fields:
Display
Level of display. 'off' displays no output; 'iter' displays output at each iteration; 'final'
displays just the final output; 'notify' (default) dislays output only if the function does not
converge.
TolX
Termination tolerance on x.
Output Arguments. Table 4-2, Output Arguments, contains general descriptions of arguments
returned by fzero. This section provides function-specific details for exitflag and output:
exitflag
Describes the exit condition:
> 0
Indicates that fzero found a zero x.
< 0
No interval was found with a sign change, or a NaN or Inf function value was encountered
during the search for an interval containing a sign change, or a complex function value was
encountered during the search for an interval containing a sign change.
output
Structure containing information about the optimization. The fields of the structure are:
iterations
Number of iterations taken (for fzero, this is the same as the number of function evaluations).
funcCount
Number of function evaluations.
algorithm
Algorithm used.
Examples
Calculate by finding the zero of the sine function near 3.
x = fzero(@sin,3)
x =
3.1416
To find the zero of cosine between 1 and 2,
x = fzero(@cos,[1 2])
x =
1.5708
Note that cos(1) and cos(2) differ in sign.
To find a zero of the function
write an M-file called f.m.
function y = f(x)
y = x.^3-2*x-5;
To find the zero near 2
z = fzero(@f,2)
z =
2.0946
Since this function is a polynomial, the statement roots([1 0 -2 -5]) finds the same real zero, and
a complex conjugate pair of zeros.
2.0946
-1.0473 + 1.1359i
-1.0473 - 1.1359i
Optimization Toolbox
fzero
Zero of a continuous function of one variable
Syntax
x = fzero(fun,x0)
x = fzero(fun,x0,options)
x = fzero(fun,x0,options,P1,P2,...)
[x,fval] = fzero(...)
[x,fval,exitflag] = fzero(...)
[x,fval,exitflag,output] = fzero(...)
Description
x = fzero(fun,x0) tries to find a zero of fun near x0, if x0 is a scalar. The value x returned by
fzero is near a point where fun changes sign, or NaN if the search fails. In this case, the search
terminates when the search interval is expanded until an Inf, NaN, or complex value is found.
If x0 is a vector of length two, fzero assumes x0 is an interval where the sign of fun(x0(1))
differs from the sign of fun(x0(2)). An error occurs if this is not true. Calling fzero with such an
interval guarantees fzero returns a value near a point where fun changes sign.
Note Calling fzero with an interval (x0 with two elements) is often faster than calling it with a
scalar x0.
x = fzero(fun,x0,options) minimizes with the optimization parameters specified in the structure
options.
x = fzero(fun,x0,options,P1,P2,...) provides for additional arguments, P1, P2, etc., which are
passed to the objective function, fun. Use options = [] as a placeholder if no options are set.
[x,fval] = fzero(...) returns the value of the objective function fun at the solution x.
[x,fval,exitflag] = fzero(...) returns a value exitflag that describes the exit condition.
[x,fval,exitflag,output] = fzero(...) returns a structure output that contains information about the
optimization.
Note For the purposes of this command, zeros are considered to be points where the function
actually crosses, not just touches, the x-axis.
Arguments
Input Arguments. Table 4-1, Input Arguments, contains general descriptions of arguments
passed in to fzero. This section provides function-specific details for fun and options:
fun
The function whose zero is to be computed. fun is a function that accepts a vector x and returns a
scalar f, the objective function evaluated at x. The function fun can be specified as a function
handle.
x = fzero(@myfun,x0)
where myfun is a MATLAB function such as
function f = myfun(x)
f = ... % Compute function value at x
fun can also be an inline object.
x = fzero(inline('sin(x*x)'),x0);
options
Optimization parameter options. You can set or change the values of these parameters using the
optimset function. fzero uses these options structure fields:
Display
Level of display. 'off' displays no output; 'iter' displays output at each iteration; 'final'
displays just the final output; 'notify' (default) dislays output only if the function does not
converge.
TolX
Termination tolerance on x.
Output Arguments. Table 4-2, Output Arguments, contains general descriptions of arguments
returned by fzero. This section provides function-specific details for exitflag and output:
exitflag
Describes the exit condition:
> 0
Indicates that fzero found a zero x.
< 0
No interval was found with a sign change, or a NaN or Inf function value was encountered
during the search for an interval containing a sign change, or a complex function value was
encountered during the search for an interval containing a sign change.
output
Structure containing information about the optimization. The fields of the structure are:
iterations
Number of iterations taken (for fzero, this is the same as the number of function evaluations).
funcCount
Number of function evaluations.
algorithm
Algorithm used.
Examples
Calculate by finding the zero of the sine function near 3.
x = fzero(@sin,3)
x =
3.1416
To find the zero of cosine between 1 and 2,
x = fzero(@cos,[1 2])
x =
1.5708
Note that cos(1) and cos(2) differ in sign.
To find a zero of the function
write an M-file called f.m.
function y = f(x)
y = x.^3-2*x-5;
To find the zero near 2
z = fzero(@f,2)
z =
2.0946
Since this function is a polynomial, the statement roots([1 0 -2 -5]) finds the same real zero, and
a complex conjugate pair of zeros.
2.0946
-1.0473 + 1.1359i
-1.0473 - 1.1359i
Optimization Toolbox

More Related Content

Similar to Fill out the missing entries in the following table with your answers.pdf

0.5.derivatives
0.5.derivatives0.5.derivatives
0.5.derivatives
m2699
 
Chapter on Functions and Graphs.ppt
Chapter on Functions and Graphs.pptChapter on Functions and Graphs.ppt
Chapter on Functions and Graphs.ppt
PhongLan30
 
Application of derivatives
Application of derivativesApplication of derivatives
Application of derivatives
indu thakur
 
01. Functions-Theory & Solved Examples Module-4.pdf
01. Functions-Theory & Solved Examples Module-4.pdf01. Functions-Theory & Solved Examples Module-4.pdf
01. Functions-Theory & Solved Examples Module-4.pdf
RajuSingh806014
 
extremevaluesofafunctionapplicationsofderivative-130905112534-.pdf
extremevaluesofafunctionapplicationsofderivative-130905112534-.pdfextremevaluesofafunctionapplicationsofderivative-130905112534-.pdf
extremevaluesofafunctionapplicationsofderivative-130905112534-.pdf
Waqas Mehmood
 
Lesson 2 - Functions and their Graphs - NOTES.ppt
Lesson 2 - Functions and their Graphs - NOTES.pptLesson 2 - Functions and their Graphs - NOTES.ppt
Lesson 2 - Functions and their Graphs - NOTES.ppt
JaysonMagalong
 
Quarter_3_Grade8_L2_Function_Notation.pptx
Quarter_3_Grade8_L2_Function_Notation.pptxQuarter_3_Grade8_L2_Function_Notation.pptx
Quarter_3_Grade8_L2_Function_Notation.pptx
DaniloFrondaJr
 
119 Powerpoint 2.2
119 Powerpoint 2.2119 Powerpoint 2.2
119 Powerpoint 2.2
Jeneva Clark
 

Similar to Fill out the missing entries in the following table with your answers.pdf (20)

Domain-and-Range-of-a-Function
Domain-and-Range-of-a-FunctionDomain-and-Range-of-a-Function
Domain-and-Range-of-a-Function
 
Lesson 1
Lesson 1Lesson 1
Lesson 1
 
Edsc 304 lesson 1
Edsc 304 lesson 1Edsc 304 lesson 1
Edsc 304 lesson 1
 
Paper06
Paper06Paper06
Paper06
 
0.5.derivatives
0.5.derivatives0.5.derivatives
0.5.derivatives
 
Boolean Matching in Logic Synthesis
Boolean Matching in Logic SynthesisBoolean Matching in Logic Synthesis
Boolean Matching in Logic Synthesis
 
237654933 mathematics-t-form-6
237654933 mathematics-t-form-6237654933 mathematics-t-form-6
237654933 mathematics-t-form-6
 
Chapter on Functions and Graphs.ppt
Chapter on Functions and Graphs.pptChapter on Functions and Graphs.ppt
Chapter on Functions and Graphs.ppt
 
Application of derivatives
Application of derivativesApplication of derivatives
Application of derivatives
 
Extreme values of a function & applications of derivative
Extreme values of a function & applications of derivativeExtreme values of a function & applications of derivative
Extreme values of a function & applications of derivative
 
01. Functions-Theory & Solved Examples Module-4.pdf
01. Functions-Theory & Solved Examples Module-4.pdf01. Functions-Theory & Solved Examples Module-4.pdf
01. Functions-Theory & Solved Examples Module-4.pdf
 
extremevaluesofafunctionapplicationsofderivative-130905112534-.pdf
extremevaluesofafunctionapplicationsofderivative-130905112534-.pdfextremevaluesofafunctionapplicationsofderivative-130905112534-.pdf
extremevaluesofafunctionapplicationsofderivative-130905112534-.pdf
 
Bostock and Chandler chapter3 functions
Bostock and Chandler chapter3 functionsBostock and Chandler chapter3 functions
Bostock and Chandler chapter3 functions
 
Fmincon
FminconFmincon
Fmincon
 
On Frechet Derivatives with Application to the Inverse Function Theorem of Or...
On Frechet Derivatives with Application to the Inverse Function Theorem of Or...On Frechet Derivatives with Application to the Inverse Function Theorem of Or...
On Frechet Derivatives with Application to the Inverse Function Theorem of Or...
 
1_AJMS_229_19[Review].pdf
1_AJMS_229_19[Review].pdf1_AJMS_229_19[Review].pdf
1_AJMS_229_19[Review].pdf
 
Lagrange’s interpolation formula
Lagrange’s interpolation formulaLagrange’s interpolation formula
Lagrange’s interpolation formula
 
Lesson 2 - Functions and their Graphs - NOTES.ppt
Lesson 2 - Functions and their Graphs - NOTES.pptLesson 2 - Functions and their Graphs - NOTES.ppt
Lesson 2 - Functions and their Graphs - NOTES.ppt
 
Quarter_3_Grade8_L2_Function_Notation.pptx
Quarter_3_Grade8_L2_Function_Notation.pptxQuarter_3_Grade8_L2_Function_Notation.pptx
Quarter_3_Grade8_L2_Function_Notation.pptx
 
119 Powerpoint 2.2
119 Powerpoint 2.2119 Powerpoint 2.2
119 Powerpoint 2.2
 

More from akashshahu23

Financing current assets What are the current asset financing strate.pdf
 Financing current assets  What are the current asset financing strate.pdf Financing current assets  What are the current asset financing strate.pdf
Financing current assets What are the current asset financing strate.pdf
akashshahu23
 

More from akashshahu23 (9)

Find the particular solution of the differential equation x2y2 - 4 d.pdf
 Find the particular solution of the differential equation x2y2 - 4 d.pdf Find the particular solution of the differential equation x2y2 - 4 d.pdf
Find the particular solution of the differential equation x2y2 - 4 d.pdf
 
Find the equation of the line with the given properties. Express th.pdf
 Find the equation of the line with the given properties. Express th.pdf Find the equation of the line with the given properties. Express th.pdf
Find the equation of the line with the given properties. Express th.pdf
 
Find the content of the A register and indicate the flags state of Z .pdf
 Find the content of the A register and indicate the flags state of Z .pdf Find the content of the A register and indicate the flags state of Z .pdf
Find the content of the A register and indicate the flags state of Z .pdf
 
Find an equation for the hyperbola described. Graph the equation. Cen.pdf
 Find an equation for the hyperbola described. Graph the equation. Cen.pdf Find an equation for the hyperbola described. Graph the equation. Cen.pdf
Find an equation for the hyperbola described. Graph the equation. Cen.pdf
 
Figure P1.11 Waveform for Problems 1.11 and 1.12. 1.7 The waveform .pdf
 Figure P1.11 Waveform  for  Problems 1.11 and 1.12. 1.7 The waveform .pdf Figure P1.11 Waveform  for  Problems 1.11 and 1.12. 1.7 The waveform .pdf
Figure P1.11 Waveform for Problems 1.11 and 1.12. 1.7 The waveform .pdf
 
Figure Ex. 7.1 represents a portion of a precedence diagram. From the.pdf
 Figure Ex. 7.1 represents a portion of a precedence diagram. From the.pdf Figure Ex. 7.1 represents a portion of a precedence diagram. From the.pdf
Figure Ex. 7.1 represents a portion of a precedence diagram. From the.pdf
 
Figure 1.10 comes from a study of lightning storms in Colorado. It sh.pdf
 Figure 1.10 comes from a study of lightning storms in Colorado. It sh.pdf Figure 1.10 comes from a study of lightning storms in Colorado. It sh.pdf
Figure 1.10 comes from a study of lightning storms in Colorado. It sh.pdf
 
Financing current assets What are the current asset financing strate.pdf
 Financing current assets  What are the current asset financing strate.pdf Financing current assets  What are the current asset financing strate.pdf
Financing current assets What are the current asset financing strate.pdf
 
Find a basis for the column, row, and null space of Solutionde.pdf
 Find a basis for the column, row, and null space of  Solutionde.pdf Find a basis for the column, row, and null space of  Solutionde.pdf
Find a basis for the column, row, and null space of Solutionde.pdf
 

Recently uploaded

Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 

Recently uploaded (20)

Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

Fill out the missing entries in the following table with your answers.pdf

  • 1. Fill out the missing entries in the following table with your answers. Solution Optimization Toolbox fzero Zero of a continuous function of one variable Syntax x = fzero(fun,x0) x = fzero(fun,x0,options) x = fzero(fun,x0,options,P1,P2,...) [x,fval] = fzero(...) [x,fval,exitflag] = fzero(...) [x,fval,exitflag,output] = fzero(...) Description x = fzero(fun,x0) tries to find a zero of fun near x0, if x0 is a scalar. The value x returned by fzero is near a point where fun changes sign, or NaN if the search fails. In this case, the search terminates when the search interval is expanded until an Inf, NaN, or complex value is found. If x0 is a vector of length two, fzero assumes x0 is an interval where the sign of fun(x0(1)) differs from the sign of fun(x0(2)). An error occurs if this is not true. Calling fzero with such an interval guarantees fzero returns a value near a point where fun changes sign. Note Calling fzero with an interval (x0 with two elements) is often faster than calling it with a scalar x0. x = fzero(fun,x0,options) minimizes with the optimization parameters specified in the structure options. x = fzero(fun,x0,options,P1,P2,...) provides for additional arguments, P1, P2, etc., which are passed to the objective function, fun. Use options = [] as a placeholder if no options are set. [x,fval] = fzero(...) returns the value of the objective function fun at the solution x. [x,fval,exitflag] = fzero(...) returns a value exitflag that describes the exit condition. [x,fval,exitflag,output] = fzero(...) returns a structure output that contains information about the optimization. Note For the purposes of this command, zeros are considered to be points where the function actually crosses, not just touches, the x-axis. Arguments Input Arguments. Table 4-1, Input Arguments, contains general descriptions of arguments
  • 2. passed in to fzero. This section provides function-specific details for fun and options: fun The function whose zero is to be computed. fun is a function that accepts a vector x and returns a scalar f, the objective function evaluated at x. The function fun can be specified as a function handle. x = fzero(@myfun,x0) where myfun is a MATLAB function such as function f = myfun(x) f = ... % Compute function value at x fun can also be an inline object. x = fzero(inline('sin(x*x)'),x0); options Optimization parameter options. You can set or change the values of these parameters using the optimset function. fzero uses these options structure fields: Display Level of display. 'off' displays no output; 'iter' displays output at each iteration; 'final' displays just the final output; 'notify' (default) dislays output only if the function does not converge. TolX Termination tolerance on x. Output Arguments. Table 4-2, Output Arguments, contains general descriptions of arguments returned by fzero. This section provides function-specific details for exitflag and output: exitflag Describes the exit condition: > 0 Indicates that fzero found a zero x. < 0 No interval was found with a sign change, or a NaN or Inf function value was encountered during the search for an interval containing a sign change, or a complex function value was encountered during the search for an interval containing a sign change. output Structure containing information about the optimization. The fields of the structure are: iterations Number of iterations taken (for fzero, this is the same as the number of function evaluations). funcCount Number of function evaluations.
  • 3. algorithm Algorithm used. Examples Calculate by finding the zero of the sine function near 3. x = fzero(@sin,3) x = 3.1416 To find the zero of cosine between 1 and 2, x = fzero(@cos,[1 2]) x = 1.5708 Note that cos(1) and cos(2) differ in sign. To find a zero of the function write an M-file called f.m. function y = f(x) y = x.^3-2*x-5; To find the zero near 2 z = fzero(@f,2) z = 2.0946 Since this function is a polynomial, the statement roots([1 0 -2 -5]) finds the same real zero, and a complex conjugate pair of zeros. 2.0946 -1.0473 + 1.1359i -1.0473 - 1.1359i Optimization Toolbox fzero Zero of a continuous function of one variable Syntax x = fzero(fun,x0) x = fzero(fun,x0,options) x = fzero(fun,x0,options,P1,P2,...) [x,fval] = fzero(...) [x,fval,exitflag] = fzero(...)
  • 4. [x,fval,exitflag,output] = fzero(...) Description x = fzero(fun,x0) tries to find a zero of fun near x0, if x0 is a scalar. The value x returned by fzero is near a point where fun changes sign, or NaN if the search fails. In this case, the search terminates when the search interval is expanded until an Inf, NaN, or complex value is found. If x0 is a vector of length two, fzero assumes x0 is an interval where the sign of fun(x0(1)) differs from the sign of fun(x0(2)). An error occurs if this is not true. Calling fzero with such an interval guarantees fzero returns a value near a point where fun changes sign. Note Calling fzero with an interval (x0 with two elements) is often faster than calling it with a scalar x0. x = fzero(fun,x0,options) minimizes with the optimization parameters specified in the structure options. x = fzero(fun,x0,options,P1,P2,...) provides for additional arguments, P1, P2, etc., which are passed to the objective function, fun. Use options = [] as a placeholder if no options are set. [x,fval] = fzero(...) returns the value of the objective function fun at the solution x. [x,fval,exitflag] = fzero(...) returns a value exitflag that describes the exit condition. [x,fval,exitflag,output] = fzero(...) returns a structure output that contains information about the optimization. Note For the purposes of this command, zeros are considered to be points where the function actually crosses, not just touches, the x-axis. Arguments Input Arguments. Table 4-1, Input Arguments, contains general descriptions of arguments passed in to fzero. This section provides function-specific details for fun and options: fun The function whose zero is to be computed. fun is a function that accepts a vector x and returns a scalar f, the objective function evaluated at x. The function fun can be specified as a function handle. x = fzero(@myfun,x0) where myfun is a MATLAB function such as function f = myfun(x) f = ... % Compute function value at x fun can also be an inline object. x = fzero(inline('sin(x*x)'),x0); options Optimization parameter options. You can set or change the values of these parameters using the optimset function. fzero uses these options structure fields:
  • 5. Display Level of display. 'off' displays no output; 'iter' displays output at each iteration; 'final' displays just the final output; 'notify' (default) dislays output only if the function does not converge. TolX Termination tolerance on x. Output Arguments. Table 4-2, Output Arguments, contains general descriptions of arguments returned by fzero. This section provides function-specific details for exitflag and output: exitflag Describes the exit condition: > 0 Indicates that fzero found a zero x. < 0 No interval was found with a sign change, or a NaN or Inf function value was encountered during the search for an interval containing a sign change, or a complex function value was encountered during the search for an interval containing a sign change. output Structure containing information about the optimization. The fields of the structure are: iterations Number of iterations taken (for fzero, this is the same as the number of function evaluations). funcCount Number of function evaluations. algorithm Algorithm used. Examples Calculate by finding the zero of the sine function near 3. x = fzero(@sin,3) x = 3.1416 To find the zero of cosine between 1 and 2, x = fzero(@cos,[1 2]) x = 1.5708 Note that cos(1) and cos(2) differ in sign. To find a zero of the function
  • 6. write an M-file called f.m. function y = f(x) y = x.^3-2*x-5; To find the zero near 2 z = fzero(@f,2) z = 2.0946 Since this function is a polynomial, the statement roots([1 0 -2 -5]) finds the same real zero, and a complex conjugate pair of zeros. 2.0946 -1.0473 + 1.1359i -1.0473 - 1.1359i Optimization Toolbox fzero Zero of a continuous function of one variable Syntax x = fzero(fun,x0) x = fzero(fun,x0,options) x = fzero(fun,x0,options,P1,P2,...) [x,fval] = fzero(...) [x,fval,exitflag] = fzero(...) [x,fval,exitflag,output] = fzero(...) Description x = fzero(fun,x0) tries to find a zero of fun near x0, if x0 is a scalar. The value x returned by fzero is near a point where fun changes sign, or NaN if the search fails. In this case, the search terminates when the search interval is expanded until an Inf, NaN, or complex value is found. If x0 is a vector of length two, fzero assumes x0 is an interval where the sign of fun(x0(1)) differs from the sign of fun(x0(2)). An error occurs if this is not true. Calling fzero with such an interval guarantees fzero returns a value near a point where fun changes sign. Note Calling fzero with an interval (x0 with two elements) is often faster than calling it with a scalar x0. x = fzero(fun,x0,options) minimizes with the optimization parameters specified in the structure options. x = fzero(fun,x0,options,P1,P2,...) provides for additional arguments, P1, P2, etc., which are passed to the objective function, fun. Use options = [] as a placeholder if no options are set.
  • 7. [x,fval] = fzero(...) returns the value of the objective function fun at the solution x. [x,fval,exitflag] = fzero(...) returns a value exitflag that describes the exit condition. [x,fval,exitflag,output] = fzero(...) returns a structure output that contains information about the optimization. Note For the purposes of this command, zeros are considered to be points where the function actually crosses, not just touches, the x-axis. Arguments Input Arguments. Table 4-1, Input Arguments, contains general descriptions of arguments passed in to fzero. This section provides function-specific details for fun and options: fun The function whose zero is to be computed. fun is a function that accepts a vector x and returns a scalar f, the objective function evaluated at x. The function fun can be specified as a function handle. x = fzero(@myfun,x0) where myfun is a MATLAB function such as function f = myfun(x) f = ... % Compute function value at x fun can also be an inline object. x = fzero(inline('sin(x*x)'),x0); options Optimization parameter options. You can set or change the values of these parameters using the optimset function. fzero uses these options structure fields: Display Level of display. 'off' displays no output; 'iter' displays output at each iteration; 'final' displays just the final output; 'notify' (default) dislays output only if the function does not converge. TolX Termination tolerance on x. Output Arguments. Table 4-2, Output Arguments, contains general descriptions of arguments returned by fzero. This section provides function-specific details for exitflag and output: exitflag Describes the exit condition: > 0 Indicates that fzero found a zero x. < 0 No interval was found with a sign change, or a NaN or Inf function value was encountered
  • 8. during the search for an interval containing a sign change, or a complex function value was encountered during the search for an interval containing a sign change. output Structure containing information about the optimization. The fields of the structure are: iterations Number of iterations taken (for fzero, this is the same as the number of function evaluations). funcCount Number of function evaluations. algorithm Algorithm used. Examples Calculate by finding the zero of the sine function near 3. x = fzero(@sin,3) x = 3.1416 To find the zero of cosine between 1 and 2, x = fzero(@cos,[1 2]) x = 1.5708 Note that cos(1) and cos(2) differ in sign. To find a zero of the function write an M-file called f.m. function y = f(x) y = x.^3-2*x-5; To find the zero near 2 z = fzero(@f,2) z = 2.0946 Since this function is a polynomial, the statement roots([1 0 -2 -5]) finds the same real zero, and a complex conjugate pair of zeros. 2.0946 -1.0473 + 1.1359i -1.0473 - 1.1359i Optimization Toolbox
  • 9. fzero Zero of a continuous function of one variable Syntax x = fzero(fun,x0) x = fzero(fun,x0,options) x = fzero(fun,x0,options,P1,P2,...) [x,fval] = fzero(...) [x,fval,exitflag] = fzero(...) [x,fval,exitflag,output] = fzero(...) Description x = fzero(fun,x0) tries to find a zero of fun near x0, if x0 is a scalar. The value x returned by fzero is near a point where fun changes sign, or NaN if the search fails. In this case, the search terminates when the search interval is expanded until an Inf, NaN, or complex value is found. If x0 is a vector of length two, fzero assumes x0 is an interval where the sign of fun(x0(1)) differs from the sign of fun(x0(2)). An error occurs if this is not true. Calling fzero with such an interval guarantees fzero returns a value near a point where fun changes sign. Note Calling fzero with an interval (x0 with two elements) is often faster than calling it with a scalar x0. x = fzero(fun,x0,options) minimizes with the optimization parameters specified in the structure options. x = fzero(fun,x0,options,P1,P2,...) provides for additional arguments, P1, P2, etc., which are passed to the objective function, fun. Use options = [] as a placeholder if no options are set. [x,fval] = fzero(...) returns the value of the objective function fun at the solution x. [x,fval,exitflag] = fzero(...) returns a value exitflag that describes the exit condition. [x,fval,exitflag,output] = fzero(...) returns a structure output that contains information about the optimization. Note For the purposes of this command, zeros are considered to be points where the function actually crosses, not just touches, the x-axis. Arguments Input Arguments. Table 4-1, Input Arguments, contains general descriptions of arguments passed in to fzero. This section provides function-specific details for fun and options: fun The function whose zero is to be computed. fun is a function that accepts a vector x and returns a scalar f, the objective function evaluated at x. The function fun can be specified as a function handle. x = fzero(@myfun,x0)
  • 10. where myfun is a MATLAB function such as function f = myfun(x) f = ... % Compute function value at x fun can also be an inline object. x = fzero(inline('sin(x*x)'),x0); options Optimization parameter options. You can set or change the values of these parameters using the optimset function. fzero uses these options structure fields: Display Level of display. 'off' displays no output; 'iter' displays output at each iteration; 'final' displays just the final output; 'notify' (default) dislays output only if the function does not converge. TolX Termination tolerance on x. Output Arguments. Table 4-2, Output Arguments, contains general descriptions of arguments returned by fzero. This section provides function-specific details for exitflag and output: exitflag Describes the exit condition: > 0 Indicates that fzero found a zero x. < 0 No interval was found with a sign change, or a NaN or Inf function value was encountered during the search for an interval containing a sign change, or a complex function value was encountered during the search for an interval containing a sign change. output Structure containing information about the optimization. The fields of the structure are: iterations Number of iterations taken (for fzero, this is the same as the number of function evaluations). funcCount Number of function evaluations. algorithm Algorithm used. Examples Calculate by finding the zero of the sine function near 3. x = fzero(@sin,3) x =
  • 11. 3.1416 To find the zero of cosine between 1 and 2, x = fzero(@cos,[1 2]) x = 1.5708 Note that cos(1) and cos(2) differ in sign. To find a zero of the function write an M-file called f.m. function y = f(x) y = x.^3-2*x-5; To find the zero near 2 z = fzero(@f,2) z = 2.0946 Since this function is a polynomial, the statement roots([1 0 -2 -5]) finds the same real zero, and a complex conjugate pair of zeros. 2.0946 -1.0473 + 1.1359i -1.0473 - 1.1359i Optimization Toolbox fzero Zero of a continuous function of one variable Syntax x = fzero(fun,x0) x = fzero(fun,x0,options) x = fzero(fun,x0,options,P1,P2,...) [x,fval] = fzero(...) [x,fval,exitflag] = fzero(...) [x,fval,exitflag,output] = fzero(...) Description x = fzero(fun,x0) tries to find a zero of fun near x0, if x0 is a scalar. The value x returned by fzero is near a point where fun changes sign, or NaN if the search fails. In this case, the search terminates when the search interval is expanded until an Inf, NaN, or complex value is found. If x0 is a vector of length two, fzero assumes x0 is an interval where the sign of fun(x0(1))
  • 12. differs from the sign of fun(x0(2)). An error occurs if this is not true. Calling fzero with such an interval guarantees fzero returns a value near a point where fun changes sign. Note Calling fzero with an interval (x0 with two elements) is often faster than calling it with a scalar x0. x = fzero(fun,x0,options) minimizes with the optimization parameters specified in the structure options. x = fzero(fun,x0,options,P1,P2,...) provides for additional arguments, P1, P2, etc., which are passed to the objective function, fun. Use options = [] as a placeholder if no options are set. [x,fval] = fzero(...) returns the value of the objective function fun at the solution x. [x,fval,exitflag] = fzero(...) returns a value exitflag that describes the exit condition. [x,fval,exitflag,output] = fzero(...) returns a structure output that contains information about the optimization. Note For the purposes of this command, zeros are considered to be points where the function actually crosses, not just touches, the x-axis. Arguments Input Arguments. Table 4-1, Input Arguments, contains general descriptions of arguments passed in to fzero. This section provides function-specific details for fun and options: fun The function whose zero is to be computed. fun is a function that accepts a vector x and returns a scalar f, the objective function evaluated at x. The function fun can be specified as a function handle. x = fzero(@myfun,x0) where myfun is a MATLAB function such as function f = myfun(x) f = ... % Compute function value at x fun can also be an inline object. x = fzero(inline('sin(x*x)'),x0); options Optimization parameter options. You can set or change the values of these parameters using the optimset function. fzero uses these options structure fields: Display Level of display. 'off' displays no output; 'iter' displays output at each iteration; 'final' displays just the final output; 'notify' (default) dislays output only if the function does not converge. TolX Termination tolerance on x.
  • 13. Output Arguments. Table 4-2, Output Arguments, contains general descriptions of arguments returned by fzero. This section provides function-specific details for exitflag and output: exitflag Describes the exit condition: > 0 Indicates that fzero found a zero x. < 0 No interval was found with a sign change, or a NaN or Inf function value was encountered during the search for an interval containing a sign change, or a complex function value was encountered during the search for an interval containing a sign change. output Structure containing information about the optimization. The fields of the structure are: iterations Number of iterations taken (for fzero, this is the same as the number of function evaluations). funcCount Number of function evaluations. algorithm Algorithm used. Examples Calculate by finding the zero of the sine function near 3. x = fzero(@sin,3) x = 3.1416 To find the zero of cosine between 1 and 2, x = fzero(@cos,[1 2]) x = 1.5708 Note that cos(1) and cos(2) differ in sign. To find a zero of the function write an M-file called f.m. function y = f(x) y = x.^3-2*x-5; To find the zero near 2 z = fzero(@f,2) z =
  • 14. 2.0946 Since this function is a polynomial, the statement roots([1 0 -2 -5]) finds the same real zero, and a complex conjugate pair of zeros. 2.0946 -1.0473 + 1.1359i -1.0473 - 1.1359i Optimization Toolbox fzero Zero of a continuous function of one variable Syntax x = fzero(fun,x0) x = fzero(fun,x0,options) x = fzero(fun,x0,options,P1,P2,...) [x,fval] = fzero(...) [x,fval,exitflag] = fzero(...) [x,fval,exitflag,output] = fzero(...) Description x = fzero(fun,x0) tries to find a zero of fun near x0, if x0 is a scalar. The value x returned by fzero is near a point where fun changes sign, or NaN if the search fails. In this case, the search terminates when the search interval is expanded until an Inf, NaN, or complex value is found. If x0 is a vector of length two, fzero assumes x0 is an interval where the sign of fun(x0(1)) differs from the sign of fun(x0(2)). An error occurs if this is not true. Calling fzero with such an interval guarantees fzero returns a value near a point where fun changes sign. Note Calling fzero with an interval (x0 with two elements) is often faster than calling it with a scalar x0. x = fzero(fun,x0,options) minimizes with the optimization parameters specified in the structure options. x = fzero(fun,x0,options,P1,P2,...) provides for additional arguments, P1, P2, etc., which are passed to the objective function, fun. Use options = [] as a placeholder if no options are set. [x,fval] = fzero(...) returns the value of the objective function fun at the solution x. [x,fval,exitflag] = fzero(...) returns a value exitflag that describes the exit condition. [x,fval,exitflag,output] = fzero(...) returns a structure output that contains information about the optimization. Note For the purposes of this command, zeros are considered to be points where the function actually crosses, not just touches, the x-axis.
  • 15. Arguments Input Arguments. Table 4-1, Input Arguments, contains general descriptions of arguments passed in to fzero. This section provides function-specific details for fun and options: fun The function whose zero is to be computed. fun is a function that accepts a vector x and returns a scalar f, the objective function evaluated at x. The function fun can be specified as a function handle. x = fzero(@myfun,x0) where myfun is a MATLAB function such as function f = myfun(x) f = ... % Compute function value at x fun can also be an inline object. x = fzero(inline('sin(x*x)'),x0); options Optimization parameter options. You can set or change the values of these parameters using the optimset function. fzero uses these options structure fields: Display Level of display. 'off' displays no output; 'iter' displays output at each iteration; 'final' displays just the final output; 'notify' (default) dislays output only if the function does not converge. TolX Termination tolerance on x. Output Arguments. Table 4-2, Output Arguments, contains general descriptions of arguments returned by fzero. This section provides function-specific details for exitflag and output: exitflag Describes the exit condition: > 0 Indicates that fzero found a zero x. < 0 No interval was found with a sign change, or a NaN or Inf function value was encountered during the search for an interval containing a sign change, or a complex function value was encountered during the search for an interval containing a sign change. output Structure containing information about the optimization. The fields of the structure are: iterations Number of iterations taken (for fzero, this is the same as the number of function evaluations).
  • 16. funcCount Number of function evaluations. algorithm Algorithm used. Examples Calculate by finding the zero of the sine function near 3. x = fzero(@sin,3) x = 3.1416 To find the zero of cosine between 1 and 2, x = fzero(@cos,[1 2]) x = 1.5708 Note that cos(1) and cos(2) differ in sign. To find a zero of the function write an M-file called f.m. function y = f(x) y = x.^3-2*x-5; To find the zero near 2 z = fzero(@f,2) z = 2.0946 Since this function is a polynomial, the statement roots([1 0 -2 -5]) finds the same real zero, and a complex conjugate pair of zeros. 2.0946 -1.0473 + 1.1359i -1.0473 - 1.1359i Optimization Toolbox fzero Zero of a continuous function of one variable Syntax x = fzero(fun,x0) x = fzero(fun,x0,options) x = fzero(fun,x0,options,P1,P2,...)
  • 17. [x,fval] = fzero(...) [x,fval,exitflag] = fzero(...) [x,fval,exitflag,output] = fzero(...) Description x = fzero(fun,x0) tries to find a zero of fun near x0, if x0 is a scalar. The value x returned by fzero is near a point where fun changes sign, or NaN if the search fails. In this case, the search terminates when the search interval is expanded until an Inf, NaN, or complex value is found. If x0 is a vector of length two, fzero assumes x0 is an interval where the sign of fun(x0(1)) differs from the sign of fun(x0(2)). An error occurs if this is not true. Calling fzero with such an interval guarantees fzero returns a value near a point where fun changes sign. Note Calling fzero with an interval (x0 with two elements) is often faster than calling it with a scalar x0. x = fzero(fun,x0,options) minimizes with the optimization parameters specified in the structure options. x = fzero(fun,x0,options,P1,P2,...) provides for additional arguments, P1, P2, etc., which are passed to the objective function, fun. Use options = [] as a placeholder if no options are set. [x,fval] = fzero(...) returns the value of the objective function fun at the solution x. [x,fval,exitflag] = fzero(...) returns a value exitflag that describes the exit condition. [x,fval,exitflag,output] = fzero(...) returns a structure output that contains information about the optimization. Note For the purposes of this command, zeros are considered to be points where the function actually crosses, not just touches, the x-axis. Arguments Input Arguments. Table 4-1, Input Arguments, contains general descriptions of arguments passed in to fzero. This section provides function-specific details for fun and options: fun The function whose zero is to be computed. fun is a function that accepts a vector x and returns a scalar f, the objective function evaluated at x. The function fun can be specified as a function handle. x = fzero(@myfun,x0) where myfun is a MATLAB function such as function f = myfun(x) f = ... % Compute function value at x fun can also be an inline object. x = fzero(inline('sin(x*x)'),x0); options
  • 18. Optimization parameter options. You can set or change the values of these parameters using the optimset function. fzero uses these options structure fields: Display Level of display. 'off' displays no output; 'iter' displays output at each iteration; 'final' displays just the final output; 'notify' (default) dislays output only if the function does not converge. TolX Termination tolerance on x. Output Arguments. Table 4-2, Output Arguments, contains general descriptions of arguments returned by fzero. This section provides function-specific details for exitflag and output: exitflag Describes the exit condition: > 0 Indicates that fzero found a zero x. < 0 No interval was found with a sign change, or a NaN or Inf function value was encountered during the search for an interval containing a sign change, or a complex function value was encountered during the search for an interval containing a sign change. output Structure containing information about the optimization. The fields of the structure are: iterations Number of iterations taken (for fzero, this is the same as the number of function evaluations). funcCount Number of function evaluations. algorithm Algorithm used. Examples Calculate by finding the zero of the sine function near 3. x = fzero(@sin,3) x = 3.1416 To find the zero of cosine between 1 and 2, x = fzero(@cos,[1 2]) x = 1.5708 Note that cos(1) and cos(2) differ in sign.
  • 19. To find a zero of the function write an M-file called f.m. function y = f(x) y = x.^3-2*x-5; To find the zero near 2 z = fzero(@f,2) z = 2.0946 Since this function is a polynomial, the statement roots([1 0 -2 -5]) finds the same real zero, and a complex conjugate pair of zeros. 2.0946 -1.0473 + 1.1359i -1.0473 - 1.1359i Optimization Toolbox