Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Hi, I try to create quizes in Maple 2016, but I don't know how to hide the Maple commands. Is it possible?


 

I'd like my students to see only 

 

when they access the quiz. Any help will be highly appreciated. Thank you.
 

I can not understand why the following statement works perfectly:
with (plots);
P1: = plot (f (x), x = xmin .. xmax, y = ymin .. ymax, color = "green");
P2: = plot (orddir, x = xmin .. xmax, y = ymin .. ymax, color = "blue");

Plots [display] (plottools [line] ([ascf, ymin], [ascf, 10]), color = red;
Plot ([5, y, y = 0 .. 10]);
P3: = implicit plot (x = ascf, x = xmin .. xmax, y = ymin .. ymax, color = red, linestyle = 3, thickness = 2);
P4: = plot (points, x = xmin .. xmax, y = ymin .. ymax, style = point, symbol = circle, symbolsize = 20, color = "black");
P5: = plot (h, x = xmin .. xmax, y = ymin .. ymax, color = "yellow");
Display ({p1, p2, p3, p4, p5}, axes = normal, scaling = unconstrained, title = "Parallel, vertice, focus, direction and axis of symmetry", gridlines = true);

While in the following
Points: = [F, V, A, B];
with (plots):
P1: = plot (f (x), x = xmin .. xmax, y = ymin .. ymax, color = "green");
P2: = plot (yd, x = xmin .. xmax, y = ymin .. ymax, color = "blue");
P3: = implicitplot (x = xv, x = xmin .. xmax, y = ymin .. ymax, color = red, linestyle = 3, thickness = 2);
P4: = plot (points, x = xmin .. xmax, y = ymin .. ymax, style = point, symbol = circle, symbolsize = 20, color = "black");

Do (% Plot0 = display ({p1, p2, p3, p4}, axes = normal, scaling = unconstrained, title = "Parallel, vertices, focus, direction and axis of symmetry", gridlines = true));

P4 does not print anything. In thanking you for the kind attention, I cordially greet you. Carmine Marotta ..


 

How is it possible that  GraphTheory:-TravelingSalesman  
is much slower than a simple brute-force solution?

 

restart;

n:=10:

A:=Matrix(n, (i,j)->`if`(i=j,0,n*(n-i)^4+2*j+(n-i)^2+j^3)):A[1,2]:=100*n^3:A;

Matrix([[0, 100000, 65724, 65763, 65826, 65919, 66048, 66219, 66438, 66711], [41027, 0, 41057, 41096, 41159, 41252, 41381, 41552, 41771, 42044], [24062, 24071, 0, 24131, 24194, 24287, 24416, 24587, 24806, 25079], [12999, 13008, 13029, 0, 13131, 13224, 13353, 13524, 13743, 14016], [6278, 6287, 6308, 6347, 0, 6503, 6632, 6803, 7022, 7295], [2579, 2588, 2609, 2648, 2711, 0, 2933, 3104, 3323, 3596], [822, 831, 852, 891, 954, 1047, 0, 1347, 1566, 1839], [167, 176, 197, 236, 299, 392, 521, 0, 911, 1184], [14, 23, 44, 83, 146, 239, 368, 539, 0, 1031], [3, 12, 33, 72, 135, 228, 357, 528, 747, 0]])

(1)

with(GraphTheory):

G:=Graph(A);

GRAPHLN(directed, weighted, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], Array(%id = 18446744074326770022), `GRAPHLN/table/1`, Matrix(%id = 18446744074326769782))

(2)

t:=time[real]():
TravelingSalesman(G);
'time'=time[real]()-t;

156750, [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 1]

 

time = 36.410

(3)

############### brute-force #############

t:=time[real]():
P:=Iterator:-Permute([seq(2..n)]):
cmin:=infinity: ord:=<"none">:
for  v in P do
  f:=add(A[v[k],v[k+1]],k=1..n-2) + A[1,v[1]]+A[v[n-1],1];
  if f<cmin then cmin:=f; ord:=copy(v) fi;
od:
cmin,[1, entries(ord,'nolist',indexorder),1];
'time'=time[real]()-t;

156750, [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 1]

 

time = 1.715

(4)

# And for n=11 I had to interrupt TravelingSalesman;
# brute-force still works for n=12.


 

Download TravelingSalesman-test.mw

Sometimes when one write a proc(), and later make changes, some of the earlier local variables could no longer used after the new edits.

In a small proc, it is easy to spot visually which ones are no longer needed and to remove them. But for a large proc() with many local variables, it is harder.

Does maple have a tool  to help one find which are the unused local declarations are not used? For example

foo:=proc(x)
local y,z:
x^2;
end proc;

I'd like maple to tell me that `y` and `z` are unused when I asked it to. (may be by highlighting or warning)

Mathematica has such a tool (and more) in its workbench editor which is very useful. does one need an external tool in Maple to do this?

Experts.

I'm trying to solve a Truck Routing Problem. I set in up in Maple and Excel, but I get a smaller minimum in the spreadsheet, than in Maple. Its like as if I havn't generated enough possible routes, even though i feel i've done an exaustive search. I realise the distance matrix violates the triangle inequality.  Any suggestions....

TRP_14x3.mw

A very big data was imported by me through

data := Import("http://fs3.fex.net/get/245716150875/11071260/data.txt");
"3.0994584798345
22.889020258043
....

26.082759642081
42.911810680717
6.4578968130322"



I need to convert it to Vector/Array. Now its type is "string":

whattype(data);
                             string

Here is my unsuccessful attempt:

convert(data,Vector);
Error, invalid input: `convert/Vector` expects its 1st argument, V, to be of type {Array, Matrix, Vector, array, sequential}, but received 3.0994584798345
22.889020258043
....

data.mw

Hey. Sorry if this is the wrong place to post, as I'm new here. Anyways, I'm trying to find the global maximum of a function, directly via Maple Commands, I've found that Maximize, does a good job to some degree, but when faced with "harder" constraints such as x^2+y^2=>1 it fails (or atleast I do :) ). I know that in WolframAlpha you can write that following as an example: 

Maximize[{(1-y^2)/(x^2), x^2 + y^2 <= 1,x>=1/2}, {x, y}]

http://www.wolframalpha.com/input/?i=Maximize%5B%7B(1-y%5E2)%2F(x%5E2),+x%5E2+%2B+y%5E2+%3C%3D+1,x%3E%3D1%2F2%7D,+%7Bx,+y%7D%5D

How would I do this in Maple? Any help would be more than welcome!! Thanks :D 

I am new user of Maple, couldn’t find solution for my problem in the last two days therefore I would like to turn to your community with my question. I am trying to replicate the calculations from a study to be sure about my understanding of the topic.

 

I cannot simplify the final equation even though the variables with their values are given. A screenshot and the file are attached, that might make easier to understand my problem.

I know what the solution should be. I cannot simplify/replace the values in the equation to get a simpler form; [(D0 - d1c - R)/ 2d1)]+c

 

Thank you if you have the time to help.

 

Joint_Pricing_Sol_.maple

i count the number among group
but when the list a large such as over 1000 records, the count will be over 30,000
use which denominator to find probability?
is there any functions in maple for this case?
 
with(LinearAlgebra):
correlationlist1 := [[1,2,3],[1,3,5]....]:
PAB := Matrix(50):
for ii from 1 to nops(correlationlist) do
 for jj from 1 to nops(correlationlist[ii]) do
  for kk from 1 to nops(correlationlist) do
   for qq from 1 to nops(correlationlist[kk]) do
    if ii <> kk then
     #print("scan=",correlationlist2[kk],"kk=",kk,"qq=",qq,"row=",correlationlist[ii][jj],"column=",correlationlist[kk][qq]):
     PAB[correlationlist[ii][jj],correlationlist[kk][qq]] := PAB[correlationlist[ii][jj],correlationlist[kk][qq]] + 1: # group to group relations
    end if:
   od:
  od:
 od:
od:

hey guys ,

 

i have problem to obtain roots for a higher order equation

 

thanks for your helppp.mw

If there is a list

[[1,2],[2,2],[3,3]...

how to use correlate function?

assume [1,2] and [2,1] count as 2 

when find correlation between 1and 2

and how about 

if [1,2] and [2,1] are different

first position as key

means 1 relate with 2 count as 1 case for 1 only

[2,1] count as 1 case for 2 only

 

How do I check if there are any solutions to this equation:
1/(u+v)^2+4*u*v-1=0
where both u and v are real numbers larger than 0.

Hi, my question is concerning a "summand counting function" i require ie suppose for the following input

of [a+b+c,a+b,a+b+c+d,a] mapping this function will produce the output [3,2,4,1]

Hi Maple Users

I am trying to use GRADIENT (with(codegen)) with a proc that includes hypergeom function but it produces the following error:

Error, (in GRAD/givedname) incorrect syntax in parse: unexpected end of input (near 4th character of parsed string)

When I remove the bits including hepergeom function it works so there seems to be some parsing problem with hypergeom. The proc is below ( I have simplified the code by assignig values to some variables). Any help is appreciated.

OV := proc(d1, d2, o)
    local noc, lambda1, lambda2, nu1, nu2, z1, z2, a1, a2, p1, p2, x1, x2, Be1, Be2, q1, q2, w1, w2, aprime, zprime, nx, nBe;
    local hg1, hg2, hg3, hg4;
       
    lambda1 := 5.22;
    lambda2 := 2.36;
    nu1 := 12.96;
    nu2 := 4.23;
    z1 := 4.99;
    z2 := 1.43;
    
    a1 := lambda1 * nu1;
    a2 := lambda2 * nu2;
    
    p1 := 1;
    p2 := 1;


    x1 := exp(a1/z1 + lnGAMMA(d1/z1 + 1) - d1/z1 * ln(a1/z1));
    x2 := exp(a2/z2 + lnGAMMA(d2/z2 + 1) - d2/z2 * ln(a2/z2));
    
    Be1 := 1 / (GAMMA(d1/z1 + 1, a1/z1) * x1 / GAMMA(d1/z1 + 1));
    Be2 := 1 / (GAMMA(d2/z2 + 1, a2/z2) * x2 / GAMMA(d2/z2 + 1));
    
    q1 := lambda1 * nu1 * Be1;
    q2 := lambda2 * nu2 * Be2;
        
     hg1 := hypergeom([p1, -d1 / z1 + 1 , a1 / z1 + p1 + 1], [a1 / z1 + p1], -z1 / a1);
     hg2 := hypergeom([-d1 / z1 + 1, p1 + 1, a1 / z1 + p1 + 2], [a1 / z1 + p1 + 1], -z1 / a1);
     hg3 := hypergeom([p2, -d2 / z2 + 1 , a2 / z2 + p2 + 1], [a2 / z2 + p2],-z2 / a2 );
     hg4 := hypergeom([-d2 / z2 + 1, p2 + 1, a2 / z2 + p2 + 2], [a2 / z2 + p2 + 1], -z2 / a2);
     
    w1 := z1 - q1 + a1 * (a1 + p1 * z1) * hg1 / ((a1 + p1 * z1 + z1) * p1 * hg2 );
                    
    w2 := z2 - q2 + a2 * (a2 + p2 * z2) * hg3 / ((a2 + p2 * z2 + z2) * p2 * hg4 );
    
    aprime := q1 + q2;
    zprime := (w1 * q1 + w2 * q2) / aprime;

    nx := exp(aprime/zprime + lnGAMMA(o/zprime + 1) - o/zprime * ln(aprime/zprime));
    nBe := 1 / (GAMMA(o/zprime + 1, aprime/zprime) * nx / GAMMA(o/zprime + 1));
          
end proc:

GRADIENT(OV);

 

How to convert "123" into integer 123

i use sprintf %d still can not convert to integer

3 4 5 6 7 8 9 Last Page 5 of 1263