MaplePrimes Questions

From the help file in StringTools - Split:


There is no information about how this is done, though.

Good day sirs, 

I have a code given the error code "Warning, solving for expressions other than names or functions is not recommended".

Please, anyone with useful information. 

Thank you in anticipation for the your response.

The Maple file is attached below.

Expression.mw

Apparently it isn't possible to access components in a workbook from procedures from a library.

Just wanted to know if that is correct, or if I am missing something here.

E.g. this procedures should delete contents of TextAreas with endings defined in a list of variables. Works nicely in the workbook, but when putting the procedure in a library, it apparently doesn't work anymore.
 

ResetCombobox := proc (var::set) local i; for i in var do if ComponentExists(cat("TextArea_", i)) then SetProperty(cat("TextArea_", i), value, 0) elif ComponentExists(cat("ComboBox_", i)) then  else Advarsel(cat("No component found for ", i)) end if end do end proc


 

Download ResetCombobox.mw

Why would simplify(t^2*x^2+t^2*y^2)  give  (x^2 + y^2)*t^2 but with seemingly same input except changing `+` to `-` fails now to simplify it?  simplify(t^2*x^2-t^2*y^2) gives t^2*x^2-t^2*y^2

Just trying to understand the logic behind this behavior.

In Mathematica both do simplify as can be seen below, which is what one would expect.

Should Maple hangs when one quits a debugger in the middle of debugging session, and there is a call to the same function with a DEBUG break point in it next?

For example

restart;
foo:=proc()
  local x;
  DEBUG();
  x:=x+1
end proc;

And now in the next same execution group, I had

> foo(); #quitting debugger here makes Maple hangs/freeze

  foo();

 

When evaluating the above, the debugger comes up as expected when first call to foo() is made.

When quitting the debugger either by hitting Quit or by hitting the close red X at top right corner, Maple now hangs. I was expecting the debugger to come up again for the second call to foo().  

It seems closing the debugger window like this for some reason is not handled correctly. Even if the user is not supposed to do this, Maple should not just freeze like this.

Nothing I do causes it to unfreeze. Clicking on the ! button does nothing. Only way is to either kill Maple from task manager or close all of Maple if possible and sometimes this does not even work, ending possibly losing work done on other open worksheets.

Maple should be more robust that this. Does this happen on other platforms?

This problem does not happen if the calls were each in a separate execution group in the worksheet. Like this

> foo();

> foo();

Using Maple 2021.2 on windows 10.

 

VertexConnectivity returns the vertex connectivity of a graph, that is the minimum number of vertices whose removal disconnects the graph.  When I was filtering some graphs with a certain  vertex connectivity, maple was much slower than mathematica. I'm going to store all graphs in file  named op21new.g6.  When mathematica selects all graphs with a connectivity of 6, it only takes 15 seconds to complete.

mma codes are the following 

L = Import[
  "C:/Users/asus/Desktop/op21new.g6"]; # Change this line
t = AbsoluteTiming[L1 = Select[L, VertexConnectivity[#] == 6 &];]

{15.6484, Null}

But my maple has been running for half an hour and it is not over yet.

with(GraphTheory):
L:=ImportGraph("C:/Users/asus/Desktop/op21new.g6", graph6, output=list): # Change this line
L2:=CodeTools:-Usage(select(g->VertexConnectivity(g)=6,L)):

Because Mapleprimes does not support graph6 format file uploading, I changed it to TXT format. If you want to use it, you only need to change the suffix name.

op21new.txt

Hi, I'm trying to solve auxilary equation to find its familes but I don't know what I'm doing wrong as I'm using following code:

famtemp := (diff(z(xi), xi))^2-a*z(xi)^2-b*z(xi)^3-c*z(xi)^4;

fam1 := simplify(`assuming`([dsolve(famtemp)], [b::real, a::real, c::real, -4*a*c+b^2 > 0, a > 0]))

I want to get the following family:

fam1 := 2*a*sech(sqrt(a)*xi)/(sqrt(-4*a*c+b^2)-b*sech(sqrt(a)*xi));

I hope someone will help me to solve it.

Thanks

I'm trying to execute a code but i am having the following error:

Error, cannot determine if this expression is true or false: 257^(1/2) < -79999999/10000000

The entire procedure is downloadable here: https://www.mediafire.com/file/3iiwmipruhtlhzx/Newton+Bairstow-+proyecto1.mw/file

If someone can help me to find a solution I'll be very thankful.

HOW TO DECIDE THE TRIPLE INTEGRAL IS POSITIVE, NEGATIVE OR ZERO WITHOUT CALCULATING IT?

restart;

f:=(x,y)->x^4-3*x^2-2*y^3+3*y+0.5*x*y;

proc (x, y) options operator, arrow; x^4-3*x^2-2*y^3+3*y+.5*y*x end proc

(1)

 

Critical points: tangentline in x direction and y direction are  0  for some points on the surface  f(x,y)  

 

CriticalPoints:= [ solve( {diff(f(x,y),x)=0,diff(f(x,y),y)=0}, {x,y}) ];

[{x = 0.5935572277e-1, y = .7105957432}, {x = 1.191117672, y = .7741187286}, {x = 1.255942703, y = -.7776000848}, {x = -0.5877159444e-1, y = -.7036351094}, {x = -1.197482099, y = -.6326213916}, {x = -1.250162405, y = .6291421140}]

(2)

         

Seems that maple calculate 6 points on the surface with a default domain?

let me make a  3D plot of f  ( not specifying the domain values)

plot3d(f);

 

 

I calculated 6 critical points :how to show them in the plot? : i calculate the functionvalues for f
So now i do have x,y,z values for a 3D point
plot3D ({ f, points}) ?

?student

 

Some information to find in

• 

 Student[MultivariateCalculus]  ..link?

• 

Multivariate Calculus Study Guide

In order to make a procedure ( to make it general) out of the wanted calculated steps , i must first calculate these steps
List of wanted steps:

1. 

calculate (6 )critical points : i did

2. 

investigate of the found critical points :are there saddle points among them?
Show this in a table

3. 

show a critical point with 2 section lines in this critical point intersected in a plot

4. 

show these critical points in a plot

===========================================

How to make table out of this list.CriticalPoints. for easy reading.?

==========================================

CriticalPoints:= [ solve( {diff(f(x,y),x)=0,diff(f(x,y),y)=0}, {x,y}) ];

[{x = 0.5935572277e-1, y = .7105957432}, {x = 1.191117672, y = .7741187286}, {x = 1.255942703, y = -.7776000848}, {x = -0.5877159444e-1, y = -.7036351094}, {x = -1.197482099, y = -.6326213916}, {x = -1.250162405, y = .6291421140}]

(3)

 

Download zadelpunten_procedure.mw

Hi! 2 questions

1. I notice that the Curl operator of the VectorCalculus package can't compute the Divergence of a 2D vector field. Of course the most classical case is 3D, but it can also be defined for 2D. Is there any way in Maple to compute the Curl of a 2D vector field using the Curl command?

2. How one can extract the components of a VectorField ? I tried op, GetComponents (LieVectoFields package) etc... but I didn't find a simple answer on the help pages. 

e.g. V1 := VectorField(<-x, -y>, cartesian[x, y])

I want to get {-x,-y}

Many thanks !

Dear all, 

I am trying to use another notation for the inert differential operators in the Physics package (using alias), I am not getting the correct result. Does anyone know how I can solve this issue? Many thanks!

 

I want to solve a differential equation with piecewise function, but I face an error. I am wondering how to handle it. Thanks

t[1]:=1

x := t -> piecewise(0 <= t and t < t[1], -60*t + 100, t[1] <= t and t <= 10, 1.645*sqrt(480*t))

dsolve({diff(p(t), t) = 2*h*x(t), p(T) = 0}, p(t))

and the error is :

"Error, (in dsolve) found the following equations not depending on the unknowns of the input system: {pT = 0}"

t[1] := 1.05

1.05

(1)

x := proc (t) options operator, arrow; piecewise(0 <= t and t < t[1], -60*t+100, t[1] <= t and t <= 10, 1.645*sqrt(480*t)) end proc

proc (t) options operator, arrow; piecewise(0 <= t and t < t[1], -60*t+100, t[1] <= t and t <= 10, 1.645*sqrt(480*t)) end proc

(2)

dsolve({p*T = 0, diff(p(t), t) = 2*h*x(t)}, p(t))

Error, (in dsolve) ambiguous input: the variables {p} and the functions {p(t)} cannot both appear in the system

 

``

Download Error.mw

I am trying to anime a pump but itn't working. I need help. Thank you. restart; with(plots); with(plottools); unprotect(D); alpha := arctan(-58/62.5); solve({k*Pi/100 = alpha}, {k}); beta := arctan(19/84); solve({k*Pi/100 = beta}, {k}); ang1 := arctan(-68/84); evalf(solve({k = ang1}, {k})); ang2 := arctan(55/84); evalf(solve({k = ang2}, {k})); #angular head travel Head := proc(k) local r, poly, k1, tC, tD, tE, DikC, DikD, DikE; global C, D, E; r := 84; C := [-55, 17]; D := [0, 0]; E := [84, 0]; poly := [[-60, 24], [63, -17], [60, -55.5], seq([r*cos(1/100*k*Pi), r*sin(1/100*k*Pi)], k1 = -24 .. 7), [82, 18], [78, 20], [64, -3], [-46.5, 35]]; tC := textplot([C[], "C"], align = {above, right}, font = [Times, bold, 18]); tD := textplot([D[], "D"], align = {above, left}, font = [Times, bold, 18]); tE := textplot([E[], "E"], align = {above, left}, font = [Times, bold, 18]); DikC := disk(C, 1, color = black); DikD := disk(D, 1, color = black); DikE := disk(E, 1, color = black); if 0

I am looking for a robust way to factor an expression (if applicable) to become    x^n*(rest)  as we do it by hand.

edit The input will only be of type `+` and I am looking for a way extract a common factor to convert the input to term^n*(rest) where term is the common factor to pull out.

For example, given  x^2*Y+x and the symbol is given as x  the result will be x*(x*Y+1) and if the input is Y^2*x^3-x^3 then the output is x^3*(Y^2-1) and if there is no common factor x to pull out from all the terms, the output will be the same as the input.

I tried many commands and options, but can't find one method that works all the time for all cases.

For example for   x^2*Y+x  the command factor(x^2*Y+x) gives (Y - 1)*(Y + 1)*x^3 which is not what I want. There is no option to factor to give the name to factor on. And I did not know how to use the last argument of function to do that.

But here simplify(x^2*Y+x) happened to work on this and gives (Y^2 - 1)*x^3 but simplify does not work on first example. simplify(x^2*Y+x) returns the same expression back. So simplify is not reliable to use.

I tried collect, with options factor and simplify. Again, they work on one examples but not others. 

collect(x^2*Y+x,x); does not do it. But collect(Y^2*x^3-x^3,x); works and returns (Y^2 - 1)*x^3 which is what I want.

The problem is that I do not know what the expression looks like. I just know the name and want to find if there is a common to any power that can be pulled out to rewite the expression as x^n*(rest) where is an integer or rational number depending.

This seems like a simple problem. But can't find a Maple command for.   I could ofcourse program it by brute force. Go over each term in the expression, check if each term has a free to any power in it multiplied by something else, then collect all these x^n term in a list. At end find the which is raised to lowest power, and then divide the whole expression by it. 

Here is another way I can also try:  Use factor and also collect and also simplify. One at a time. Each time I check if the result is of type `*` but not a division! (check that denom is 1). If so, Then check if result has two operands only. If so, check if op(1,result) is for form x^anything. If so, then one of these cases worked.  Need to try this now to see if it will work on all cases I have. 

Is there a better way to do this in Maple? It has to work on all expresions f(x) without knowing what the expression looks like.

update

I've updated the test cases and included all algorithms given to compare. It is hard in Maple to make a nice table to present results and keep math formatting below.

restart;
makegrid := proc(M::Matrix)#https://www.mapleprimes.com/questions/202902-How-To-Create-Table-Like-Output-For
  uses DocumentTools:-Layout;
  local i,j,m,n,wks;
  m,n := op(1,M);
  wks := Worksheet(Table(alignment=center,width=20,
                         seq(Column(),j=1..n),
                         seq(Row(seq(Cell(Textfield(sprintf("%a",M[i,j]))),
                                     j=1..n)),i=1..m)));
  DocumentTools:-InsertContent(wks);
end proc:

acer_V1_common_factor := proc(x::algebraic, ee::algebraic)
  local p, d := gcd(ee, x^frontend(degree,[ee,x]),'p');
  d * p;
end proc:

acer_V2_common_factor := proc(x, ee) local d, t;
  if ee::`+` then
    t := max(map(proc(u) local r:=frontend(degree,[u,x]);
                         `if`(r::numeric,r,0); end proc,[op(ee)]));
    d := gcd(numer(ee),x^t);
    d*map(u->u/d,ee);
  else ee; end if;
end proc:

dharr_common_factor:=proc(x,z)
  local xn:=x^ldegree(collect(z,x),x);
  if rem(z,xn,x)=0 then xn*quo(z,xn,x) else z end if;
end proc:

me_common_factor:=proc(term,expr)
local tmp;
local T1;

local update_T1:=proc()
T1:= hastype(op(1,tmp),identical(term)^anything) or hastype(op(1,tmp),identical(term));
if not T1 then
   T1:= hastype(op(2,tmp),identical(term)^anything) or hastype(op(2,tmp),identical(term));
fi;
end proc;

if type(expr,`*`) or not has(expr,term) then 
   return expr;
fi;

tmp := collect(expr,term);       
if type(tmp,`*`) and evalb(denom(tmp)=1) and evalb(nops(tmp)=2) then
   update_T1();
   if T1 then
       return tmp;
   fi;
fi;

tmp :=factor(expr);
if type(tmp,`*`) and evalb(denom(tmp)=1) and evalb(nops(tmp)=2) then
    update_T1();
    if T1 then
      return tmp;
    fi;
fi;

tmp := simplify(expr);
if type(tmp,`*`) and evalb(denom(tmp)=1) and evalb(nops(tmp)=2) then
    update_T1();
    if T1 then              
      return tmp;
    fi;
fi;

return expr;
end proc:
############################

test_data:=[[x,x^2*Y+x],
[x,Y^2*x^3-x^3],
[x,x],
[x,x+2*x^2],
[x,x^4*diff(y(x),x)+x^7],
[x,x^4*diff(y(x),x)+x^7-sin(x)],
[y(x),y(x)^4*diff(y(x),x$2)^2*diff(y(x),x)+y(x)^2*diff(y(x),x)+y(x)],
[y(x),y(x)^4*diff(y(x),x$2)^2+y(x)^2*diff(y(x),x)+y(x)^9],
[x,x^4*y^2+x^2*y^2],
[y(x),y(x)^4*diff(y(x),x)^2+y(x)^2*diff(y(x),x)^2],
[diff(y(x),x),y(x)^4*diff(y(x),x)^2+y(x)^2*diff(y(x),x)^2],
[diff(y(x),x),y(x)*diff(y(x),x$2)^2*diff(y(x),x)*sin(x)+diff(y(x),x)^3],
[y(x),diff(y(x),x)-(1+x^(1/2))/(1+y(x)^(1/2))],
[y(x),diff(y(x),x) -(x-1)*y(x)^5/x^2/(-y(x)+2*y(x)^3)],
[y(x),3*y(x)+diff(y(x),x) - 2*x/exp(3*x)],
[x,3*x^2*y^3+7*x/y],
[y,A-(1+x)/(1+y^(1/2))]
]:
RESULT:=Matrix(nops(test_data),6);
for N,item in test_data do
    term:=item[1];
    expr:=item[2];
    RESULT[N,1]:=term; RESULT[N,2]:=expr;
    try
        result:=acer_V1_common_factor(term,expr);
        if type(result,`*`) and denom(result)<>1 then
           RESULT[N,3]:=expr;#bypass, not correct output
        else
           RESULT[N,3]:=result;#accept
        fi;  
    catch:
        RESULT[N,3]:=expr;#reject
    end try;      

    try
        result:=acer_V2_common_factor(term,expr);
        if type(result,`*`) and denom(result)<>1 then
           RESULT[N,4]:=expr;#bypass, not correct output
        else
           RESULT[N,4]:=result;#accept
        fi;  
    catch:
        RESULT[N,4]:=expr;#reject
    end try;      

    try
        result:=dharr_common_factor(term,expr);
        if type(result,`*`) and denom(result)<>1 then
           RESULT[N,5]:=expr;#bypass, not correct output
        else
           RESULT[N,5]:=result;#accept
        fi;  
    catch:
        RESULT[N,5]:=expr;#reject
    end try;      


    try
        result:=me_common_factor(term,expr);
        if type(result,`*`) and denom(result)<>1 then
           RESULT[N,6]:=expr;#bypass, not correct output
        else
           RESULT[N,6]:=result;#accept
        fi;  
    catch:
        RESULT[N,6]:=expr;#reject
    end try;      

od:

RESULT

how_to_do_special_factor.mw

Mapleprime will not let let insert content for some reason. Here is the output as screen shot but it is hard to read. But it is in the above worksheet.

First 237 238 239 240 241 242 243 Last Page 239 of 2308