I am trying to solve a 6-equation system with one self-built function. Problem is, 3 equation must be passed as argument while the other 3 are defined inside the function. I am quite new with Wolfram Mathematica and I don´t understand how I should pass arguments to properly build the equation system with the local variables inside the function.
eqlin = {xE == O5[[1]], yE == O5[[2]], zE == O5[[3]]} /.
{Cos[\[Alpha]0 + \[Theta]1] -> C1, Sin[\[Alpha]0 + \[Theta]1] -> S1,
Cos[\[Theta]2] -> C2, Sin[\[Theta]2] -> S2, Cos[\[Theta]2 + \[Theta]3] -> C3,
Sin[\[Theta]2 + \[Theta]3] -> S3}
Here I define the 3 equations to be passed to the function. I previously defined O5[[1]], O5[[2]], O5[[3]] so mathematica gives me as output (when I evaluate this section of the code):
{xE == -C1 (a1 - C2 L1 + C3 L2) + x0, yE == -(a1 - C2 L1 + C3 L2) S1,
zE == L1 S2 - L2 S3 + z1}
which is correct. Now I build a function to modify the answer (not important for my question, but I use it later):
MinusPi[\[Alpha]_] := ArcTan[Cos[\[Alpha]], Sin[\[Alpha]]];
and then I define the main question:
InverseCinem[x0_, z1_, a1_, \[Alpha]0_, L1_, L2_, xE_, yE_, zE_, eqlin_] := Module[
{LinearSolution, C1, S1, C2, S2, C3, S3, temp},
LinearSolution = NSolve[
{eqlin[[1]], eqlin[[2]], eqlin[[3]], C1^2 + S1^2 == 1,
C2^2 + S2^2 == 1, C3^2 + S3^2 == 1},
{C1, S1, C2, S2, C3, S3}];
temp = {ArcTan[C1, S1] - \[Alpha]0, ArcTan[C2, S2], ArcTan[C3, S3] - ArcTan[C2, S2]} /. LinearSolution
Map[MinusPi, temp]
]
then I call the function using arguments from a previusly built vector (no problem with this one, I used it somewhere else and it is correct):
ss = N[InverseCinem[paramCost[[1]], paramCost[[2]], paramCost[[3]],
paramCost[[4]], paramCost[[5]], paramCost[[6]], 5, 0, 20, eqlin]]
but the answer is:
{-1.0472 + ArcTan[C1$12808, S1$12808], ArcTan[C2$12808, S2$12808], -1.ArcTan[C2$12808, S2$12808] + ArcTan[C3$12808, S3$12808]}
Can someone help me? thanks a lot
For example:
f =x^2+y==3 (*function of argument x and y*)
Funct[argument_] := Module[
{x,y}, Solve[{argument, x-y==-1},{x,y}]]
Funct[f]
This last command should not work because the x and y defined as local variables inside Module are not considered the same as the x and y used in f outside the Module. This is what I understood up to now about how Mathematica treats local and global variables. If this is right I suppose it must be pretty obvious for someone knowing how Mathematica works, but I have been working with Mathematica only for a few days and I find it waaaay more tricky than in other languages where managing local and global variables is easier.
InverseCinem
after its definition? $\endgroup$LinearSolution
is{}
in this case, so no replacement is made. $\endgroup$