# Issues with syntax procedural structures inside module

Posted 9 years ago
4801 Views
|
2 Replies
|
2 Total Likes
|
 Hello, I am a beginner, I've written a method to calculate the unknown arriere[D_, R_] := Module[{n, a, b, x},       a = D;       b = R;       n = Dimensions[a][[1]];              For[j = n, j >= 1, j--,         If[ a[[j, j]] == 0 , Break[]]           x[[j]] = b[[j]]/a[[j, j]];          For[i = 1, i <= j - 1,      i++                 b[[i]] = b[[i]] - a[[i, j]]*x[[j]];          ];        ];      {x}];[/i][/i][/color]but it returns me only the values ??of the inputk = {{1, 2, 3}, {0, -3, -6}, {0, 0, 1}}l = {1, -3, 0}[/color]arriere[k, l]arriere[{{1, 2, 3}, {0, -3, -6}, {0, 0, 1}}, {1, -3, 0}]
2 Replies
Sort By:
Posted 9 years ago
 Please use a more descriptive subject heading in future.
Posted 9 years ago
 In[1]:= calcularriere[d_, r_] := Module[{n, a, b, x},    a = d;    b = r;    n = Dimensions[a][[1]];    For[j = n, j >= 1, j--,     If[a[[j, j]] == 0, Break[]];      x = b/a[[j, j]];     For[i = 1, i <= j - 1, i++,       b = b - a[[i, j]]*x     ]    ];   x];k = {{1, 2, 3}, {0, -3, -6}, {0, 0, 1}};l = {1, -3, 0};calcularriere[k, l]Out[4]= {20/3, -20, 0}No space in name calcul arriere.D is the derivative function name in Mathematica.Dimensions[ a ] returns a list of all dimensions {3,3}.No extra [ ] after variables.Semicolon between each two expressions.I hope this is correct and helps you.
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.