0
$\begingroup$

I have a numerical function zz:

zz[s_ ? NumericQ] := so3toE3[Inverse[yn[s]].ND[yn[k], k, s]];

The other functions involved have 2 pages of code defining them so I will leave it at that for now unless asked to give more detail

Print[A0];
Print[ND[zz[kk], kk, 1]];
Print["J1 A=0 ", NIntegrate[Norm[ND[zz[kk], kk, tt] ], {tt, 0, 1}, Method -> {"TrapezoidalRule", "Points" -> 100}, MaxRecursion -> 0, PrecisionGoal -> 3]]
Print["J1 A only ", NIntegrate[Norm[A0], {tt, 0, 1}, Method -> {"TrapezoidalRule", "Points" -> 100}, MaxRecursion -> 0, PrecisionGoal -> 3]];
Print["J1 ", NIntegrate[Norm[ND[zz[kk], kk, tt] - A0], {tt, 0, 1}, Method ->{"TrapezoidalRule", "Points" -> 100}, MaxRecursion -> 0,  PrecisionGoal -> 3]];

The output of the preceding statements are:

{0.5,-0.1,0.}
{-1.57106,4.25392,-0.435128}
J1 A=0 4.21996
J1 A only 0.509902

These are as expected. The problem happens when I then try and subtract A0 from the other expression:

NIntegrate::inum: Integrand Sqrt[Abs[-0.5+1/63 (Times[<<2>>]+Times[<<2>>])]^2+Abs[0. +1/63 (Times[<<2>>]+Times[<<2>>])]^2+Abs[0.1 +1/63 (Times[<<2>>]+Times[<<2>>])]^2] is not numerical at {tt} = {0.}. >>
NIntegrate::inum: Integrand Sqrt[Abs[-0.5+1/63 (Times[<<2>>]+Times[<<2>>])]^2+Abs[0. +1/63 (Times[<<2>>]+Times[<<2>>])]^2+Abs[0.1 +1/63 (Times[<<2>>]+Times[<<2>>])]^2] is not numerical at {tt} = {0.}. >>
J1 NIntegrate[Norm[ND[zz$1746189[kk],kk,tt]-A0$1746189],{tt,0,1},Method->{TrapezoidalRule,Points->100},MaxRecursion->0,PrecisionGoal->3]

Why is subtracting A0 from ND[zz[kk], kk, tt] causing a problem even though I know they are both vectors of the same dimension? Is there a way of 'declaring' that zz is a vector of Length[] equal to 3?

Thanks.

$\endgroup$
2
  • 1
    $\begingroup$ This answer is probably the key to your question. Use dummy[s_?NumericQ] := A0 and make your integrand Norm[ND[zz[kk], kk, tt] - dummy[tt]]. The explanation is in the linked answer. (It's hard to check since working code is not included here.) $\endgroup$
    – Michael E2
    Jun 7, 2013 at 3:22
  • $\begingroup$ Thanks @MichaelE2, that works perfectly. I'll close the question and look at the linked answer for the explanation. $\endgroup$
    – muzzlator
    Jun 7, 2013 at 5:21

0