pagan

5147 Reputation

23 Badges

17 years, 125 days

 

 

"A map that tried to pin down a sheep trail was just credible,

 but it was an optimistic map that tried to fix a the path made by the wind,

 or a path made across the grass by the shadow of flying birds."

                                                                 - _A Walk through H_, Peter Greenaway

 

MaplePrimes Activity


These are answers submitted by pagan

It appears that your results obtained from using Matlab:-evalM are as if matlabmatrix_a were transposed.

> maplematrix_a := Matrix([[3, 3, 2], [4, 5, 2], [6, 2, 4]]):
> maplematrix_b := Matrix([[3, 2, 5], [1, 8, 2], [7, 3, 4]]):
> maplematrix_a^%T+maplematrix_b;
                                [6     6    11]
                                [             ]
                                [4    13     4]
                                [             ]
                                [9     5     8]
 
> evalf( maplematrix_b^(-1) . maplematrix_a^%T );
              [-0.1616766467    -0.4011976048    -0.1556886228 ]
              [                                                ]
              [0.2455089820     0.4610778443     -0.05988023952]
              [                                                ]
              [0.5988023952     0.8562874251      1.317365269  ]

Oh, wait! What is that extra single quote (') doing following matlabmatrix_a in each evalM example? Isn't that transposing it in Matlab syntax? Is that just an omission, then, in your checkup code?

The following are all OK. Note that applications of sine and cosine have notation like sin(x) and cos(x).
int( (sin(x)^4)*(cos(x)^3), x);

int( (sin(x))^4*(cos(x))^3, x);

int( sin(x)^4*cos(x)^3, x);
> simplify((z^6)^(1/6)) assuming z>0;
                                       z

> simplify((z^6)^(1/6)) assuming z<0;
                                      -z
You are using `e` for the exponent of 10 (scientific notation). That's fine. No need to replace with exp(), as that's not what you mean, I think.

Your R11 and R22 are both assigned as sets (of single equations). So take their union, before passing to `solve`

> solve(R11 union R22);
{p = 1.746167017, t = 0.6508775936}, {p = -95.17280239, t = 65.29557274},

    {p = -25.39084851 + 1.655830988 I, t = 0.5255049158 + 6.920575460 I},

    {p = -25.39084851 - 1.655830988 I, t = 0.5255049158 - 6.920575460 I}

Perhaps it ran out of memory on your machine but not on his machine.

Or perhaps it could not allocate enough memory due to a restriction in your operating system's shell. You might try launching Maple (Standard GUI or commandline interface, your choice) from a commandline terminal window on your Mac. You could first issue `ulimit -d <value>` in that shell, where <value> represented at least as much memory space as was used by Maple in your friends successful run.

Maybe see also here.

You first error comes from treating [matrice,vecteur] as a Matrix. That is just a list. To get an augmented Matrix, do it as Matrix([matrice,vecteur]).

Now, your code has j go all the way to n. But the Matrix is augmented by the rhs Vector, so instead j should go only as high as n-1.

It should start with the bottom (m) row, and move upwards in rows by decreasing i. Your code has i increasing.

You use V[i] in summing up to get resultat. But you may want V[j] instead.

You can pull that assignment to 'a' outside of the inner loop, as it doesn't depend on j.

Making all those changes, I get this. Note that it only works if the leading nonzero entry in the ith row occurs in the ith column. You could refine the procedure to first find the "leading columns". Also, you could be simplifying/normalizing as you compute.

substitutioninverse := proc(matrice, vecteur)
local n, m, j, i, resultat, V, matrice2, a;
 uses LinearAlgebra;
 matrice2 := Matrix([matrice, vecteur]);
 m, n := Dimension(matrice2);
 V := Vector(m);
 for i from m to 1 by -1 do
  resultat := 0;
  for j from n-1 to i by -1 do
   resultat := resultat+matrice2[i, j]*V[j];
  end do;
  V[i] := (matrice2[i, n]-resultat)/matrice2[i, i];
 end do;
 return V
end proc:

M:=Matrix([[a,b,c],[0,d,e],[0,0,f]]):
V:=Vector([11,13,17]);

ans:=substitutioninverse(M,V);

M.ans;

Try looking at this. (Maple 13)

interface(verboseproc=3);
eval(linalg[backsub]);
showstat(linalg[backsub],39..55);
showstat(linalg[backsub],63..74);

The first hit from google for a search on maple rocket equation was this.

It looks like you should also be able to find lots of other relevant links.

The procedure that you wrote acts "in-place" upon the input Matrix. It actually changes the input Matrix.

But maybe that's not what you want. Maybe, instead, you want it to have "copy" rather than "in-place" semantics. If that is so, then you should create a copy of input argument 'matrice', and act on that and return that.

Or, you can create a more interesting procedure that does either inplace or copy operation, according to an optional argument.

> rowoperation := proc(matrice, i, j)
> local m, n, k;
>   uses LinearAlgebra;
>   m, n := Dimension(matrice);
>   for k to n do
>   matrice[j, k] := r*matrice[i, k]+matrice[j, k]
>   end do;
>   matrice;
> end proc:
>
> M := Matrix([[a,b],[c,d]]):
>
> rowoperation(M,1,2);
                             [   a          b   ]
                             [                  ]
                             [r a + c    r b + d]

>
> M; # it is changed
                             [   a          b   ]
                             [                  ]
                             [r a + c    r b + d]

>
> newrowoperation := proc(origmatrice, i, j)
> local m, n, k, matrice;
>   uses LinearAlgebra;
>   matrice:=copy(origmatrice);
>   m, n := Dimension(matrice);
>   for k to n do
>   matrice[j, k] := r*matrice[i, k]+matrice[j, k]
>   end do;
>   matrice;
> end proc:
>
> M := Matrix([[a,b],[c,d]]):
>
> newrowoperation(M,1,2);
                             [   a          b   ]
                             [                  ]
                             [r a + c    r b + d]

>
> M; # it is not changed
                                   [a    b]
                                   [      ]
                                   [c    d]

>
> coolrowoperation := proc(origmatrice, i, j,
>                         {inplace::truefalse:=false})
> local m, n, k, matrice;
>   uses LinearAlgebra;
>   if inplace then
>     matrice:=origmatrice;
>   else
>     matrice:=copy(origmatrice);
>   end if;
>   m, n := Dimension(matrice);
>   for k to n do
>   matrice[j, k] := r*matrice[i, k]+matrice[j, k]
>   end do;
>   matrice;
> end proc:
>
>
> M := Matrix([[a,b],[c,d]]):
>
> coolrowoperation(M,1,2); # default is copy, not inplace
                             [   a          b   ]
                             [                  ]
                             [r a + c    r b + d]

>
> M;
                                   [a    b]
                                   [      ]
                                   [c    d]

>
> coolrowoperation(M,1,2,inplace=true);
                             [   a          b   ]
                             [                  ]
                             [r a + c    r b + d]

>
> M;
                             [   a          b   ]
                             [                  ]
                             [r a + c    r b + d]

Do either of these things.

Add a new last line inside your procedure, which is simply,

matrice

Or, add a new line inside your procedure, following the computational part of your procedure, which is simply,

return matrice

In the component properties for Plot0, toggle the checkbox titled, `Make "execute code" the default manipulator'.

Then, right-click on Plot0 and go to the context-menu item near the botton labelled, Manipulator. Click that to get its choices. Set the manipulator to Click and Drag.

With the set up as you described it, and after making the above changes, then single left-clicking on the Plot0 window would update the plot to match whatever formula was in the rhs of the equation in the container Math.

Of course, merely moving either slider does not update the plot, as the action was associated with clicking on the Plot component. In your scheme, you have to click on the Plot component in order to get its associated action.

If you wanted the plot to automatically change whenever either slider was moved, then you might try editing the action associated with that slider.

nb. I correct a small typo of ths to rhs.

A more basic question is: how to get Product(exp(...),k=1..n) to exp(Sum(...,k=1..n))? For finite and explicit posint n, you could use `combine`.

Once some method to do that is known, it might possibly be applied to get the desired result directly.

But did you want to be more careful with the indices? The index k was used twice, without being declared local to Liklihood.

> F:=t->exp(Sum(ln(op(1,t)),op(2,t)));
                  F := t -> exp(Sum(ln(op(1, t)), op(2, t)))
 
> T:=Product(exp(-(rr(k)^2+ii(k)^2)/Sum(rr(kk)^2+ii(kk)^2,kk=1..n)*n),k=1..n);
                        n
                     --------'                2        2
                    '  |  |             (rr(k)  + ii(k) ) n
               T :=    |  |    exp(- --------------------------)
                       |  |            n
                       |  |          -----
                      k = 1           \            2         2
                                       )    (rr(kk)  + ii(kk) )
                                      /
                                     -----
                                     kk = 1
 
> simplify(subsindets(T,specfunc(anything,Product),F),symbolic);
                                    exp(-n)

For this example, radnormal gets it.

> restart:
> Q := x* 2500/(2+3*6^(1/2))^2/(3*6^(1/2)-2)^2:
> radnormal(Q);
                                       x
 
> restart:
> Q := x* 2500/(2+3*6^(1/2))^2/(3*6^(1/2)-2)^2:
> evala(Normal(Q));
                                       x

> restart:
> Q := x* 2500/(2+3*6^(1/2))^2/(3*6^(1/2)-2)^2:
> Algebraic:-Normal(Q);
                                       x

Joe's comments will likely be very useful to you as you learn to program in Maple.

There is also the ArrayTools:-AddAlongDimension command.

This sort of thing can sometimes be done using extra condtions.

> f := x -> x^2-1:

> solve( {f(x)=0, x>0}, x);
                                    {x = 1}

> solve( {f(x)=0, x<0 or x>0}, x);
                               {x = 1}, {x = -1}

> restart:

> f := x -> x*(x^2-1);
                                           2
                             f := x -> x (x  - 1)

> solve(f(x)=0,x);
                                   0, 1, -1

> solve({f(x)=0,x<>0},x);
                               {x = 1}, {x = -1}

> solve({f(x)=0,x<0 or x>0},x);
                               {x = 1}, {x = -1}

One type of situation in which this can occur is when `is` uses floating-point evaluation to make the test, and when the unsimplified expression suffers from round-off error but the simplified instance does not.

There can be several "Maple-isms" at play, either alone or  together: Procedure arguments are not always simplified (to avoid costly runaway scenarios as the default behaviour). Digits specifies working precision and not accuracy, for floating-point evaluation of compound expressions.

Other scenarios can involve simplifications not handled by just `normal`. (Recall that equality-testing is similar to zero-testing, and  in general has the same theoretical restrictions.)

> restart:
> expr1:=sqrt(2)*sqrt(3)*cos(x)^2+sqrt(6)*sin(x)^2:
> expr2:=simplify(expr1);
                                        1/2  1/2
                              expr2 := 2    3

> is(expr1=expr2);
                                     false

> is(simplify(expr1)=expr2);
                                     true

Now, you might ask why doesn't `is` respect and utilize Normalizer? You might also notice that `is` uses remember tables (which unfortunately may not be careful enough about changes to Digits).

First 38 39 40 41 42 43 44 Last Page 40 of 48