Preben Alsholm

13728 Reputation

22 Badges

20 years, 250 days

MaplePrimes Activity


These are replies submitted by Preben Alsholm

xhimi 0

You say that you have a bunch of matrices. Why not just find all the eigenspaces and then use IntersectionBasis in one call?

@Preben Alsholm  I tried to move your reply to my answer to where it belongs, but it appears as my reply.

xhimi 0  WROTE:

Thanks a lot!

 I have tried the intersection basis but I am not not able to have a procedure that does both processes at the same time, i.e., finding the eigenspace and then recursively intersecting. HELP PLEASE!

Could you give us an actual example? I don't quite understand what you are trying to say.

Obviously the equation LambertW(ln(s)) = ln(z) doesn't have s=1 as a solution generically, i.e unless z=1, since
eval(LambertW(ln(s)) = ln(z), s=1) returns 0=ln(z). So I see that as a bug.
It is strange that occasionally that error occurs.
I tried
for sym in {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,x,y,z} do solve({LambertW(ln(zz)) = ln(sym)}, zz) end do;
and didn't see any problems, though.
##Added: I also tried:
for sym in {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,t,u,v,x,y,z} do solve({LambertW(ln(s)) = ln(sym)}, s) end do;
which exhibited the error for sym= t,u,v,x,y,z.
It so happens that t,u,v,x,y,z all follow after s in the alphabet.
## Suspicion confirmed by now lettin g be the unknown:
for sym in {a,b,c,d,e,f,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,x,y,z} do solve({LambertW(ln(g)) = ln(sym)}, g) end do;

Clearly a bug and also prsent in Maple 2016.
I shall submit an SCR.


 

@GoitaHass You are not using the code I gave you in your attached worksheet. Your code contains several syntactical errors. I wasn't blunt enough when I wrote: Assuming that your 2-D input can be interpreted to mean the same as this corrected 1-D version ..

Try to take a copy of my reply above and paste it into a simple text editor like NotePad in Windows. You can make Maple work like that.
Since you are new to
Maple you may not be aware of the important difference between 2D input and 1D input (aka Maple input).

Go to the menu Tools/Options/Display/Input display choose Maple Notation.
Keep the Options window open.

After that in the Options window go to the tab Interface/Default format for new worksheets choose Worksheet.
Finally click the button Apply Globally.

This action can always be reversed.

Let me add that my personal choice would be to choose simpler names as in this modified version:
restart;
ode := mu1*E1(x)-mu2*(u(x)-d1*E1(x))/d2+diff(gamma1*E1(x)-gamma2*(u(x)-d1*E1(x))/d2, x) = 0;
isc:=E1(0) = 0;
dsolve({ode,isc},E1(x));


@John Fredsted Will this one work in your situation?

conv:=proc(u) local g, res;
  res:=evalindets(u,`*`,s->g(selectremove(type,s,{identical(tau),identical(f(t))})));
  res:=subs(tau*f(t)=f(-t),res);
  eval(%,g=`*`)
end proc;

conv(expr);
conv(tau*f(t)+6*f(t)-(1+7*I)*tau*f(t));
conv([expr,tau*f(t)+6*f(t)-(1+7*I)*tau*f(t)]);

#But maybe just evalindets with algsubs?

evalindets([expr,tau*f(t)+6*f(t)-(1+7*I)*tau*f(t)],`*`,s->algsubs(tau*f(t)=f(-t),s));

## Well, maybe I'm not quite getting it: You probably have many different functions f?
## That could be handled as in this example:
conv:=proc(u) local g, res, tps,S1,S; global tau,t,f,F,h;
  S1:={f(t),F(t),h(t)}; #Just an example
  tps:=identical~({tau} union S1);
  S1:=convert(S1,list);
  S:=tau*~S1=~eval(S1,t=-t);
  res:=evalindets(u,`*`,s->g(selectremove(type,s,tps)));
  res:=eval(res,S);
  eval(%,g=`*`)
end proc;
### And a version with algsubs combined with foldr and evalindets:
L:=[f(t),F(t),h(t)];
S:=tau*~L=~eval(L,t=-t);
conv:=u->foldr(algsubs,u,op(S));
evalindets([expr,tau*f(t)+6*h(t)-(1+7*I)*tau*F(t)],`*`,conv);




@John Fredsted You write that tau is supposed to be a time-reversal operator acting on some time-dependent function f(t).
Doesn't that mean that the `*` is not multiplication in your actual case, and the one you showed us is only a toy example?

@John Fredsted I realized my mistake before your reply. I have edited my answer.
Actually it is the fact that
subs(a*b=4,a*b*c);
eval(a*b*c,a*b=4);

both work as you intended that surprised me.

@dharr Yes, putting uneval quotes around the procedure name is nice.

@vv The assume project is quite ambitious. It is clearly very difficult.
I don't favor ad hoc solutions to satisfy the crowd (or just me) and I think it is fine to have high ambitions.
Nevertheless, straightforward cases like assume(n = 7) or the implied variety ought to be handled somewhat gracefully, whatever I mean by that.

@Markiyan Hirnyk Yes, assume(n >= 7, n <= 7) is equivalent to assume(n=7), so ought to be handled the same way.

My own simple hack of overloading assuming doesn't handle that because only equalities are handled by eval.
Thus
n assuming n>=0,n<=0;

works as it does without the hack, i.e. it returns n.

@vv I'm not sure what you mean by equality not being the real issue.
Certainly as you say we have from
assume(p<=0,p>=0);
about(p);
the response
Originally p, renamed p~:
  is assumed to be: 0

So we are actually assuming that p = 0, right?
I'm not saying that it is wrong for assuming to accept equality, I'm just asking what the designers want the system to respond to the fact that the assumptions imply equality.
As it is now the response is not easy to guess.

Should anybody return to this let me give the last revision that I have

restart;
assumingoverload:=subsop(3=overload,eval(`assuming`)):
st:=convert(eval(assumingoverload),string):
st2:=StringTools:-Substitute( st, st[1..19], "proc(x::uneval,a::list(Not(satisfies(x->hastype(x,name=constant)))))" ):
STR2:=" if type(a,'list') then assumptions := op(a)":
st3:=StringTools:-Substitute(st2,STR2,cat(STR2[1..-3],"ListTools:-Flatten(evalindets(a,set,[op])))")):
assumingoverload:=parse(st3):

assumingoverload:=parse(st3):
`assuming`:=overload(
       [
          proc(x::uneval,par1::And(list,satisfies(x->hastype(x,name=constant)))) option overload;
           local par,par2,res;
           par:=ListTools:-Flatten(evalindets(par1,set,[op]));
           par,par2:=selectremove(hastype,par,name=constant);
           assign(par);
           try
            res:=eval(x) assuming op(par2);
           catch:
            error;
           finally  
            map(unassign@lhs,eval(par,2));
           end try;
           op(eval(res,par)) assuming op(par2);
          end proc,
          eval(assumingoverload)
        ]
):

#################
Examples.
plot(a*sin(x),x=0..b) assuming {a=-2,b=7};
param := {a=2,b=7}:
plot(a*sin(x),x=0..b) assuming param;
plot(a*sin(x),x=0..b) assuming a=-2,b=7;
plot(a*sin(x),x=0..b) assuming [a=-2],{b=Pi};
simplify(sqrt((x*y)^2)) assuming x>0,y>0;
simplify(sqrt((x*y)^2)) assuming x=10,y>0;
int(exp(a*t),t=0..b) assuming a<0,b=infinity;
int(exp(b*a*t),t=0..infinity) assuming b=2,a<0;
int(exp(b*a*t),t=0..infinity) assuming {a<0,b>2};
A:=Matrix([[a,b],[c,d]]);
LinearAlgebra:-Eigenvectors(A) assuming d=0;


@Markiyan Hirnyk Thank you Markiyan. Yes that's the one.

@vv Several years ago I wrote contrived an overloading of assuming to work as eval when assuming equality.

That works fine, but the question is what the designers of `assuming` and assume intend assuming equality to mean.

I will formulate a question in MaplePrimes with the title "What does assume n=7 mean?"

First 87 88 89 90 91 92 93 Last Page 89 of 230