| Author |
Comment/Response |
Bill
|
07/03/08 01:00am
Hi:
Question: What would be the Mathematica code to test Out[5], to verify that all 4 values, {s,t,u,v}, are between 0 and 1? What I want to do is to print a mesage stating that the parameters are within tolerance, or are not within tolerance. (If even one is out of the 0 to 1 range, I want to reject the entire group.)
In[1]:=
Clear[X,Y,s,t,u,v,dSq];
X[s_,t_]={0+s*2+t*0,0+s*0+t*3,4+s*(-1)+t*(-1)};
Y[u_,v_]={v*Sin[u]-2,v*Cos[u],-v^2-1};
dSq[s_,t_,u_,v_]=(X[s,t]-Y[u,v]).(X[s,t]-Y[u,v]);
soln=FindRoot[{D[dSq[s,t,u,v],s]==0,D[dSq[s,t,u,v],t]==0,D[dSq[s,t,u,v],u]==0,D[dSq[s,t,u,v],v]==0},{{s,1},{t,1},{u,1},{v,1}}];
Chop[%,10^-6]
{s,t,u,v}=Flatten[{s,t,u,v}/.soln];
Out[5]=
{s->0.210459,t->0.537982,u->0.982794,v->0.300463}
tia,
Bill
PS. I'm using Mathematica 6.0.1 with Windows XP on a PC.
URL: , |
|