Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I am preparing a document where in I want to show half circle inide the drawing. I can plot a half circle, but can not bring it inside the drawing canvass. Is there a way to show smooth curves inside the drawing. Pencil tool helps to show my curve, but not a smooth one! In any picture tool, bring forward, sent backward options will be there. Are there such tools in maple?
Thanks for answers.

Cheers.

Ramakrishnan V
 

``

``


 

Download drawing_semicircle.mw

Hello everyone

I have the solution of diffusion equation from Help of maple website. I put the code here

*****************************

restart: with(plots):
 

unprotect(D);
 

alias(c[0]=c0, c[1]=c1, c[2]=c2);
PDE:=diff(C(x,t),t)=D*diff(C(x,t),x,x);
IBC:={C(x,0)=cx0, C(0,t)=ct0, D[1](C)(10,t)=0};
ct0:=1;
cx0:=0;
D:=1;
pds:=pdsolve(PDE,IBC,numeric);
L1:=[0.01, 0.1, 1, 5, 10];
L2:=[red, green, yellow, blue, magenta, black];
for i from 1 to 5 do
 pn[i] := pds:-plot(t=L1[i], color=L2[i]):
end do:
display({seq(pn[i], i=1..5)}, title=`Numerical solution at t=0.01, 0.1, 1, 5, 10`);

****************************

 

the code is working perfectly. But, My question is how can I found the diffusion constant (D) if I have the solution ( C(x,t) ).  Probably it should be an algorithm which use least square method to find (D) based on the data C(x,t).

I am looking for a fast and efficient algorithm if there is any.

thank you so much for your kind attentions in advance

Sincerely yours,

Amir

This ODE turns out to be a simple separable ODE. With one solution, if the ODE is rewritten.

But in its original form, Maple dsolve gives 6 complicated looking solutions with complex numbers in some of them. Even though all 6 solutions are valid.

Any one knows why Maple did that and not give the one simple solution instead? 

I used isolate to solve for y' from the original ODE. Verfiied that only one solution exist.  The ODE then became y'(x)= 3*y(x)/(2*x). Which by uniqueness theorem, should have one unique solution in some region in the RHS or in some region in the LHS that does not inculde x=0 ?

Just wondering what is going on, and why Maple did not give same simpler solution, so I can learn something new. That is all.

restart;

Typesetting:-Settings(typesetprime=true):

ode:= 1/2*(2*x^(5/2)-3*y(x)^(5/3))/x^(5/2)/y(x)^(2/3)+1/3*(-2*x^(5/2)+3*y(x)^(5/3))*diff(y(x),x)/x^(3/2)/y(x)^(5/3) = 0;

(1/2)*(2*x^(5/2)-3*y(x)^(5/3))/(x^(5/2)*y(x)^(2/3))+(1/3)*(-2*x^(5/2)+3*y(x)^(5/3))*(diff(y(x), x))/(x^(3/2)*y(x)^(5/3)) = 0

DEtools:-odeadvisor(ode);

[[_1st_order, _with_linear_symmetries], _exact, _rational]

maple_sol:=dsolve(ode);

y(x) = (1/3)*2^(3/5)*3^(2/5)*(x^(5/2))^(3/5), y(x) = (1/3)*(-(1/4)*5^(1/2)-1/4-((1/4)*I)*2^(1/2)*(5-5^(1/2))^(1/2))^3*2^(3/5)*3^(2/5)*(x^(5/2))^(3/5), y(x) = (1/3)*(-(1/4)*5^(1/2)-1/4+((1/4)*I)*2^(1/2)*(5-5^(1/2))^(1/2))^3*2^(3/5)*3^(2/5)*(x^(5/2))^(3/5), y(x) = (1/3)*((1/4)*5^(1/2)-1/4-((1/4)*I)*2^(1/2)*(5+5^(1/2))^(1/2))^3*2^(3/5)*3^(2/5)*(x^(5/2))^(3/5), y(x) = (1/3)*((1/4)*5^(1/2)-1/4+((1/4)*I)*2^(1/2)*(5+5^(1/2))^(1/2))^3*2^(3/5)*3^(2/5)*(x^(5/2))^(3/5), x/y(x)^(2/3)+y(x)/x^(3/2)+_C1 = 0

map(x->odetest(x,ode),[maple_sol])

[0, 0, 0, 0, 0, 0]

solve(ode,diff(y(x),x),AllSolutions)

(3/2)*y(x)/x

ode2:=isolate(ode,diff(y(x),x)); #solve for y' first

diff(y(x), x) = -(3/2)*(2*x^(5/2)-3*y(x)^(5/3))*y(x)/(x*(-2*x^(5/2)+3*y(x)^(5/3)))

ode2:=simplify(ode2)

diff(y(x), x) = (3/2)*y(x)/x

DEtools:-odeadvisor(ode2);

[_separable]

sol:=dsolve(ode2)

y(x) = _C1*x^(3/2)

odetest(sol,ode2)

0

 

Download strange_ode_answer.mw

Maple 2019.1

Physics 395

Hi, I am trying to plot the phase potrait for this as follow:

s0 := 3*10^5;
d := 10^(-3);
delta := 10^4;
b := 5*10^6;
lamda := 4.16;

DEplot([diff(I(t), t) = s0 + I(t)*(-d - delta*Q(t)/(b + Q(t))), diff(Q(t), t) = -lamda*Q(t)], [I(t), Q(t)], t = 0 .. 10, I = 0 .. 100, 0, Q = 0 .. 100, 0, dirfield = 400, arrows = smalltwo, number = 2, [[0, 4, 0.1], [0, 0.2, 4.1], [0, 7, 0.2], [0, 0.2, 7]], color = red, linecolor = blue, numsteps = 100)

 

But, there is an error saying "Error, (in DEtools/DEplot) vars must be declared as a list, e.g. [x(t),y(t),...]". However, I did the same for other problem and worked well tho. I have no idea what the problem is for above.

Please download 1.txt.

Integrand := parse(FileTools[Text][ReadFile]("1.txt")):

int(Integrand, [z = -R .. R, y = 0 .. R], numeric);

plots[implicitplot3d](Phi = phi, z = -R .. R, y = 0 .. R, Phi = 0 .. 0.1e-1, color = ColorTools[Gradient]("Red" .. "Blue", best)[4], grid = [50, 50, 20]);

Why the integrand has positive real amounts in the domain [z = -R .. R, y = 0 .. R] for R=0.5, but the integral value is negative?

Hi guys

 

I've created a joint display which plots a spacecurve and an arrow which represents the tangent to the curve:

I've written this in the animation format so I can move the tangent arrow along the curve, however when I replace

arrow(subs(s=0,p),subs(s=0,ptan),width=0.3,length=4)

with

arrow(subs(s=A,p),subs(s=A,ptan),width=0.3,length=4)

I get the error:

Error, (in Plot:-AnalyzeData:-StandardizeData) points cannot be converted to floating-point values

I have tried animating the arrow alone(see below) and this works fine, so the problem is coming from try to pass the animation parameter A into the display array of multiple plots.

DG.mw

Thanks

Hi

I have trouble with solving this ODE system using dsolve command:

and 

 

This system have following solutions:

where

and

C's and A are constants of integration.

 

They're equations from this paper https://arxiv.org/abs/1710.01910 (45 and 47). 
               

However, my solution differs from correct one - in output there are hypergeometric functions everywhere.

Is there any way to fix/convert this solution? Or to get rid of these functions (my f1 solution looks very close to original one but with coupled hypergeometric function). 
 

`` ``

``

``

 

``

sysode := 2*q*(3*q-1)*f1(tau)/tau^2+2*q*(diff(f1(tau), tau))/tau+diff(f1(tau), tau, tau)+(kappa^2+f2(tau))*(1+omega)*(tau/t0)^(-(3*(3+omega))*q) = 0, (54*q^3-30*q^2+4*q)*f1(tau)/tau^3+(24*q^2-4*q)*(diff(f1(tau), tau))/tau^2+11*q*(diff(f1(tau), tau, tau))/tau+diff(f1(tau), tau, tau, tau)-3*omega*(1+omega)*(kappa^2+f2(tau))*q*(tau/t0)^(-(3*(1+omega))*q)/tau = 0;

2*q*(3*q-1)*f1(tau)/tau^2+2*q*(diff(f1(tau), tau))/tau+diff(diff(f1(tau), tau), tau)+(kappa^2+f2(tau))*(1+omega)*(tau/t0)^(-3*(3+omega)*q) = 0, (54*q^3-30*q^2+4*q)*f1(tau)/tau^3+(24*q^2-4*q)*(diff(f1(tau), tau))/tau^2+11*q*(diff(diff(f1(tau), tau), tau))/tau+diff(diff(diff(f1(tau), tau), tau), tau)-3*omega*(1+omega)*(kappa^2+f2(tau))*q*(tau/t0)^(-3*(1+omega)*q)/tau = 0

(1)

``

``

simplify(dsolve([sysode], build));

{f1(tau) = _C1*tau^(-q+1/2-(1/2)*(-20*q^2+4*q+1)^(1/2))+_C2*tau^(-q+1/2+(1/2)*(-20*q^2+4*q+1)^(1/2))+_C3*tau^(-9*q+2)*hypergeom([-(1/12)*(16*q+(-20*q^2+4*q+1)^(1/2)-3)/q, (1/12)*(-16*q+(-20*q^2+4*q+1)^(1/2)+3)/q], [-(1/12)*(4*q+(-20*q^2+4*q+1)^(1/2)-3)/q, (1/12)*(-4*q+(-20*q^2+4*q+1)^(1/2)+3)/q], -(1/2)*(tau/t0)^(6*q)*omega), f2(tau) = (-695520*(q^2+(11/21)*q+2/21)*(tau/t0)^(3*q*(omega+5))*_C3*(q-3/10)*omega*q*(q^2-(25/69)*q+2/69)*tau^(-9*q)*hypergeom([-(1/12)*(4*q+(-20*q^2+4*q+1)^(1/2)-3)/q, (1/12)*(-4*q+(-20*q^2+4*q+1)^(1/2)+3)/q], [-(1/12)*(-8*q+(-20*q^2+4*q+1)^(1/2)-3)/q, (1/12)*(8*q+(-20*q^2+4*q+1)^(1/2)+3)/q], -(1/2)*(tau/t0)^(6*q)*omega)-89424*(q^2*(tau/t0)^(3*q*(omega+7))*omega^2*tau^(-9*q)*_C3*(q^2-(25/69)*q+2/69)*hypergeom([-(1/12)*(-8*q+(-20*q^2+4*q+1)^(1/2)-3)/q, (1/12)*(8*q+(-20*q^2+4*q+1)^(1/2)+3)/q], [-(1/12)*(-20*q+(-20*q^2+4*q+1)^(1/2)-3)/q, (1/12)*(20*q+(-20*q^2+4*q+1)^(1/2)+3)/q], -(1/2)*(tau/t0)^(6*q)*omega)+(7/3)*(q^2+(11/21)*q+2/21)*(hypergeom([-(1/12)*(16*q+(-20*q^2+4*q+1)^(1/2)-3)/q, (1/12)*(-16*q+(-20*q^2+4*q+1)^(1/2)+3)/q], [-(1/12)*(4*q+(-20*q^2+4*q+1)^(1/2)-3)/q, (1/12)*(-4*q+(-20*q^2+4*q+1)^(1/2)+3)/q], -(1/2)*(tau/t0)^(6*q)*omega)*_C3*(tau/t0)^(3*(3+omega)*q)*(q^2-(25/69)*q+2/69)*tau^(-9*q)+(1/69)*kappa^2*(1+omega)))*(q^2-(7/9)*q+2/9))/((1+omega)*(4*q-(-20*q^2+4*q+1)^(1/2)-3)*(8*q-(-20*q^2+4*q+1)^(1/2)+3)*(8*q+(-20*q^2+4*q+1)^(1/2)+3)*(4*q+(-20*q^2+4*q+1)^(1/2)-3))}

(2)

NULL

NULL

``

NULLNULL

NULL

NULL

NULL

NULL

``


 

Download question.mw

When I apply the uses function with the Physics package in a procedure, the commands in this package are not restricted to the inside of the procedure, but are applied globally. See the example below:

gds := proc(LL, qi, t)

 local ta,i;  

uses Physics;

ta := sec(diff(diff(LL, diff(qi[i](t), t)), t), i = 1 .. nops(qi));

RETURN(ta) end:

sxy := diff(x(t), t)^2 + diff(y(t), t)^2:

gds(sxy, [x, y], t);

Error, (in Physics:-diff) name expected for external function
 

On the other hand, when I apply the uses function with the LinearAlgebra package in a procedure, the commands in this package are restricted to the inside of the procedure only.
dst:=proc(MM) 

local DA; 

uses LinearAlgebra;

DA:=Determinant(MM); 

RETURN(DA) end:

dst(<<1 | 2>, <3 | 4>>);

                  -2

Determinant(<<1 | 2>, <3 | 4>>);

                         Determinant(Matrix(2, 2, [[1, 2], [3, 4]]))

This could be a bug in Maple 2019?

Hello, I am wondering if Maple is capable of generating a subgraph for a directed, weighed graph with the GraphTheory package. The online resources I can find only include undirected, unweighed graphs. 

can you please include an example with commands that is able to perform the said task?

hi everyone:

how can I solve this below equation?

w:=(x)->sin(lambda*x)+b*cos(lambda*x)-sinh(lambda*x)-b*cosh(lambda*x);

b := -(sin(lambda*L)+sinh*lambda*L)/(cos(lambda*L)+cosh*lambda*L);

L:=10;

equation:=int(w(x)^2,x=0..L)=1;

lambda=????

tnx..

Hi everybody?

how can I solve this PDE with Runge-Kutta method and 2D plot in terms of w(x,t) , t and 3D plot in terms of t, x, w(x,t)?

code1.mw

how this integral can be calculated in the simplest form ? the second question is what exactly is done when using assuming? for example when using assuming real, all the functions or parameteres are affected? thanks in advanced

 

restart:with(IntegrationTools):

(int(int(exp(-(y-beta[0]-beta[1]*x-b0-b1*x)^2/(2*sigma^2))*exp(-b0)*exp(-b1),b0=0..infinity),b1=0..infinity,continuous=true) assuming real)

signum(limit(-(1/2)*Pi^(1/2)*exp((1/2)*(2*b1+2*beta[1])*x+(1/2)*sigma^2-y-b1+beta[0])*2^(1/2)*sigma*(erf((1/2)*(sigma^2+(b1+beta[1])*x-y+beta[0])*2^(1/2)/sigma)-signum(sigma)), b1 = infinity))*infinity

(1)

 


 

Download error_function.mw

This post is closely related to the previous one  https://www.mapleprimes.com/posts/210930-Numbrix-Puzzle-By-The-Branch-And-Bound-Method  which presents the procedure  NumbrixPuzzle   that allows you to effectively solve these puzzles (the text of this procedure is also available in the worksheet below).  
This post is about generating these puzzles. To do this, we need the procedure  SerpentinePaths  (see below) , which allows us to generate a large number of serpentine paths in a matrix of a specified size, starting with a specified matrix element. Note that for a square matrix of the order  n , the number of such paths starting from [1,1] - position is the sequence  https://oeis.org/search?q=1%2C2%2C8%2C52%2C824&language=english&go=Search .

The required parameter of  SerpentinePaths procedure is the list  S , which defines the dimensions of the matrix. The optional parameter is the list  P  - this is the position of the number 1 (by default P=[1,1] ).
As an example below, we generate 20 puzzles of size 6 by 6. In exactly the same way, we can generate the desired number of puzzles for matrices of other sizes.


 

restart;

SerpentinePaths:=proc(S::list, P::list:=[1,1])
local OneStep, A, m, F, B, T, a;

OneStep:=proc(A::listlist)
local s, L, B, T, k, l;

s:=max[index](A);
L:=[[s[1]-1,s[2]],[s[1]+1,s[2]],[s[1],s[2]-1],[s[1],s[2]+1]];
T:=table(); k:=0;
for l in L do
if l[1]>=1 and l[1]<=S[1] and l[2]>=1 and l[2]<=S[2] and A[op(l)]=0 then k:=k+1; B:=subsop(l=a+1,A);
T[k]:=B fi;
od;
convert(T, list);
end proc;
A:=convert(Matrix(S[], {(P[])=1}), listlist);
m:=S[1]*S[2]-1;
B:=[$ 1..m];
F:=LM->ListTools:-FlattenOnce(map(OneStep, `if`(nops(LM)<=30000,LM,LM[-30000..-1])));
T:=[A];
for a in B do
T:=F(T);
od;
map(convert, T, Matrix);

end proc:
 

NumbrixPuzzle:=proc(A::Matrix)
local A1, L, N, S, MS, OneStepLeft, OneStepRight, F1, F2, m, L1, p, q, a, b, T, k, s1, s, H, n, L2, i, j, i1, j1, R;
uses ListTools;
S:=upperbound(A); N:=nops(op(A)[3]); MS:=`*`(S);
A1:=convert(A, listlist);
for i from 1 to S[1] do
for j from 1 to S[2] do
for i1 from i to S[1] do
for j1 from 1 to S[2] do
if A1[i,j]<>0 and A1[i1,j1]<>0 and abs(A1[i,j]-A1[i1,j1])<abs(i-i1)+abs(j-j1) then return `no solutions` fi;
od; od; od; od;
L:=sort(select(e->e<>0, Flatten(A1)));
L1:=[`if`(L[1]>1,seq(L[1]-k, k=0..L[1]-2),NULL)];
L2:=[seq(seq(`if`(L[i+1]-L[i]>1,L[i]+k,NULL),k=0..L[i+1]-L[i]-2), i=1..nops(L)-1), `if`(L[-1]<MS,seq(L[-1]+k,k=0..MS-L[-1]-1),NULL)];
OneStepLeft:=proc(A1::listlist)
local s, M, m, k, T;
uses ListTools;
s:=Search(a, Matrix(A1));   
M:=[[s[1]-1,s[2]],[s[1]+1,s[2]],[s[1],s[2]-1],[s[1],s[2]+1]];
T:=table(); k:=0;
for m in M do
if m[1]>=1 and m[1]<=S[1] and m[2]>=1 and m[2]<=S[2] and A1[op(m)]=0 then k:=k+1; T[k]:=subsop(m=a-1,A1);
fi;
od;
convert(T, list);
end proc;
OneStepRight:=proc(A1::listlist)
local s, M, m, k, T, s1;
uses ListTools;
s:=Search(a, Matrix(A1));  s1:=Search(a+2, Matrix(A1));  
M:=[[s[1]-1,s[2]],[s[1]+1,s[2]],[s[1],s[2]-1],[s[1],s[2]+1]];
T:=table(); k:=0;
for m in M do
if m[1]>=1 and m[1]<=S[1] and m[2]>=1 and m[2]<=S[2] and A1[op(m)]=0 and `if`(a+2 in L, `if`(is(abs(s1[1]-m[1])+abs(s1[2]-m[2])>1),false,true),true) then k:=k+1; T[k]:=subsop(m=a+1,A1);
fi;
od;
convert(T, list);   
end proc;
F1:=LM->ListTools:-FlattenOnce(map(OneStepLeft, LM));
F2:=LM->ListTools:-FlattenOnce(map(OneStepRight, LM));
T:=[A1];
for a in L1 do
T:=F1(T);
od;
for a in L2 do
T:=F2(T);
od;
R:=map(t->convert(t,Matrix), T);
if nops(R)=0 then return `no solutions` else R fi;
end proc:


Simple examples

SerpentinePaths([3,3]);  # All the serpentine paths for the matrix  3x3, starting with [1,1]-position
SerpentinePaths([3,3],[1,2]);  # No solutions if the start with [1,2]-position
SerpentinePaths([4,4]):  # All the serpentine paths for the matrix  4x4, starting with [1,1]-position
nops(%);
nops(SerpentinePaths([4,4],[1,2]));  # The number of all the serpentine paths for the matrix  4x4, starting with [1,2]-position
nops(SerpentinePaths([4,4],[2,2]));  # The number of all the serpentine paths for the matrix  4x4, starting with [2,2]-position

[Matrix(3, 3, {(1, 1) = 1, (1, 2) = 6, (1, 3) = 7, (2, 1) = 2, (2, 2) = 5, (2, 3) = 8, (3, 1) = 3, (3, 2) = 4, (3, 3) = 9}), Matrix(3, 3, {(1, 1) = 1, (1, 2) = 8, (1, 3) = 7, (2, 1) = 2, (2, 2) = 9, (2, 3) = 6, (3, 1) = 3, (3, 2) = 4, (3, 3) = 5}), Matrix(3, 3, {(1, 1) = 1, (1, 2) = 8, (1, 3) = 9, (2, 1) = 2, (2, 2) = 7, (2, 3) = 6, (3, 1) = 3, (3, 2) = 4, (3, 3) = 5}), Matrix(3, 3, {(1, 1) = 1, (1, 2) = 4, (1, 3) = 5, (2, 1) = 2, (2, 2) = 3, (2, 3) = 6, (3, 1) = 9, (3, 2) = 8, (3, 3) = 7}), Matrix(3, 3, {(1, 1) = 1, (1, 2) = 2, (1, 3) = 9, (2, 1) = 4, (2, 2) = 3, (2, 3) = 8, (3, 1) = 5, (3, 2) = 6, (3, 3) = 7}), Matrix(3, 3, {(1, 1) = 1, (1, 2) = 2, (1, 3) = 3, (2, 1) = 8, (2, 2) = 7, (2, 3) = 4, (3, 1) = 9, (3, 2) = 6, (3, 3) = 5}), Matrix(3, 3, {(1, 1) = 1, (1, 2) = 2, (1, 3) = 3, (2, 1) = 8, (2, 2) = 9, (2, 3) = 4, (3, 1) = 7, (3, 2) = 6, (3, 3) = 5}), Matrix(3, 3, {(1, 1) = 1, (1, 2) = 2, (1, 3) = 3, (2, 1) = 6, (2, 2) = 5, (2, 3) = 4, (3, 1) = 7, (3, 2) = 8, (3, 3) = 9})]

 

[]

 

52

 

25

 

36

(1)


Below we find 12,440 serpentine paths in the matrix  6x6 starting from various positions (the set  L )

k:=0:  n:=6:
for i from 1 to n do
for j from i to n do
k:=k+1; S[k]:=SerpentinePaths([n,n],[i,j])[];
od: od:
L1:={seq(S[i][], i=1..k)}:
L2:=map(A->A^%T, L1):
L:=L1 union L2:
nops(L);

12440

(2)


Further, using the list  L, we generate 20 examples of Numbrix puzzles with the unique solutions

T:='T':
N:=20:
M:=[seq(L[i], i=combinat:-randcomb(nops(L),N))]:
for i from 1 to N do
for k from floor(n^2/4) do
T[i]:=Matrix(n,{seq(op(M[i])[3][j], j=combinat:-randcomb(n^2,k))});
if nops(NumbrixPuzzle(T[i]))=1 then break; fi;
od:  od:
T:=convert(T,list):
T1:=[seq([seq(T[i+j],i=1..5)],j=[0,5,10,15])]:
DocumentTools:-Tabulate(Matrix(4,5, (i,j)->T1[i,j]), fillcolor = "LightYellow", width=95):


The solutions of these puzzles

DocumentTools:-Tabulate(Matrix(4,5, (i,j)->NumbrixPuzzle(T1[i,j])[]), fillcolor = "LightYellow", width=95):

 


For some reason, these 20 examples and their solutions did not load here.

 Edit. I separately inserted these generated 20 puzzles as a picture:

 

Download SerpPathsinMatrix.mw

 

I know you can call python from Maple, I am thinking if there is the other way around. That is use Maple (and its toolbox) as backend engine to do calculations (e.g. Global Optimization), and say manipulate the data in Python as the front-end.

The following differential equation:

sy := (dsolve({T*diff(y(x), x, x) + rho*omega^2*y(x) = 0, y(0) = 0, y(L) = 0}, y(x)) assuming (0 < T, 0 < omega, 0 < rho))

                                                                 sy:=y(x)=0

Maple only returns the trivial solution. Should return other expressions:
Thank you

First 11 12 13 14 15 16 17 Last Page 13 of 1582