laatp

5 Reputation

2 Badges

13 years, 26 days

MaplePrimes Activity


These are replies submitted by laatp

I think I explained badly. Probably much better with an example:

I have something like this:

# with(ListTools)...
eqti := (x,y) -> if x = y then 1 else 0 end if;
for i from 1 to 3 do: p[i] := DotProduct([`$`(a[i,j],j=1..3)],[1,x,y]); end do;
for i from 1 to 3 do:
  for j from 1 to 3 do:
    eq[i,j] := subs({x=x[j],y=y[j]},p[i]) = eqti(i,j);
  end do;
end do;
for i from 1 to 3 do: assign(solve({`$`(eq[i,k],k=1..3)},{`$`(a[i,k],k=1..3)})); end do;
> p[1];
   \frac{x_2y_3 + ...}{-x_2y_1 - ....}
 

Then if i do the same, but into a proc with local variables:

a := proc() local p, a, eq, eqti, i, j;
  ... # the above code
  RETURN(p1)
end;
> a(); 
  a_{1,1} + a_{1,2}x + a_{1,3}y

 

But if I use "global p, a, eq, eqti, i, j;" then "> a();" works fine and return somthing like \frac{x_2y_3 + ...}{-x_2y_1 - ....}

This is the problem that i have.

Thanks

I think I explained badly. Probably much better with an example:

I have something like this:

# with(ListTools)...
eqti := (x,y) -> if x = y then 1 else 0 end if;
for i from 1 to 3 do: p[i] := DotProduct([`$`(a[i,j],j=1..3)],[1,x,y]); end do;
for i from 1 to 3 do:
  for j from 1 to 3 do:
    eq[i,j] := subs({x=x[j],y=y[j]},p[i]) = eqti(i,j);
  end do;
end do;
for i from 1 to 3 do: assign(solve({`$`(eq[i,k],k=1..3)},{`$`(a[i,k],k=1..3)})); end do;
> p[1];
   \frac{x_2y_3 + ...}{-x_2y_1 - ....}
 

Then if i do the same, but into a proc with local variables:

a := proc() local p, a, eq, eqti, i, j;
  ... # the above code
  RETURN(p1)
end;
> a(); 
  a_{1,1} + a_{1,2}x + a_{1,3}y

 

But if I use "global p, a, eq, eqti, i, j;" then "> a();" works fine and return somthing like \frac{x_2y_3 + ...}{-x_2y_1 - ....}

This is the problem that i have.

Thanks

Page 1 of 1