herclau

Mr. Hermes Rozsa Iglesias

1038 Reputation

13 Badges

19 years, 273 days

MaplePrimes Activity


These are answers submitted by herclau

Thanks to @Alec Mihailovs , in his reply from Forum, 2005
Sorting with Indices

How to implement this idea for a matrix or universalize to: List, Array, Vector, Matrix

My proposal for a matrix, I hope you guide me for improvement

# proc (M::Matrix)
local m, n, i, MI, MV, TT;
m, n := upperbound(M);
MI := Matrix(m, n);
MV := Matrix(m, n);
for i to n do
TT := ListTools:-Transpose(sort(ListTools:-Enumerate(convert(M[() .. (), i], list)), (a, b) -> a[2] <= b[2]));
MI[() .. (), i] := <(TT[1]>;
MV[() .. (), i] := <TT[2]>;
end do;
return MI, MV
end proc;

Gracias

Tangentlinrev.mw

why the command does not work: _EnvHorizontalName := x,_EnvVerticalName := y ?
And a few lines later asks me the name of the axes

restart;
with(plots); with(plottools);

The circle S with center at the origin and radius 2 is given by the equation x2 + y2 = 4
The circle S have two tangents passing through the point (4, 1). Find the equation for each of them.
x^2+y^2 = 4;

subs(y(x) = y, solve(diff(subs(y = y(x), x^2+y^2 = 4), x), diff(y(x), x)));
y-1 = -x*(x-4)/y;
x^2+y^2 = 4, y-1 = -x*(x-4)/y;

solve({y-1 = -x*(x-4)/y, x^2+y^2 = 4}, {x, y});

allvalues({x = 1-RootOf(17*_Z^2-2*_Z-3), y = 4*RootOf(17*_Z^2-2*_Z-3)});

cp1 := eval([x, y], %[1]);
cp2 := eval([x, y], `%%`[2]);

graph1 := implicitplot(x^2+y^2 = 4, x = -3 .. 3, y = -3 .. 3);
extp := point([4, 1], color = black, symbol = cross, symbolsize = 25);
ccp1 := point(cp1, color = green, symbolsize = 25, symbol = circle);
ccp2 := point(cp2, color = green, symbolsize = 25, symbol = circle);
tl1 := line([4, 1], cp1, color = red, linestyle = solid, color = blue);
tl2 := line([4, 1], cp2, color = red, linestyle = solid, color = blue);

display([graph1, extp, ccp1, ccp2, tl1, tl2]);


with(geometry);
 _EnvHorizontalName := x;_EnvVerticalName := y;

point(Ex, 4, 1), point(A, cp1[1], cp1[2]), point(B, cp2[1], cp2[2]);

line(t1, [Ex, A]);
line(t2, [Ex, B]);
map(detail, [t1, t2]);

Equation(t1);
Equation(t2);

ll1 := implicitplot(Equation(t1), x = -3 .. 5, y = -3 .. 3, color = black);
ll2 := implicitplot(Equation(t2), x = -3 .. 5, y = -3 .. 3, color = black);
display([graph1, extp, ccp1, ccp2, ll1, ll2]);

Gracias

The generation of the matrices A and B are not updated if use in command "!!!".
And it happens with the "!" or executing each line...

It will be possible to know the number of iterations with this procedure? The execution time varies between 0.0015 and 0.047.

> restart:

> randomize(4567890);

> with(LinearAlgebra);

> A := RandomMatrix(4, 4, generator = 10 .. 100);

> B := RandomMatrix(4, 4, generator = -80 .. 20);

> st := time();

 > `~`[is](`~`[`<`](A, B));

> printf("\n     %.3f seconds\n\n", time()-st);     

 0.015 seconds

How about on this?

> restart;

> with(ScientificErrorAnalysis);

> a1 := Quantity(a, dela);           

> ode := diff(y(x), x) = a1*y(x);    
> dsolve({ode, y(0) = 1});

> combine(exp(a1*x), 'errors'); 

               
> expand(GetError(%)/GetValue(%));                                        

 

 

ListTools['MakeUnique']([1, 5, 4, 1, 2, 4, 5, 1, 6]);

or

[op({op([1, 5, 4, 1, 2, 4, 5, 1, 6])})]


It could improve the codes that are highlighted in bold

restart;

deq := diff(y(t), t$2) = y(t)-x(t), diff(x(t), t) = x(t);

init := y(0) = 1, D(y)(0) = 2, x(0) = 3;

Dsolve:=proc (Deq::list)

local vn,A,b,v,vi,X:

vn:=indets(remove(has,Deq[2],diff),name)[1];#take independent variable

A,b:=LinearAlgebra:-GenerateMatrix(rhs~(Deq[1]),lhs~(Deq[2]));

X:=<map2(apply,lhs~(Deq[2]),vn)>;

v:=diff~(X,vn)=A.X-b;

if dat[3]<> 'undefined' then

vi:=eval(X,vn=Deq[3])=<Deq[4]>;

convert(Equate(lhs(v),rhs(v)),set) union convert(Equate(lhs(vi),rhs(vi)),set);

else

convert(Equate(lhs(v),rhs(v)),set);

end if;

end proc:

dat1:=DEtools[convertsys]({deq}, {init}, {x(t), y(t)}, t,Y,YP);

Dsolve(dat1);

dat:=DEtools[convertsys]({deq}, {}, {x(t), y(t)}, t,Y,YP);

Dsolve(dat);

eval(%,dat[2]);

remove(has,%,diff);

{}

odesys_new2.mw

TheStandarFormDESyst.mw

Gracias

I had problem:

 

Dsolve2({deq},{u(0)=2,D(u)(0)=-1},{u(t)},numeric,output=Array([0,0.25,0.5,0.75,1]));

Error, (in is/internal) too many levels of recursion

 

A quick way:

Matrix(3,3,1).A

A/~%

Vector([row]((3,1).%

Ans2.mw

This is the simplest and most versatile I have found recently.
The Matrix, Vector or settlement must be defined as float ¿?.  

> N := 15;
> L := LinearAlgebra[RandomVector](N, datatype = float[8]);  
> ArrayTools[SearchArray](L=~ min(L));  
> ArrayTools[SearchArray](L=~ max(L));  


> b := Matrix(3, 3, [3, 6, 8, 12, 3, 7, 8, 4, 1], datatype = float[8]);  
> x, y := ArrayTools[SearchArray](b=~ max(b))  

> T :=ArrayTools[RandomArray](5, 5, 2, datatype = float[8]);  
> r, c := ArrayTools[SearchArray](T=~max(T));  
> r, c := ArrayTools[SearchArray](T=~min(T));

time_delay_x(n)_vs_y.mw   1
time_delay.mw    2

What I am not implemented correctly?
How to determine the "time delay" between the two signals?
Any help, ride ... please...

gracias

with this procedure I get the values ​​for the last graph shown.

 

xcorr := proc (x, y)
local corrLength, c;
corrLength := op(1, x)+op(1, y)-1;
c := IFFT(FFT(Vector(corrLength, x, fill = 0), normalization = none)*~ conjugate~(FFT(Vector(corrLength, y, fill = 0), normalization = none)), normalization = full);
c := Re~(ArrayTools[CircularShift](c, (1/2)*op(1, c))); 
end proc;

 

http://www.mapleprimes.com/view.aspx?sf=134510/437587/Maple_xcorr.jpg

Which of these is the correct procedure for "time delay" between two signals?

Gracias

other performance

n := Statistics:-Count(X);
DM1 := BandMatrix([[`$`(0, n-2)], [`$`(-1, n-1)], [`$`(1, n-1)]], 1, n-1, n)

evalf[16](Mean(DM1.X))

0.01000000000000000

 idea copied from the forum

> n := 4;

> BandMatrix([[`$`(0, n-2)], [`$`(-1, n-1)], [`$`(1, n-1)]], 1, n-1, n);

[-1  1  0  0]
[ 0 -1  1  0]
[ 0  0 -1  1]

 

Gracias

  @jaytreiman I saw the chart in the document Paper_959_1138_MathC.pdf.  This chart I want to translate into Maple. I'd like to be very similar to the document.

Gracias

1 2 3 4 5 6 7 Last Page 1 of 10