nm

11353 Reputation

20 Badges

13 years, 10 days

MaplePrimes Activity


These are answers submitted by nm

May be you want is map. Hard to guess without an example. Maple will add the "()" automatically for you.

f:=poly->poly+1; #this is your f function, change as needed
my_polynomials:=[2*x-1,x^2+3*x+2,x^3-2*x-3,x^3];
map(f,my_polynomials)

 

alternative:

I happen to like pattern matching also. Even though in Maple this is not as needed/ or used as it is in Mathematica.

So you could also do

unassign('a,b');
Given_eq_3_37a := simplify(subs([Given_eq_3_30], Given_eq_3_37));

patmatch(rhs(Given_eq_3_37a),sqrt(a::anything)*sqrt(b::anything),'la');
assign(la);

Given_eq_3_37a:=M=sqrt(a*b)

this is similar to you question you asked above.  

First the solution to the PDE is sol := u(x, t) = 2*x

so nothing to animate, since it has no time depenedency.

But if you change the command to

plots:-animate(plot, [rhs(sol), x = 0 .. 2], t = 0 .. 1, frames = 60)

The error goes away. but nothing will move in the animation ofcourse since there is no t in the solution.

 

 

Change the animation line to the following makes it work:

plots[animate](plot, [subs(t=i,rhs(sol)), x = -10 .. 10], i = 0 .. 5,frames=100)

ps. I see it will also works without the extra subs() in there.

 

restart;
pde := diff(u(x,t), t) = diff(u(x,t),x$2) - alpha*u(x,t);
bc  := u(0,t) = 0, u(L,t) = 0;
pdsolve([pde, bc],u(x,t)) assuming alpha>0,L>0;

start edit: fyi, the above was done on Physics version earlier than 824. In Latest version 824, the output looks like

end edit.

 

But it would be better if you provide IC:

restart;
pde := diff(u(x,t), t) = diff(u(x,t),x$2) - alpha*u(x,t);
bc  := u(0,t) = 0, u(L,t) = 0;
ic  := u(x,0) = f(x);
pdsolve([pde, bc, ic],u(x,t)) assuming alpha>0,L>0;

 

Updated to answer new comment:

can you provide the working process without Maple command if possible

I assume you mean solution by hand not using Maple? if so, you can use separation of variables.

But this forum is really about using Maple commands to solve problems. But here is my hand solution anyway. This is from one of my old solutions. I solved hundreds of such PDE's by hand before. This shows Maple's solution was correct also as it got same final answer ;).

Ofcourse using Maple is much easier than having to do all this each time.

 

 

 

Need to set the right condition. For exp(t), the condition is s-1>0. For general exp(a*t) the condition is s-a>0. 

restart;

LT := proc(f::function,t::symbol,s::symbol)
local a,la;
patmatch(op(1,f),a::anything*t,'la');
assign(la);
simplify(int(exp(-s*t)*f, t = 0 .. infinity), assume=[s-a>0]);
end proc:

LT(exp(t),t,s);
LT(exp(2*t),t,s);
LT(exp(a*t),t,s);

1/(-1+s)

1/(-2+s)

-1/(a-s)

inttrans:-laplace(exp(t),t,s);
inttrans:-laplace(exp(2*t),t,s);
inttrans:-laplace(exp(a*t),t,s);

1/(-1+s)

1/(-2+s)

1/(-a+s)

 


 

Download lap.mw

in addition to what was said in other replies.

The issues seems that Maple could not integrate 

Using another software, this has antiderivative

Copying this result to Maple to give final solution and odetest gives zero. Here is the worksheet


 

restart;

with(MmaTranslator);
ode:=diff(Q(t),t)=-alpha*beta*t^(beta-1)*Q(t)-a*p^(-b);
sol:=dsolve(ode);

[FromMma, FromMmaNotebook, Mma, MmaToMaple]

diff(Q(t), t) = -alpha*beta*t^(beta-1)*Q(t)-a*p^(-b)

Q(t) = (Int(-a*p^(-b)*exp(t^beta*alpha), t)+_C1)*exp(-t^beta*alpha)

#the above is same as
sol := Q(t) = (( -a*p^(-b)*Int(exp(t^beta*alpha), t)) + _C1)*exp(-t^beta*alpha)

Q(t) = (-a*p^(-b)*(Int(exp(t^beta*alpha), t))+_C1)*exp(-t^beta*alpha)

int(exp(t^beta*alpha), t)

int(exp(t^beta*alpha), t)

#copied antiderivative of the above
inside_integral:=FromMma(`-((t*Gamma[beta^(-1), -(alpha*(t^beta))])/(beta*(-(alpha*(t^beta)))^(beta^(-1))))`);

-t*GAMMA(1/beta, -t^beta*alpha)/(beta*(-t^beta*alpha)^(1/beta))

#this is the final solution
sol:=subs(Int(exp(t^beta*alpha), t)=inside_integral,sol)

Q(t) = (a*p^(-b)*t*GAMMA(1/beta, -t^beta*alpha)/(beta*(-t^beta*alpha)^(1/beta))+_C1)*exp(-t^beta*alpha)

odetest(sol,ode)

0

 


 

Download dsolve_9_5_2020.mw

 

 

subexp := sin(omega*t + alpha)*sin(omega*t + phi);
subexp2:= M__a*I__a*trigsubs(subexp)[1];

You can't solve the above since there is no equation. An equation must have a `=` in it and your's do not. May be this is why it did not work when you tried it?

If you can post an actuall differential equation, then I am sure Maple will be able to solve it, even if the diff was in the denominator.

For example

restart;
dsolve(y(t)/diff(y(t),t)=1)

gives

                        y(t) = _C1*exp(t)

 in the example I would expect it to return exp(x).

Did you try to enter it in Maple?

sum(x^n/n!,n=0..infinity)

And Maple returns exp(x)

 

 

why can't you just write

a:=3;
plot(x, x = 0 .. a)

but if you do not want, you can try

f:=a->plot(x, x = 0 .. a);
f(3)

But if you do not want, you can try

restart;
eval('plot(x, x = 0 .. a)',a=3)

But if you do not want, you can try

restart;
simplify('plot(x, x = 0 .. a)',{a=3})

OP said

I found another solution I like:

use a=3 in plot(x, x=0..a) end use;

If you want to do the above, then you could also do

..... 

proc() 
   local a=3; 
   plot(x,x=0..a); 
end proc 
    ()
.....

The above introduces local block inside you other functions and inside is only local to that block. Same as with use but I think is better.

I learned the above from Carl answer here https://www.mapleprimes.com/questions/201123-Can-One-Declare-Local-Variables-With 

there is none. Even this, without the sqrt, has no anti-derivative

restart;
p :=1/(ln(t)^2 + t);
int(p,t)

 

restart;
f := Statistics:-RandomVariable(Normal(1,1/2)):
plot(Statistics:-PDF(f,t),t=-3..3);

ode:=m*diff(x(t),t$2)+c*diff(x(t),t)+k*x(t)=F(t);
ic:=x(0)=1,D(x)(0)=0;
m:=1;c:=1/100;k:=10;
F:=t->Statistics:-PDF(f,t);
sol:=dsolve([ode,ic],x(t));

plot(rhs(sol),t=0..20)

 

where the expression would be M = 2Krst / w

one way could be

restart;
M:= 2*p*q*r*s*t /(u*v*w);
algsubs(p*q/(u*v)=k,M)

Another way

restart;
M:= 2*p*q*r*s*t /(u*v*w);
solve(p*q/(u*v)=k,p);
subs(p=%,M)

you really do not need Maple for this

Check using Maple:

ode:=diff(f(x),x)=f(x)^(-1);
dsolve(ode);

First 11 12 13 14 15 16 17 Page 13 of 20