
Re: question
Posted:
Apr 8, 2014 3:36 AM


First, please do not hurl unfounded  and unjustified  insults at Mathematica just because you're having trouble applying it to a particular problem.
(I say "unjustified" because one could argue quite the opposite: With all the added functionality in recent versions for image processing, stochastic processes, exploiting curated databases, etc., it seems to me that Mathematica is in fact being oriented more towards doing "applied work" of great variety more than towards satisfying the needs of "university types".)
Second, as to your problem itself, I've simplified and modified the code somewhat so as to:
 use Set (=) rather than SetDelayed (:=) in the definitions that involve derivatives, so that the same derivatives are not calculated repeatedly;
 use NumericQ rather than NumberQ;
 let Mathematica do more of the work by using builtin Normalize in the definitions of q1 and q2;
 eliminate the superfluous assumptions about the reality of the derivative of the vectorvalued function beta2' (including that assumption in the original definition of beta1', where it's irrelevant).
The resulting code is:
beta2[t_] := {Cos[2Pi t], Sin[2Pi t]} beta1[t_] := beta2[t + (48/10)t^2 (t  1)^2]
q1[s_] = Normalize[beta1'[s]]; q2[t_] = Normalize[beta2'[t]];
a[t_, z_] = 2 q1[t].q2'[z]; b[t_, z_] = q1[t].q2[z]; c[t_, z_] = 2 q1'[t].q2[z];
F1[t_, z_] = FunctionExpand[ c[t, z]/b[t, z], {t \[Element] Reals, z \[Element] Reals}]; F2[t_, z_] = FunctionExpand[ a[t, z]/b[t, z], {t \[Element] Reals, z \[Element] Reals}];
factor1[s_, z_?NumericQ] := Exp[NIntegrate[F2[s, u], {u, 0, z}]] factor2[s_, z_?NumericQ] := Exp[NIntegrate[F2[s, u], {u, 0, z}]]
g[s_?NumericQ, z_?NumericQ] := NIntegrate[factor2[s, tau] F1[s, tau],{tau, 0, z}]
y[s_?NumericQ, z_?NumericQ] := factor1[s, z] g[s, z]
And now:
y[0.2, 0.3]
NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in u near {u} = {0.0732375}. NIntegrate obtained 9.98518 and 13.51073580442933` for the integral and error estimates. >>
NIntegrate::errprec: Catastrophic loss of precision in the global error estimate due to insufficient WorkingPrecision or divergent integral. >>
21702.4 NIntegrate[factor2[0.2, tau] F1[0.2, tau], {tau, 0, 0.3}]
The syntactical problems seem to be gone and now you might look at the underlying _mathematical_ difficulties here.
Look at the two factors we're trying to evaluate for y[0.2, 0.3]:
factor1[0.2, 0.3] NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in u near {u} = {0.0732375}. NIntegrate obtained 9.98518 and 13.51073580442933` for the integral and error estimates. >>
21702.4
g[0.2, 0.3] NIntegrate::errprec: Catastrophic loss of precision in the global error estimate due to insufficient WorkingPrecision or divergent integral. >>
NIntegrate[factor2[0.2, tau] F1[0.2, tau], {tau, 0, 0.3}]
So _both_ factors so far elude numeric integration, at least with default WorkingPrecision.
Hope this can help a bit.
On Apr 5, 2014, at 1:48 AM, Hagwood, Charles R <charles.hagwood@nist.gov> wrote:
> > I am so sick of Mathematica. It no longer seems to be a package to do applied work, but more for the university types. I have spent several hours using several combinations > of ?NumberQ in the following code, but still I get an error. Last weekend I spend several hours using FunctionExpand to get results I can read. > > Any help appreciated. > > > > r1=1; > r2=2; > beta2[t_]:={r1*Cos[2*Pi*t],r2*Sin[2*Pi*t]} > > beta1[t_]:=beta2[t+4.8*t^2*(t1)^2] > > q2[t_]:= > = FunctionExpand[beta2'[t]/Sqrt[Norm[beta2'[t]]],Assumptions>t\[Element] Reals && beta2'\[Element]Vectors[2,Reals]] > > q1[s_]:=FunctionExpand[ > beta1'[s]/Sqrt[Norm[beta1'[s]]],Assumptions>s\[Element] Reals&& beta2'\[Element]Vectors[2,Reals]] > > > a[t_, z_] := 2*q1[t].q2'[z] // FunctionExpand > b[t_, z_] := q1[t].q2[z] // FunctionExpand > c[t_, z_] := 2*q1'[t].q2[z] // FunctionExpand > > > F1[t_, z_] := c[t, z]/b[t, z] > F2[t_, z_] := a[t, z]/b[t, z] > > > > factor1[s_, z_] := Exp[NIntegrate[F2[s, u], {u, 0, z}]] > > factor2[s_, z_] := Exp[NIntegrate[F2[s, u], {u, 0, z}]] > > g[s_, z_?NumberQ] := NIntegrate[factor2[s, tau]*F1[s, tau], {tau, 0, z}] > > y[s_, z_] := factor1[s, z]*g[s, z] > > y[.2, .3] > > > I get the error > > NIntegrate::nlim: _u_ = _tau_ is not a valid limit of integration > >
Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 240 2467240 (H) University of Massachusetts 710 North Pleasant Street Amherst, MA 010039305

