1
$\begingroup$

I have a complicated vector of 3 coordinates (with complicated expressions), depending on 7 variables. I know that the system has an infinite number of solutions but I would like to find just 20 solutions in a certain range. I used NSolve but it returns the input.

How to do this ?

Even when I use something as simple as the program below, where I have no constraints and where I ask for only one solution, it does not work..

My program : (PS: I am not familiar with mathematica so it is a beginner's code)

1st, I define a matrix function that will help me build my equation:

Ti[i_, j_, \[Alpha]_, d_, 
   a_, \[Theta]0_, \[Theta]exp_] := ({{Cos[\[Theta]exp[[i, 
        j]] + \[Theta]0[[
        j]]], -Sin[\[Theta]exp[[i, j]] + \[Theta]0[[j]]]*
      Cos[\[Alpha][[j]]], 
     Sin[\[Theta]exp[[i, j]] + \[Theta]0[[j]]]*Sin[\[Alpha][[j]]], 
     a[[j]]*Cos[\[Theta]exp[[i, j]] + \[Theta]0[[
         j]]]}, {Sin[\[Theta]exp[[i, j]] + \[Theta]0[[j]]], 
     Cos[\[Theta]exp[[i, j]] + \[Theta]0[[j]]]*
      Cos[\[Alpha][[j]]], -Cos[\[Theta]exp[[i, j]] + \[Theta]0[[j]]]*
      Sin[\[Alpha][[j]]], 
     a[[j]]*Sin[\[Theta]exp[[i, j]] + \[Theta]0[[j]]]}, {0, 
     Sin[\[Alpha][[j]]], Cos[\[Alpha][[j]]], d[[j]]}, {0, 0, 0, 1}});
P[i_, \[Alpha]_, d_, a_, \[Theta]0_, \[Theta]exp_, P7_] := 
  Ti[i, 1, \[Alpha], d, a, \[Theta]0, \[Theta]exp].Ti[i, 2, \[Alpha], 
    d, a, \[Theta]0, \[Theta]exp].Ti[i, 3, \[Alpha], d, 
    a, \[Theta]0, \[Theta]exp].Ti[i, 4, \[Alpha], d, 
    a, \[Theta]0, \[Theta]exp].Ti[i, 5, \[Alpha], d, 
    a, \[Theta]0, \[Theta]exp].Ti[i, 6, \[Alpha], d, 
    a, \[Theta]0, \[Theta]exp].Ti[i, 7, \[Alpha], d, 
    a, \[Theta]0, \[Theta]exp].P7;

After, I define the constant parameters:

\[Alpha]real = {-90, 90, -90, -90, 90, -90, 0}*Pi/180;
dreal = {455, 0, 770, 0, -531, 0, -131};
areal = {0, -65, 0, -65, 0, -29, 0};
\[Theta]0real = {0, 0, 0, 0, 0, 0, 0}*Pi/180;
P7real = {0, 0, 50, 1};

Then, I simulate the system for random variables

\[Theta]all = RandomReal[360, {1, 7}]*Pi/180;
P0temp = P[1, \[Alpha]real, dreal, areal, \[Theta]0real, \[Theta]all, 
   P7real];

After, I define my variables:

inc = Table[0, {i, 1, 1}, {j, 1, 7}];
\[Theta]inc[[1, 1]] = \[Theta]inc1;
\[Theta]inc[[1, 2]] = \[Theta]inc2;
\[Theta]inc[[1, 3]] = \[Theta]inc3;
\[Theta]inc[[1, 4]] = \[Theta]inc4;
\[Theta]inc[[1, 5]] = \[Theta]inc5;
\[Theta]inc[[1, 6]] = \[Theta]inc6;
\[Theta]inc[[1, 7]] = \[Theta]inc7;
P0inc = P[1, \[Alpha]real, dreal, areal, \[Theta]0real, \[Theta]inc, 
   P7real];

and finally I want to solve the esuation, normally Mathematica should at least give the value of the vector [Theta]all as a solution but it does not.

FindInstance[
 P0inc == P0temp, {\[Theta]inc1, \[Theta]inc2, \[Theta]inc3, \
\[Theta]inc4, \[Theta]inc5, \[Theta]inc6, \[Theta]inc7}, Reals, 1]
$\endgroup$
3
  • 3
    $\begingroup$ see FindInstance? $\endgroup$
    – kglr
    Sep 13, 2018 at 13:40
  • 3
    $\begingroup$ Note that you will only get generic suggestions if you don't give us actual code and details to play with. $\endgroup$
    – MarcoB
    Sep 13, 2018 at 13:52
  • $\begingroup$ Ok, I used FindInstance, my code is below, can you please tell me why it does not work? Thank you $\endgroup$
    – Salma
    Sep 14, 2018 at 7:36

0

Browse other questions tagged or ask your own question.