[Date Index]
[Thread Index]
[Author Index]
Optional Arguments and FindRoot
*To*: mathgroup at smc.vnet.net
*Subject*: [mg13217] Optional Arguments and FindRoot
*From*: sean_ross_at_pl-04m3 at smtpgw1.plk.af.mil
*Date*: Mon, 13 Jul 1998 07:43:05 -0400
*Sender*: owner-wri-mathgroup at wolfram.com
I have a function which has an optional _Real argument with a
default
value of 0.0. When I execute FindRoot on this function, it
executes
properly if I give a non-zero value for my optional parameter or
leave
it out. If I specify a value of 0.0 for this parameter, then
FindRoot
substitutes an INTEGER zero. Can anyone shed any light as to why
this
is occurring? I fixed the problem with an extra function
definition
for Integer zero final arguments, so that is not an issue. I am
interested in why FindRoot decided to put an Integer zero where I
specified a Real zero.
Thanks. Sean
Here is the definition of the function, with a final optional
argument
qsoi_Real:0.
Dkopo[lp_Real:1.064, ls_Real,
Topo_Real /; Topo > 20. && Topo <= 200., qsoi_Real:0.] /;
ls > lp :=
Module[{li, qioi},
li = (1/lp - 1/ls)^(-1);
qioi =
ArcSin[li/
nextLiNbO3[li, Topo]*(
nextLiNbO3[ls, Topo]*Sin[qsoi])/ls];
2*Pi*(nextLiNbO3[lp, Topo]/lp -
nextLiNbO3[ls, Topo]*Cos[qsoi]/ls -
nextLiNbO3[li, Topo]*Cos[qioi]/li -
1/Dopo[Topo])];
Dopo[T_(*degrees C*)]:=
Module[{a=1.54*^-5, b=5.3*^-9},
29.75 (1+a (T-25.)+ b (T-25.)^2)];
Here is the FindRoot executing just fine if I leave the argument
out.
FindRoot[Dkopo[1.064,x,45.],{x,1.54,1.55}]
{x->1.52972}
Here is the FindRoot executing just fine if I specify a non-zero
argument.
FindRoot[Dkopo[1.064,x,45.,0.001],{x,1.54,1.55}]
{x->1.52989}
Here is the findroot function substituting an INTEGER zero into my
function rather than the REAL zero I specified.
FindRoot[Dkopo[1.064,x,45.,0.000],{x,1.54,1.55}]
FindRoot::"frnum":
"Function ({Dkopo[\(1.06400000000000005`, \
1.54000000000000003`, 45.`, 0\)]}\) is not a length 1 list of
numbers
at x = 1.540"
Prev by Date:
**Default format for new cells**
Next by Date:
**Rotated fonts and Greek characters**
Previous by thread:
**Re: Default format for new cells**
Next by thread:
**Rotated fonts and Greek characters**
| |