nm

2561 Reputation

16 Badges

7 years, 39 days

MaplePrimes Activity


These are answers submitted by nm

I would like to make similar graphs for y',y'',y''' etc and i couldn't think of how to do it.

For the above part, what I normally do is get the solution, use unapply to make it a function, then plot it and its derivatives. May be you can do something similar to your ODE. I used the following example for illustration:

restart;
ode:=diff(y(t),t$2)+1/10*diff(y(t),t)+2*y(t)=sin(t);
ic:=y(0)=0,D[1](y)(0)=0;

diff(diff(y(t), t), t)+(1/10)*(diff(y(t), t))+2*y(t) = sin(t)

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

sol:=dsolve([ode,ic],y(t)):
y:=unapply(rhs(sol),t);

proc (t) options operator, arrow; -(1990/80699)*exp(-(1/20)*t)*sin((1/20)*799^(1/2)*t)*799^(1/2)+(10/101)*exp(-(1/20)*t)*cos((1/20)*799^(1/2)*t)-(10/101)*cos(t)+(100/101)*sin(t) end proc

p1:=plot(y(t),t=0..2*Pi,'color'='red');
p2:=plot(diff(y(t),t),t=0..2*Pi,'color'='blue');

plots:-display(p1,p2)

 


 

Download plot_1.mw

Maple 2019.1

Your input is not right. I do not understand what concatentation operator || is doing in the above actually. (did not know one can use || inside matrix)

May be, in simple terms, you can show what is your A,B,C,D matrices are?

This is how I do these things:

restart:
a   := Matrix([[0,1,0,0],[0,0,1,0],[0,0,0,1],[-100,-90,-32,-8]]):
b   := Matrix([[0],[0],[5],[6]]):
c   := Matrix([[1,0,0,0]]):
d   := Matrix([[1]]):
sys := DynamicSystems:-StateSpace(a,b,c,d);

DynamicSystems:-ResponsePlot(sys, 
       DynamicSystems:-Step(),duration=10,color=red,legend="step");

Default digits is 10. Solve gives exact solution. When converted to numerical using only 10 digits you get the difference shown

if you increase the Digits to say 16, now both give the same answer.

restart;

sol:=solve(cos(2*arccos(x)));
evalf(sol);
Digits:=16:
evalf(sol);

(1/2)*2^(1/2)

.7071067810

.7071067811865475

restart;

fsolve(cos(2*arccos(x)));
Digits:=16:
fsolve(cos(2*arccos(x)));
 

.7071067812

.7071067811865475

 

 

Download 072919.mw

If your expression is sums/addition as you show, you could try patmatch

restart;
foo:=proc(expr)
  local  b,c,la;
  local result:={};
  if patmatch(expr,b::nonunit(realcons)+c::anything,'la') then
     assign(la);
     result := b;
  fi;
     
  return(result);
end proc:

And now

expr:=35.438*y1(x)-34424*y2(x)+78.34+2*z1(x)+33*x:
foo(expr)

gives 78.24

and

expr:=2*z1(x)+33*x:
foo(expr)

gives {}

 

You can use the option 'series' to get series solution,. Change Order to obtain more terms. But for series solution, initial conditions must be given at a single point, Which is not the case in your ode. But Maple can solve analytically.

If you solve it using series, without IC, it works
 

restart;
ode:= diff(g(r),r$2)- r/R*g(r)=0;
ic:=g(2*R)=0, D[1](g)(0)=R;
dsolve([ode,ic],g(r)) assuming R>0

diff(diff(g(r), r), r)-r*g(r)/R = 0

g(2*R) = 0, (D(g))(0) = R

g(r) = -2*R^(4/3)*Pi*AiryBi(2*R^(2/3))*AiryAi(r/R^(1/3))/(GAMMA(2/3)*(3^(2/3)*AiryAi(2*R^(2/3))+3^(1/6)*AiryBi(2*R^(2/3))))+2*AiryAi(2*R^(2/3))*R^(4/3)*Pi*AiryBi(r/R^(1/3))/(GAMMA(2/3)*(3^(2/3)*AiryAi(2*R^(2/3))+3^(1/6)*AiryBi(2*R^(2/3))))

Order:=10;
dsolve(ode,g(r),'series') assuming R>0

10

g(r) = series(g(0)+(D(g))(0)*r+((1/6)*g(0)/R)*r^3+((1/12)*(D(g))(0)/R)*r^4+((1/180)*g(0)/R^2)*r^6+((1/504)*(D(g))(0)/R^2)*r^7+((1/12960)*g(0)/R^3)*r^9+O(r^10),r,10)

 

 

Download t.mw

 

 

 

 

 

"with solutions k*Pi and -Pi/48 + K*Pi/8"

What is K above? Is this supposed to be an integer? If so, the above misses many solutions:

restart;
eq   := sin(9*x-(1/3)*Pi) - sin(7*x-(1/3)*Pi);
pt1  := [seq( [k*Pi,0] ,k=-2..2)];
pt2  := [seq( [-Pi/48+k*Pi/8,0],k=-2..2)];
pt   := [op(pt1),op(pt2)];

plots:-display([
        plot(eq,x=-2*Pi..2*Pi,color=blue),
        plots:-pointplot(pt,color=red,symbol=circle,symbolsize=20)]
       );

 

You can see there are many zeros your solution missed.

You could use map. To map a function to list. Here is an example

my_values:=[1,2,3];
foo:=x-> x^2;
map(foo,my_values)

     [1, 4, 9]

So in your case

 

fI := [12.5, 16, 20, 25, 31.5, 40, 50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500, 630, 800, 1000, 1250, 1600, 2000, 2500, 3150, 4000, 5000, 6300, 8000, 10000, 12500, 16000, 20000]:
x:= 23;
y:= 36;
Lp:= z->8-10*log[10]((1+(z/(2*x))^2.5)*(1+(y/(2*z))^1.7));
map(Lp,fI)

gives

[3.274233826, 4.233853584, 4.851085247, 5.179646200, 5.157642183, 4.688048956, 
3.809126215, 2.467329267, 0.689125561, -1.242681054, -3.35483821, -5.82698075, 
-8.13745542, -10.49146441, -12.95740533, -15.52422767, -17.93167078, -20.43110843, 
-23.01860293, -25.43771840, -27.85814511, -30.53677413, -32.95859769, -35.38074288, 
-37.88959767, -40.48306044, -42.90564400, -45.41479325, -48.00845170, -50.43115414, 
-52.85387222, -55.53409784, -57.95683404]

 

one way might be

x:= C*exp(I*T[1]*e*eta);
algsubs(e*T[1]=T[2],x)

You can obtain a series solution

dsolve([ode,y(0)=C1,D(y)(0)=C2],y(t),'series')

 

 

try isprime.  as in 

select(isprime,{$1..100});

 

{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}

 

There might be a build in function in Maple to do this. But you could always do

N:=10: #must be even integer
lst:=[seq([i,N-i],i=1..N/2)]

corrected to use evalhf instead of evalf (I am not able to delete this for some reason).

It is always best to provide an example when asking such questions to eliminate any misunderstanding.

You could try

r:=evalf(Pi); 
parse(sprintf("%.10f",r)); #truncate to whatever number of decimals

if this is not what you meant, someone please feel free to delete my answer. I am not able to delete it. 

Try it with Maple 2019 Physics 348


 

pde := diff(u(x, t), t) = k*diff(u(x, t), x, x);
bc := u(x, 0) = T, u(0, t) = a*t + b, u(L, t) = T;
pdsolve([pde, bc], u(x, t)) assuming (0 < k, 0 < L, 0 < a, 0 < b, 0 < T, 0 <= t, 0 <= x and x <= L);

diff(u(x, t), t) = k*(diff(diff(u(x, t), x), x))

u(x, 0) = T, u(0, t) = a*t+b, u(L, t) = T

u(x, t) = (1/6)*(6*(Sum(2*sin(n*Pi*x/L)*(Pi^2*k*(T-b)*n^2+L^2*a)*exp(-Pi^2*n^2*k*t/L^2)/(n^3*Pi^3*k), n = 1 .. infinity))*k*L+((6*a*t+6*b)*L+6*x*(-a*t+T-b))*k-2*a*x*(L-x)*(L-(1/2)*x))/(L*k)

 

 


 

Download A.mw

I removed bc[4] but the code run withour any error but no solution displayed

It works for me on Maple 2019:


 

restart;

pde := diff(f(x, y), x $ 2) + diff(f(x, y), y $ 2) = 0;
bc[1] := f(x, 0) = exp(-x);
bc[2] := D[1](f)(0, y) = 0;
bc[3] := D[2](f)(x, 1) = 0;
sys := [pde, bc[1], bc[2], bc[3]];
sol := pdsolve(sys, f(x, y))

diff(diff(f(x, y), x), x)+diff(diff(f(x, y), y), y) = 0

f(x, 0) = exp(-x)

(D[1](f))(0, y) = 0

(D[2](f))(x, 1) = 0

[diff(diff(f(x, y), x), x)+diff(diff(f(x, y), y), y) = 0, f(x, 0) = exp(-x), (D[1](f))(0, y) = 0, (D[2](f))(x, 1) = 0]

f(x, y) = Sum(8*sin((1/2)*(1+2*n)*Pi*y)*((n+1/2)*Pi*(2+(1+(n+1/2)*Pi)^2*_C5(n))*exp((1/2)*(1+2*n)*Pi*x)+(n+1/2)*Pi*_C5(n)*(1+(n+1/2)*Pi)*(-1+(n+1/2)*Pi)*exp(-(1/2)*(1+2*n)*Pi*x)+2*exp(-x))/((1+2*n)^3*Pi^3+2*Pi^2*(1+2*n)^2), n = 0 .. infinity)+exp(-x)

 


 

Download foo.mw

One way could be

unassign('f,x,y');
f:=(x,y)->arctan(x*y^2);
diff(f(x,y),x);
diff(f(x,y),y);

 

1 2 3 4 5 6 7 Page 1 of 7