nm

8679 Reputation

19 Badges

11 years, 274 days

MaplePrimes Activity


These are answers submitted by nm

may be there is better way, but try

r:=[[5,7],[],[1,3],[],[5,4]];
select(X->nops(X)>0,r)

Yes, this happens, but the important thing is that the corresponding order with the correct eigenvalue do not change.

i.e the way to read the outout is that the first eigenvalue goes with the first column, the second eigenvalue goes with the second column and so on.

So it does not matter if the eigenvector columns change positions, as long the the corresponding eigenvalues change in same way

 

btw, if you for some reason need to have same order of eigenvectors each time, you could always sort the eigenvector matrix columns using the numerical values of the corresponding eigenvalues as key for sorting. Something like

23920

LI:=LinearAlgebra;
M:=Matrix([[0,1],[1,0]]);

LI := LinearAlgebra

Matrix(%id = 36893490698467268956)

a,b:=LI:-Eigenvectors(M):
b[.., sort(a,output=permutation)]

Matrix(2, 2, {(1, 1) = -1, (1, 2) = 1, (2, 1) = 1, (2, 2) = 1})

a,b:=LI:-Eigenvectors(M):
b[.., sort(a,output=permutation)]

Matrix(2, 2, {(1, 1) = -1, (1, 2) = 1, (2, 1) = 1, (2, 2) = 1})

a,b:=LI:-Eigenvectors(M):
b[.., sort(a,output=permutation)]

Matrix(2, 2, {(1, 1) = -1, (1, 2) = 1, (2, 1) = 1, (2, 2) = 1})

a,b:=LI:-Eigenvectors(M):
b[.., sort(a,output=permutation)]

Matrix(2, 2, {(1, 1) = -1, (1, 2) = 1, (2, 1) = 1, (2, 2) = 1})

a,b:=LI:-Eigenvectors(M):
b[.., sort(a,output=permutation)]

Matrix(2, 2, {(1, 1) = -1, (1, 2) = 1, (2, 1) = 1, (2, 2) = 1})

a,b:=LI:-Eigenvectors(M):
b[.., sort(a,output=permutation)]

Matrix(2, 2, {(1, 1) = -1, (1, 2) = 1, (2, 1) = 1, (2, 2) = 1})

 

 

Download sorted_V.mw

Maple 2024

I have feeling there is a better or more direct way to do this but could not find it so far. But here is an attempt

Opps. Fix to make true matrix

R:=Vector[row]([1,2,3]);
C:=Vector([d,e,f]);
convert(convert(map(X->X*C,R),listlist),Matrix);
whattype(%);
LinearAlgebra:-Dimension(%%);

 

You should really post plain text code. One can't copy code from image. But you can try

sol:=signum(-sigma+q)^2;
simplify(sol) assuming real;

You should really post plain text code next time or at least worksheet.

I tried this in Maple 2024 and Mathematica 14. Both give solution that validate.  Here is Maple's

ode1:= diff(c(T),T)=-2*c(T)*(1+beta__c*c(T)^2/p__c(T)^2);
ode2:= diff(p__c(T),T)=2*(1+beta__c*c(T)^2/p__c(T)^2)*p__c(T);
sol:=[dsolve([ode1,ode2],[c(T),p__c(T)],'explicit')]


 

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

restart;

212532

ode1:= diff(c(T),T)=-2*c(T)*(1+beta__c*c(T)^2/p__c(T)^2);
ode2:= diff(p__c(T),T)=2*(1+beta__c*c(T)^2/p__c(T)^2)*p__c(T);
sol:=[dsolve([ode1,ode2],[c(T),p__c(T)],'explicit')]

diff(c(T), T) = -2*c(T)*(1+beta__c*c(T)^2/p__c(T)^2)

diff(p__c(T), T) = 2*(1+beta__c*c(T)^2/p__c(T)^2)*p__c(T)

[{c(T) = -(1/2)*64^(1/2)*(beta__c*c__2/(8*c__1*(exp(T))^8+64*c__2)^(1/2))^(1/2)/beta__c, p__c(T) = -((1/2)*I)*(8*c__1*(exp(T))^8+64*c__2)^(1/4)}, {c(T) = (1/2)*64^(1/2)*(beta__c*c__2/(8*c__1*(exp(T))^8+64*c__2)^(1/2))^(1/2)/beta__c, p__c(T) = -((1/2)*I)*(8*c__1*(exp(T))^8+64*c__2)^(1/4)}, {c(T) = -(1/2)*64^(1/2)*(beta__c*c__2/(8*c__1*(exp(T))^8+64*c__2)^(1/2))^(1/2)/beta__c, p__c(T) = ((1/2)*I)*(8*c__1*(exp(T))^8+64*c__2)^(1/4)}, {c(T) = (1/2)*64^(1/2)*(beta__c*c__2/(8*c__1*(exp(T))^8+64*c__2)^(1/2))^(1/2)/beta__c, p__c(T) = ((1/2)*I)*(8*c__1*(exp(T))^8+64*c__2)^(1/4)}, {c(T) = -2*(-2*beta__c*c__2/(2*c__1*(exp(T))^8+16*c__2)^(1/2))^(1/2)/beta__c, p__c(T) = -(1/2)*(8*c__1*(exp(T))^8+64*c__2)^(1/4)}, {c(T) = (1/2)*(-64*beta__c*c__2/(8*c__1*(exp(T))^8+64*c__2)^(1/2))^(1/2)/beta__c, p__c(T) = -(1/2)*(8*c__1*(exp(T))^8+64*c__2)^(1/4)}, {c(T) = -2*(-2*beta__c*c__2/(2*c__1*(exp(T))^8+16*c__2)^(1/2))^(1/2)/beta__c, p__c(T) = (1/2)*(8*c__1*(exp(T))^8+64*c__2)^(1/4)}, {c(T) = (1/2)*(-64*beta__c*c__2/(8*c__1*(exp(T))^8+64*c__2)^(1/2))^(1/2)/beta__c, p__c(T) = (1/2)*(8*c__1*(exp(T))^8+64*c__2)^(1/4)}]

map(X->odetest(X,[ode1,ode2]),sol)

[[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]

 


 

Download it_works_for_me.mw

Here is Mathematica code I tried.

ClearAll["Global`*"]
ode1 = c'[T] == -2*c[T]*(1 + \[Beta]*c[T]^2/pc[T]^2);
ode2 = pc'[T] == 2*(1 + \[Beta]*c[T]^2/pc[T]^2)*pc[T];
sol = DSolve[{ode1, ode2}, {c, pc}, T]

Solution also verifies OK

Since both solutions from Maple and Mathematica verfiy OK, then both are correct even though they look different. 

set has no implied ordering. So need to use list.  Here is one way out of many

X:=[x12, x1, x3, x15, x2, x9];

f:=proc(a,b)::truefalse;
     :-parse(String(a)[2..]) < :-parse(String(b)[2..]) ;
end proc:

sort(X,f);

may be

n:=294912:
d:=8:
eq:=d^m=n/2:
floor(solve(eq,m)):
n/(d^%);

        9

This assume n is even 

You can easily modify it for odd

 

Need to tell is x is not negative

 

simplify(g(f(x))) assuming x>=0

                 x

 

This is a guess. When expression is product, such as a*b internally it is   a^1*b^1  so  when you do subs 1=2 you get a^2*b^2. It replaced the exponents by 2.

same for division. You can see this from

subs(1=2,a*b^9)

           a^2*b^9

And 

dismantle(a*b)

PROD(5)
   NAME(4): a
   INTPOS(2): 1  ------->
   NAME(4): b
   INTPOS(2): 1  ----->

 

Compare to 

dismantle(a*b^9)

PROD(5)
   NAME(4): a
   INTPOS(2): 1   --->
   NAME(4): b
   INTPOS(2): 9   ---->

 

So internally for a  PROD   , each term has hidden exponent of by default unless overriden.

 

For SUM, the same thing. There is a hidden or implied  `1`. You can see this from

dismantle( a + b);

SUM(5)
   NAME(4): a
   INTPOS(2): 1 --->
   NAME(4): b
   INTPOS(2): 1  --->

 

Compare to 

dismantle( a + 9*b);

SUM(5)
   NAME(4): a
   INTPOS(2): 1  ------->
   NAME(4): b
   INTPOS(2): 9  ------->1

 

So when you do 

subs(1=2,a+b)

It is as if  you typed

subs(1=2, 1*a+ 1*b)

And that is why you get 

          2*a + 2*b

It is by design. This is called "infinite scroll"

Google search also introduced this not long ago on its search result. It is terrible feature and Maplesoft seems to copy this. 

Google Infinite Scroll keeps loading new results as you scroll down the page.

Many web sites seem to imitate this now. 

I much prefer the old way. One page at a time, and click next page to see the next page of result.

I could not find a way to turn it off from google search result.

For Maple's page above, you'd have to ask Maplesoft if they can turn off Infinite Scroll as it is part of the page design and they are the ones who add the javascript in the page to control this.

Outside users has no control as far as I can see on how to prevent Infinite Scroll

So what you see as repositions arbitrarily. is actually a side effect of this automatic scrolling. If not done right, it looks like what you describe and I've seen this in many other sites.

It also makes one lose track of what they were looking on the page when this happens.

The web is a big mess and Maplesoft is just following the trend.

another possibility

e:=(10*(5+sqrt(41)))/(sqrt(70+10*sqrt(41))*sqrt(130+10*sqrt(41)));
simplify(numer(e)/expand(combine(denom(e))))

btw, Mathematica does it with FullSimplify command. 

another possibility

A := LinearAlgebra:-RandomMatrix(5);
Vector~(convert(A^+,listlist))[]

use assumptions

int((t/a)*exp(-t/a),t=0..infinity) ;
simplify(%) assuming a>0

Unable to upload worksheet. here is screen shot

Here is another approach

find_element:=proc(e,L::list)
 local idx;
 idx:=ListTools:-Search(e,L);
 if idx=0 then
    RETURN([]);
 elif idx=nops(L) then
      RETURN([L[idx]]);
 else
      RETURN(L[idx+1..-1]);
 fi;
end proc;


is_in_order:=proc(N::list,lis::list)::truefalse;
    local final_result::truefalse:=true;
    local item,r::list:=lis;
    for item in N do 
       r:=find_element(item,r);
       if nops(r)=0 then
          final_result:=false;
          break;
       fi;
   od:
   RETURN(final_result);
end proc:

and now

         is_in_order([7,2,4],[2,6,5,7,3,2,9,4])
                              true

        is_in_order([7,2,4],[2,1,4,2,6,7,3,9])
                            false

        is_in_order([7,2,4],[7,4,2,7,2,4])
                           
true

        is_in_order([7,2,4],[7,7,7,7,2,2,2,7,4])
                           
true

Yes, a bug. Seems it went wrong in integration somewhere.

These are two temporary workarounds .

One is to use `useint`

Second is to replace (Heaviside(t-1)-Heaviside(t-2) with (Heaviside(t-a)-Heaviside(t-b) and then replace a=1 and b=2 back in the solution.

Both of these give same exact result, but with unresolved integral in the solution.  But at least they do not give y=0 as solution. Maple could not integrate this integral.

You might want to report this hopefully this will be fixed in future version.

23912

restart;

23912

F := (t-1)*(t-2)/(t^2+1)^3*(Heaviside(t-a)-Heaviside(t-b));
ode := diff(y(t),t,t) + diff(y(t),t) = F;
ic := y(0)=0, D(y)(0)=0;
sol:=dsolve([ode,ic]);

(t-1)*(t-2)*(Heaviside(t-a)-Heaviside(t-b))/(t^2+1)^3

diff(diff(y(t), t), t)+diff(y(t), t) = (t-1)*(t-2)*(Heaviside(t-a)-Heaviside(t-b))/(t^2+1)^3

y(0) = 0, (D(y))(0) = 0

y(t) = -(Int((Int(exp(_z1)*(_z1-1)*(_z1-2)*(Heaviside(-_z1+a)-Heaviside(-_z1+b))/(_z1^2+1)^3, _z1 = 0 .. _z1))*exp(-_z1), _z1 = 0 .. t))

simplify(value(eval(sol,[a=1,b=2])))

y(t) = -(1/80)*(int(((20-15*I)*(Heaviside(_z1-2)-Heaviside(_z1-1))*exp(-_z1-I)*(_z1^2+1)^2*Ei(1, -_z1-I)+(-20+15*I)*(Ei(1, -2-I)*Heaviside(_z1-2)-Ei(1, -1-I)*Heaviside(_z1-1))*(_z1^2+1)^2*exp(-_z1-I)+(20+15*I)*(Heaviside(_z1-2)-Heaviside(_z1-1))*exp(-_z1+I)*(_z1^2+1)^2*Ei(1, -_z1+I)+(-20-15*I)*(Ei(1, -2+I)*Heaviside(_z1-2)-Ei(1, -1+I)*Heaviside(_z1-1))*(_z1^2+1)^2*exp(-_z1+I)+45*Heaviside(_z1-1)*(_z1^2+1)^2*exp(-_z1+1)-22*Heaviside(_z1-2)*(_z1^2+1)^2*exp(-_z1+2)+40*(Heaviside(_z1-2)-Heaviside(_z1-1))*(_z1^3+(1/4)*_z1^2+(3/2)*_z1+7/4))/(_z1^2+1)^2, _z1 = 0 .. t))

F := (t-1)*(t-2)/(t^2+1)^3*(Heaviside(t-2)-Heaviside(t-1));
ode := diff(y(t),t,t) + diff(y(t),t) = F;
dsolve([ode,ic],useint);

(t-1)*(t-2)*(Heaviside(t-2)-Heaviside(t-1))/(t^2+1)^3

diff(diff(y(t), t), t)+diff(y(t), t) = (t-1)*(t-2)*(Heaviside(t-2)-Heaviside(t-1))/(t^2+1)^3

y(t) = (1/80)*(Int(((20-15*I)*(Heaviside(_z1-2)-Heaviside(_z1-1))*exp(-_z1-I)*(_z1^2+1)^2*Ei(1, -_z1-I)+(-20+15*I)*(Ei(1, -2-I)*Heaviside(_z1-2)-Ei(1, -1-I)*Heaviside(_z1-1))*(_z1^2+1)^2*exp(-_z1-I)+(20+15*I)*(Heaviside(_z1-2)-Heaviside(_z1-1))*exp(-_z1+I)*(_z1^2+1)^2*Ei(1, -_z1+I)+(-20-15*I)*(Ei(1, -2+I)*Heaviside(_z1-2)-Ei(1, -1+I)*Heaviside(_z1-1))*(_z1^2+1)^2*exp(-_z1+I)+45*Heaviside(_z1-1)*(_z1^2+1)^2*exp(-_z1+1)-22*Heaviside(_z1-2)*(_z1^2+1)^2*exp(-_z1+2)+40*(Heaviside(_z1-2)-Heaviside(_z1-1))*(_z1^3+(1/4)*_z1^2+(3/2)*_z1+7/4))/(_z1^2+1)^2, _z1 = 0 .. t))

F := (t-1)*(t-2)/(t^2+1)^3*(Heaviside(t-2)-Heaviside(t-1));
ode := diff(y(t),t,t) + diff(y(t),t) = F;
ic := y(0)=0, D(y)(0)=0;
dsolve([ode,ic], y(t),method='laplace');

(t-1)*(t-2)*(Heaviside(t-2)-Heaviside(t-1))/(t^2+1)^3

diff(diff(y(t), t), t)+diff(y(t), t) = (t-1)*(t-2)*(Heaviside(t-2)-Heaviside(t-1))/(t^2+1)^3

y(0) = 0, (D(y))(0) = 0

y(t) = (1/80)*(-2*Heaviside(t-2)*(16*t^2-15*t+21)+5*Heaviside(t-1)*(11*t^2-6*t+13))/(t^2+1)+(7/8)*arctan(t)*(Heaviside(t-2)-Heaviside(t-1))+(1/4-(3/16)*I)*(Heaviside(t-2)*(Ei(1, -2-I)-Ei(1, -t-I))+(-Ei(1, -1-I)+Ei(1, -t-I))*Heaviside(t-1))*exp(-t-I)+(1/4+(3/16)*I)*(Heaviside(t-2)*(Ei(1, -2+I)-Ei(1, -t+I))+(-Ei(1, -1+I)+Ei(1, -t+I))*Heaviside(t-1))*exp(-t+I)-(1/40)*Heaviside(t-2)*(-11*exp(-t+2)+35*arctan(2))+(1/32)*Heaviside(t-1)*(-18*exp(-t+1)+7*Pi)

odetest(y(t)=0,[ode,ic])

[(-Heaviside(t-2)*t^2+Heaviside(t-1)*t^2+3*Heaviside(t-2)*t-3*Heaviside(t-1)*t-2*Heaviside(t-2)+2*Heaviside(t-1))/(t^2+1)^3, 0, 0]

To see why it gave zero, we can replace initial conditions by unknown values instead of zero

F := (t-1)*(t-2)/(t^2+1)^3*(Heaviside(t-1)-Heaviside(t-2));
ode := diff(y(t),t,t) + diff(y(t),t) = F;
ic := y(0)=a, D(y)(0)=b;
sol:=dsolve([ode,ic]);

and now it gives

Which is zero when b and a are zero which is the case in the original input.

Download feb_20_2024.mw

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