nm

10436 Reputation

19 Badges

12 years, 192 days

MaplePrimes Activity


These are answers submitted by nm

one way

sol := (-v + sqrt(-4*a^2*R^2 + v^2))/(2*a*omega*L);
expand(sol);
map(X->`if`( hastype(X,'anything'^(1/2)),sqrt(X^2),X),%)

Another using pattern matching

sol := (-v + sqrt(-4*a^2*R^2 + v^2))/(2*a*omega*L);
f:=proc(x)
local a,b,c,la;
if patmatch(x,b::nonunit(anything)*sqrt(a::nonunit(anything)),'la') then
   assign(la);
   RETURN(sqrt(a*b^2));
else
   RETURN(x);
fi;
end proc;
map(X->f(X),expand(sol));

note that in all the above,  sqrt(a)/b is same as sqrt(a/b^2) assuming b>0

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.

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

30960

u1 := RootOf(4*_Z^2 + (4*RootOf(60*_Z^3 - 60*_Z^2 + 15*_Z - 1) - 4)*_Z + 4*RootOf(60*_Z^3 - 60*_Z^2 + 15*_Z - 1)^2 - 4*RootOf(60*_Z^3 - 60*_Z^2 + 15*_Z - 1) + 1)

RootOf(4*_Z^2+(4*RootOf(60*_Z^3-60*_Z^2+15*_Z-1)-4)*_Z+4*RootOf(60*_Z^3-60*_Z^2+15*_Z-1)^2-4*RootOf(60*_Z^3-60*_Z^2+15*_Z-1)+1)

DEtools:-remove_RootOf(u1):
result:=[allvalues(%)]:
map(X->simplify(convert(X,trig)),result);

[(2/9)*(cos((1/3)*arctan(3/4))+1)*(3^(1/2)*sin((1/3)*arctan(3/4))-cos((1/3)*arctan(3/4))+2) = 0, -(2/9)*(cos((1/3)*arctan(3/4))+1)*(3^(1/2)*sin((1/3)*arctan(3/4))+cos((1/3)*arctan(3/4))-2) = 0, (1/9)*(2*cos((1/3)*arctan(3/4))-1)^2 = 0]

 

Download A.mw

see Improving-Phaseplot-For-System-Of-Odes for reference. There is no function which gives exactly as StreamPlot in Maple, but DEtools:-DEplot gets close. The difference is that in Mathematica the arrows follow each others along one stream, but in Maple they are disconnected. i.e. where one arrow ends, is not same location where the next arrow starts.

This makes Mathematica's output a little more pleasing to look at than Maple's IMNSHO.

ode=y'[x]==y[x]-x
f[x_,y_]:=y-x
p1=StreamPlot[{1,f[x,y]},{x,-5,6},{y,-4,3},
           Frame->False,Axes->True,AspectRatio->1/GoldenRatio,
           AxesLabel->{"x","y(x)"},BaseStyle->12]

restart;

ode:=diff(y(x),x)=y(x)-x;

DEtools:-DEplot(ode,[y(x)],x=-5..6,y = -4..3,arrows=curve,linecolor=red,
                  color='magnitude[legacy]',scene=[x,y(x)],
                  font=[TIMES,12], labelfont=[TIMES,16],size=[default,0.618034]);

 

One can change arrowsize, to make it look closer to Mathematica. But hard to pick the correct value each time.

restart;
ode:=diff(y(x),x)=y(x)-x;

DEtools:-DEplot(ode,y(x),x=-5..6,y = -4.