Joe Riel

9660 Reputation

23 Badges

20 years, 5 days

MaplePrimes Activity


These are answers submitted by Joe Riel

Because your input is cylic, you can use a moving average without losing any points.

pts := [[1, 1], [3, 2], [3.5, 4], [4, 6], [5, 5], [6, 7], [7, 6], [8, 5], [9, 5.5], [10, 4], [11, 1], [12, -5], [11.5, -6], [12, -12], [10, -10], [8, -14], [7, -10], [3, -10], [2, -5], [1, -8], [0, 0], [1, 1]]:

x := op~(1,pts):
y := op~(2,pts):

n := nops(pts):
m := 5:
use Statistics in
x1 := MovingAverage([x[],x[2..m][]], m)[1..n];
y1 := MovingAverage([y[],y[2..m][]], m)[1..n];
end use:

pts1 := `[]`~(x1,y1):

plt1 := plot(pts):
plt2 := plot(pts1, color=blue):

plots:-display(plt1,plt2);

Try restarting Maple.  Those commands work fine for me.

You can use ?TypeTools[AddType] to create a new type. One way to do that is to specify a particular attribute for the Matrix. Thus

TypeTools:-AddType('MyMatrix', 'Matrix(attributes=[MyMatrix])'):

NewAdd := module()
option package;
export `+`;
    `+` := overload([proc(a::MyMatrix, b::MyMatrix)
                     local M;
                     option overload;
                         M := Matrix([[a[1,1]], [:-`+`(a[2,1],b[2,1])]], 'attributes=[MyMatrix]');
                         if _npassed > 2 then
                             return procname(M,_rest);
                         else
                             return M;
                         end if;
                     end proc,
                     proc(a::procedure, b::procedure)
                     option overload;
                         proc(V) `+`(a(V),b(V)) end proc
                     end proc
                    ]
                   );
end module:

A := Matrix([[1,2],[3,4]], 'attributes=[MyMatrix]'):
B := Matrix([[1,2],[3,4]]);
with(NewAdd);

A+A;
                                      [1]
                                      [ ]
                                      [6]

B+B;
                                   [2    4]
                                   [      ]
                                   [6    8]

`+`(A,A,A);
                                      [1]
                                      [ ]
                                      [9]


Note that the `+` procedure was extended to be n-ary (for n >= 2). 

Square brackets are not algebraic parentheses in Maple.  Use parentheses and it works fine.

Followup: actually, that doesn't take you out of the woods.  Maple generates the procedure, however, there is a problem at the initial point.  You can see that with

deq := (2*.1)*((y(t)*(diff(y(t), t, t))-1)*(1+(diff(y(t), t))^2)^(3/2)-y(t)*(diff(y(t), t))^2*(diff(y(t), t, t))*sqrt(1+(diff(y(t), t))^2))-2*sin(t)*(1+(diff(y(t), t))^2)^2 = 0:
ini := {y(0) = 0, (D(y))(0) = 0}:
eval(subs(t=0, ini, convert(deq,D)));
                                   -0.2 = 0

There is no general solution unless A and V are orthogonal.  To see that, let A lie on the z-axis and V lie in the x=0 plane.  Then

with(VectorCalculus):

A := Vector([0,0,a3]):
V := Vector([0,v2,v3]):
W := Vector([w1,w2,0]):

WxV := W &x V:
ex := WxV * (A.A) - A*(WxV.WxV):
eqs := convert(ex,set) union {W.W=Wmag^2}:
solve(eqs, {w1,w2,v3});
{v3 = 0, w1 = 0, w2 = Wmag}, {v3 = 0, w1 = 0, w2 = -Wmag},

                                      2       2   2     2
                   a3        RootOf(a3  - Wmag  v2  + _Z )
    {v3 = 0, w1 = ----, w2 = -----------------------------}
                   v2                     v2

This works

NewAdd := module()
option package;
export `+`;
    `+` := overload([proc(a::Matrix, b::Matrix)
                     option overload;
                         Matrix([[a[1,1]], [:-`+`(a[2,1], b[2,1])]])
                     end proc,
                     proc(a::procedure, b::procedure)
                     option overload;
                         proc(V) `+`(a(V),b(V)) end proc
                     end proc
                    ]
                   );
end module:

A  := proc(v::Matrix) Matrix([[v[1,1]-1],[v[2,1]]]); end proc:
At := proc(v::Matrix) Matrix([[v[1,1]+1],[v[2,1]]]); end proc:

with(NewAdd);
                                      [+]


V1:=Matrix([[a],[b]]);
                                         [a]
                                   V1 := [ ]
                                         [b]


A(V1)+At(V1);
                                    [a - 1]
                                    [     ]
                                    [ 2 b ]

(A+At)(V1);  
                                    [a - 1]
                                    [     ]
                                    [ 2 b ]
 a:=[class,23,45,74,34,25,76,class,55,67,78,34,65,12,23,45,64,23,class,12,13,15,class,99,98,97,59 ]:    
 ListTools:-Split(type,a, name);                 
                [], [23, 45, 74, 34, 25, 76], [55, 67, 78, 34, 65, 12, 23, 45, 64, 23], [12, 13, 15], [99, 98, 97, 59]


While Maple shouldn't be crashing, the proximate cause is that Lines is invalid.  I suspect you want

Lines:=map(spacecurve, [L1,L2,L3], t=-2..2);

and then (later)

display(A,Lines[]);

A somewhat more sophisticated approach is to note that if you translate one of the vertices of the tetrahedron to the origin of a Euclidean space, then there is a linear transformation of the unit simplex to the tetrahedron.  Consequently, the volume of the tetrahedron equals the volume of the unit simplex (1/6) multiplied by the determinate of the linear transformation.  The matrix of the linear transformation is easily found, its columns are the three vectors that correspond to the edges extending from the origin of the translated tetrahedron. 

So, if the vertices are the vectors V1, V2, V3, V4, then

M := < V2-V1 | V3-V1 | V4-V1>: # matrix of linear transformation
vol := LinearAlgebra:-Determinant(M)/6:

You may have to take the absolute value if the transformation doesn't preserve orientation

Note that the approximation is only good for small alpha.

The usual way to do that is with zip,

 zip((x,y)->[x[],y], a,b);
                  [[a1, a2, b1], [a3, a4, b2], [a5, a6, b3]]

An interesting alternative is

use T = ListTools:-Transpose in 
   T([T(a)[],b])
end use;
                  [[a1, a2, b1], [a3, a4, b2], [a5, a6, b3]]

Consider the specialization

X1 := RandomVariable(Geometric(1/2)):
Sample(X1, 10);
                                  [4., 0., 1., 0., 1., 0., 1., 0., 0., 2.]

Note that 0 is a valid sample.  ln(0) is undefined, so Mean(ln(X1)) is also undefined.

I had modified your code to correct what may be the issue, but that led to the problem of g5, which I forget to confirm existed in the original, it doesn't, at least not identically.

Here's what I noticed.  When using assumption it is generally necessary to apply them before creating expressions that use the variable, otherwise those expressions get the "unassumed" variable which is different from the variable with assumptions.  To avoid that, I moved your assumptions to the start of the script.  When that is done, I get

indets([{mu = Mean(Y5), sigma^2 = Variance(Y5)},{c,b}]);
                                   {b, c, c, mu, sigma}

Note that c appears twice.  Those correspond to different variables, albeit with the same apparent name. I haven't looked closer, but believe the immediate problem is coming from the use of

assume(GAMMA((1/2)*c) > 0, 0 < sqrt(2^c*GAMMA((3/2)*c)*GAMMA((1/2)*c))*sigma/(2^c*GAMMA((3/2)*c))):

 

Insert all the values into a Matrix, say, M, then create the spreadsheet with ExcelTools:-Export(M, "mydata.xls");

Don't use square brackets as parentheses, they do not act that way in Maple.  Also, use Pi instead of pi.

First 65 66 67 68 69 70 71 Last Page 67 of 114