235 Reputation

4 years, 302 days

Simplify presentation...

Maple

Suppose I have a matrix representing a magma such as

matrix(n,n, (i,j)->E[i].E[j])

First, if E is a set of integers then . is converged to * for some reason.

Second, is there any way to simplify the presentation of this matrix? I am using subs to simply but I have to essentially hand code every entry which sort of defeats the purpose. Is there any way to present a matrix and then have the resultant simplified as far as possible?

E.g., subs does not allow one to do something like ?.E[3] = E[2] where ? represents any value. E.g., if I have an identity it would be nice to simplify all elements quickly with one expression rather than having one for all possibilities(essentially 2n).

Also, magma's only let positive integers which seems kinda restrictive(why not create map internally to handle it?).

Also, is there any way to use special chars like -? I'm using d but I'd prefer using special chars so it is visually more congruent to what I'm doing. I realize - is also a minus but maybe there is someway around it(unicode?)?

Bug in maple procedural evaluation?...

Maple

I have a relatively simple procedure that attempts to provide a continuous function from arctan.

This function, when called is not returning values properly for some unknown reason. It is not updating variables.

The code is relatively simple, given a continuous vector valued function it gets the angle using arctan(y,x). The problem with this function is that it is not continuous as it only evaluates the function along the principle branch.

What the function below attempts to do is find out when the function has a jump discontinuility and it provides the amount to shift to make the output continuous. To do this requires some memory which is stored in the global variable l.

vs := t->[cos(3*t), sin(t)];
nvs := t->sqrt(vs(t)[1]^2 + vs(t)[2]^2);
v := t->vs(t); l/~nvs;

l := 0:
ls := [0,0]:
ArgK := proc(f, t)
local e := 0.005, q := 0, y1, y2:
global l, ls:
y1 := evalf(arctan(f(t)[2], f(t)[1]),50);
y2 := evalf(arctan(f(t+e)[2], f(t+e)[1]),50);
if ls[1] = 0 then
if abs(y2 - y1) > 1.5 then l := l - sgn(y2 - y1)*2*Pi; ls := [1,t]: q := 1434: fi;

fi;
#arctan(f(t)[2], f(t)[1]) + l;
[l,q, IF(abs(y2 - y1) > 1.5)];
end proc:

l := 0:
ArgK(v,Pi/2);
ArgK(v,Pi);
([seq([2*Pi*k/10, ArgK(v,2*Pi*k/10)],k=0..10)]);
listplot([seq([2*Pi*k/1000, ArgK(v,2*Pi*k/1000)[1]],k=0..1000)]);

output:

[0, 0, 0]

[2 Pi, 1434, 1]

[                   [1                 ]  [2                 ]
[[0, [2 Pi, 0, 0]], [- Pi, [2 Pi, 0, 0]], [- Pi, [2 Pi, 0, 0]],
[                   [5                 ]  [5                 ]

[3                 ]  [4                 ]
[- Pi, [2 Pi, 0, 0]], [- Pi, [2 Pi, 0, 0]], [Pi, [2 Pi, 0, 1]],
[5                 ]  [5                 ]

[6                 ]  [7                 ]
[- Pi, [2 Pi, 0, 0]], [- Pi, [2 Pi, 0, 0]],
[5                 ]  [5                 ]

[8                 ]  [9                 ]
[- Pi, [2 Pi, 0, 0]], [- Pi, [2 Pi, 0, 0]], [2 Pi, [2 Pi, 0, 0]]
[5                 ]  [5                 ]

]
]
]

The nonsense output is not my fault, copying directly from maple. The main thing is thatat 2pi, the output should be 1434(see 2nd line) but there is no 1434. The output is completely ignored. It seems the correct jump is never calculated properly in the sequence although it works fine manually and has worked before when messing with the code.

e.g., these should be identical

[2 Pi, 1434, 1]

[Pi, [2 Pi, 0, 1]],

yet there is a 0 where there should be a 1434. (I was using q to figure out why the thing was not working)

I've been playign around with the code trying to get it to work but I've not been able to as maple is doing something very funky.  It should be a very simple problem of detecting a jump discontinuility then adding an appropriate amount(which must be tracked).

ls was used because I was getting wierd results around the discontinuity where the test would be called multiple times, I guess because something to do with the evaluation in plotting.

E.g., commenting out the ls if statement will get the step function one epects except it's not the right values.

The idea is simple though. For a continuous function theta(t) one should be able to provide a full and meaningful angle that takes in to account the correct branch when extracting this angle from a continuous function that is known to provide a continuous theta(t). i.e., Ang(f(t)) should be continuous. This is what I'm trying to achieve.

convert series to list with 0's...

Maple

convert(series(f(x),x,10),list) will produce a list with exponents rather than 0's. Is there a natural way to simply get a list with 0 padding? Also, can one make their own type converter?  (obviously I can make a procedure but talking about something in accordance with convert)

Store values in variable outside of proc...

Maple

I have a proc that takes a function. This function is called  when the proc needs it to. Normally it will simply do a computation. The return is generally ignored(since the proc is a bit non-deterministic). I would like, though, to store values computed within the function in a global variable. I can't seem to use assign since it forces the variable to be local.

I can print the result of the function and it shows up but what is the proper way to assign variables within a function:

e.g.,

plot(store(x),x=1..2);

Then store would somehow store the values passed to the function(and in this case probably returning x). The example is not my use case and may not actually work properly.I cannot use global in the function passed as an argument to create a global variable.

F := proc(f)

blah blah f(3)
blah blah f(4)

end proc;

R := []:

F(x->store(R, x));

R = [3,4]

Print points with records...

Maple

Is there a way to print points that have additional information that can be probed when mousing over the points?

I have an array of arrays with information in each element including the point: [x,y1,y2,R1, R2, R3, R4]

Where y1 and y2 are different values to graph per x(different plots)  and Rk are records for the data(other info that goes along with them such as day of week, rainfall on that day, etc). The different graphs might have different scales so it would be nice if they handled scaling effectively(e.g., |y1| < 1 and y2 > 3430).

I have about 50k points so it has to be relatively fast... as it's already taking a few minutes to process the data in to the array from a file using fopen and readline(not sure why so slow as I'm just using a few parses and cats to put it in an array but probably is being slowed by not being able to pre-allocate the array.

 1 2 3 4 5 6 7 Last Page 1 of 16
﻿