Preben Alsholm

MaplePrimes Activity


These are replies submitted by Preben Alsholm

@Rouben Rostamian  With little change to your nice code using odeplot with the frame option, we can make the orbit as the bob moves.
 

#orbit := spacecurve(eval([r[1],r[2],-r[3]], dsol), t=0..tmax);
# Using instead:
orbitA:=odeplot(dsol,[r[1],r[2],-r[3]],0..tmax,frames=100,color=blue);
A:=animate(frame, [t], t=0..tmax, scaling=constrained, frames=100); # No background
display(A,orbitA);

@nm Here is a case (expr2 below) where things are different:  

expr1:=(A+E)/B+C;
normal(expr1);
combine(expr1); # As expected
expr2:=2*sin(x)*cos(x)/B+C;
normal(expr2); # As expected
combine(expr2); # Not expected: (C*B + sin(2*x))/B
expand(%,sin); #  Now we get what I expected above: C + sin(2*x)/B
### A more complicated version:
evalindets(expr2,`*`,combine); # C + sin(2*x)/B

# Note: Using map instead of evalindets seems simpler:

map(combine,expr2);

@nm I admit that I find frontend difficult to use, so I rarely use it.
Instead I use freeze and thaw when I need to avoid e.g. expansions:
 

evalindets(eq,`^`,freeze);
solve(%,A);
thaw(%);

 

In your extremely simple example both of the following work:
 

restart;
eq:=A=(1/2+x+y)^(3);
the_rhs:=solve(eq,A);
rhs(isolate(eq,A));
frontend(solve,[eq,A],[{`=`}]);

@Tamour_Zubair Notice what happens when a table index is defined more than once as in your case:

BB:={a=c,a=b}; # Notice the order of the output
table(BB);
indices(%,pairs);

If you want to refer to a certain order use a list instead of a set:
 

CC:=[a=c,a=b];
table(CC);
indices(%,pairs);

 

@PainedMushroom I copied your input (your definition of A), then I pasted it to a 1D (aka Maple notation) input line.
What I got was
A:= [ [[0,1,0],[0,0,1],[-1,-4,-6]] ]:

which is a list of the listlist [[0,1,0],[0,0,1],[-1,-4,-6]].
You obviously meant to get  A:=Matrix([[0,1,0],[0,0,1],[-1,-4,-6]]): instead.

How you got into that mess I obviously cannot see, and why A:= [ [[0,1,0],[0,0,1],[-1,-4,-6]] ]: should cause the response you get I don't know. I never use document mode nor 2D input.
I did try, however, in a new document in document mode to paste in A:= [ [[0,1,0],[0,0,1],[-1,-4,-6]] ]:
It didn't create any problem, but of course this wasn't what you wanted as mentioned.

Please upload a worksheet using the fat green up arrow.

@Christian Wolinski 
You could do this (where I use the same name as Carl):
 

restart;
MyOperations := module() option package;  export `+`;
    `+` := proc(a::integer, b::float) option overload;
        :-`+`(a, F(b)); # Notice that :-`+` is used here
    end proc;
end module:

with(MyOperations);

1+1.1;
1-8.;
1+8;
1.1;
:-`+`(1,1.1);
main:=module() export `+`:= :-`+`; end module;
#main:=module() export `+`; `+`:= :-`+` end module: # same thing
use main in 
  1+1.1;
  1-8.;
  1+8;
  1.1
end use;

 

@Christian Wolinski This may be irrelevant to what you want to do, but didn't you want this:
 

MyOperations := module() option package;  export `+`;
    `+` := proc(a::integer, b::float) option overload;
        :-`+`(a, F(b)); # Notice that :-`+` is used here
    end proc;
end module:

with(MyOperations);

1+1.1;

1-8.;
1+8;
1.1;
:-`+`(1,1.1);

 

@Tokoro So do you really mean that you will start with the system
 

sys:=[diff(x1(t), t) = x2(t), diff(x2(t), t) = -x3(t)/3, diff(x3(t), t) = 6*x2(t) - 3*x3(t) - 3*u1(t), y1(t) = -6*x1(t) + x2(t)];

If so, what is u1(t) ? What are the initial conditions for x1, x2, and x3?
How are x1, x2, and x3 related to e__C and i__RL?
 

 

What has the system at the bottom got to do with the rest of the worksheet?
Specifically, what does "(->)" mean? I suppose that it is in Japanese.
 

It is the same in Maple 2022.0 as in Maple 2018.
I think it may be deliberate.
Notice that lprint(value(zero1) ) = 0 and lprint(value(quo1)) = 1.

@mary120 In this version I have shown how to find acceptable initial values for given values of delta.
The clue is that ode has diff(n(x),x)^2 which is nonnegative. Thus the rest of lhs(ode) must be negative (or zero) since the right hand side of ode is 0.

restart;  #NEW V

Digits:=15:
V:=-n^2*((T[e]+T[i])/T[e])*((((n)*(1+1/(2*delta[p]))))-ln(n)-ln(n/(2*delta[p]))-1-1/(4*delta[p])-delta[p]);
W:=eval(V,{T[e]=6/5,T[i]=1/100,n=n(x)}); # Omit delta[p]
ode:=diff(n(x),x)^2+2*W=0;
############################

############## When does a real solution exist for ode?
E:=lhs(eval(ode,{n(x)=n})); # E must be negative or zero for a real solution of ode
sol:=solve(E,n,allsolutions);
E1:=eval(sol,_Z2=0); # If you run the first time after restart you see _Z2. If you repeat without restart you get _Z4
E2:=eval(sol,_Z2=-1);
mMa:=eval([E1,E2],delta[p]=0.7);
mMb:=eval([E1,E2],delta[p]=0.9)
plot([E1,E2],delta[p]=0.7..0.9);
plot(eval(E,delta[p]=.7),n=0..2);
plot(eval(E,delta[p]=.9),n=0..2);
mMa;
mMb;
m:=min(mMa[1],mMb[1]);
M:=max(mMa[2],mMb[2]);
##So the initial values acceptable for ode and ODE if delta[p] values are between 0.7 and 0.9
##must be chosen outside of the values in mMa and nMb since E must be negative (or zero). 
##So n(0) must lie in the open interval 0..m or in the open interval M..infinity.
############################
# Example of an acceptable start valid for delta[p] between 0.7 and 0.9:
eval(convert(ode,D),{n(x)=m-.01}); # Start at 0 < n < m
ICS:=solve(eval(%,x=0),{D(n)(0)});
ic:=n(0)=m-.01;
ODE:=diff(ode,x);
## Using the parameters option to dsolve/numeric:
RESpar:=dsolve({ODE,op(ICS[1]),ic},numeric,parameters=[delta[p]]);

RESpar(parameters=[delta[p]=0.7]); # # Setting the parameter
plots:-odeplot(RESpar,[x,n(x)],-5..5); p1:=%: 
RESpar(parameters=[0.9]);# You can omit the name of the parameter when setting it.  
plots:-odeplot(RESpar,[x,n(x)],-5..5,color=blue); p2:=%:
plots:-display(p1,p2);
## A procedure that helps doing the above:
Q:=proc(dp,{range::range:=-10..10}) if not dp::realcons then return 'procname(_passed)' end if;
   RESpar(parameters=[dp]); # Setting the parameter
   plots:-odeplot(RESpar,[x,n(x)],range,_rest)
end proc;
# Simple input:
Q(0.7);
Q(0.9,color=black,range=-5..5,linestyle=3);
## An animation in delta[p]:
interface(warnlevel=0); # To avoid all those warnings.
plots:-animate(Q,[delta[p],range=-5..5],delta[p]=0.7..0.9);
plots:-animate(Q,[delta[p],range=-5..5,color="DarkGreen"],delta[p]=0.7..0.9,trace=24);

@mary120 You can do as I have posted earlier. If you insist on n(0) = 1 you cannot consider delta[p]>=1/2:
 

restart;  #NEW V

Digits:=15:
V:=-n^2*((T[e]+T[i])/T[e])*((((n)*(1+1/(2*delta[p]))))-ln(n)-ln(n/(2*delta[p]))-1-1/(4*delta[p])-delta[p]);
W:=eval(V,{T[e]=6/5,T[i]=1/100,n=n(x)}); # Omit delta[p]
ode:=diff(n(x),x)^2+2*W=0;
############################

eval(W,delta[p]=0.7);
############################
eval(convert(ode,D),{n(x)=1});
ICS:=solve(eval(%,x=0),{D(n)(0)});
ic:=n(0)=1;
ODE:=diff(ode,x);
eval(ODE,delta[p]=0.7);
## Using the parameters option to dsolve/numeric:
RESpar:=dsolve({ODE,op(ICS[1]),ic},numeric,parameters=[delta[p]]);

RESpar(parameters=[delta[p]=1/5]); # # Setting the parameter
plots:-odeplot(RESpar,[x,n(x)],-3..2,view=0..20); p1:=%: 
RESpar(parameters=[1/4]);# You can omit the name of the parameter when setting it.  
plots:-odeplot(RESpar,[x,n(x)],-3..2,view=0..20,color=blue); p2:=%:
plots:-display(p1,p2);
## A procedure that helps doing the above:
Q:=proc(dp,{range::range:=-10..10}) if not dp::realcons then return 'procname(_passed)' end if;
   RESpar(parameters=[dp]); # Setting the parameter
   plots:-odeplot(RESpar,[x,n(x)],range,_rest)
end proc;
# Simple input:
Q(1/5);
Q(1/4,color=black,range=-3..2,view=0..20,linestyle=3);
## An animation in delta[p]:
interface(warnlevel=0);
plots:-animate(Q,[delta[p],range=-5..5,view=0..20],delta[p]=0.1..0.49);
plots:-animate(Q,[delta[p],range=-5..5,view=0..20,color="DarkGreen"],delta[p]=0.1..0.49,trace=24);

What is Delta?  Even if you think it's obvious, tell us anyway, please.

First 14 15 16 17 18 19 20 Last Page 16 of 229