Maple 2021 Questions and Posts

These are Posts and Questions associated with the product, Maple 2021

Let N=pq be an odd semi-prime; What is the distribution of  integers that has a common divisor with N. We have shown that the distribution in [1,N-1] is a symmetric one, and there exsits a multiple of p lying to a multiple of q. We post the Maple source here.

 

gap := proc(a, b) return abs(a - b) - 1; end proc

HostsNdivisors := proc(N)

local i, j, g, d, L, s, t, m, p, q, P, Q, np, nq;

m := floor(1/2*N - 1/2);

L := evalf(sqrt(N));

P := Array();

Q := Array();

s := 1; t := 1;

for i from 3 to m do

   d := gcd(i, N);

    if 1 < d and d < L then P(s) := i; s++;

    elif L < d then Q(t) := i; t++; end if;

end do;

  np := s - 1;

  nq := t - 1;

 for i to np do printf("%3d,", P(i)); end do;

  printf("\n");

  for i to nq do printf("%3d,", Q(i)); end do;

  printf("\n gaps: \n");

  for i to np do

     for j to nq do

      p := P(i); q := Q(j);

      g := gap(p, q);

      printf("%4d,", g);

  end do;

    printf("\n");

end do;

end proc

 

HostOfpq := proc(p, q)

local alpha, s, t, g, r, S, T, i, j;

   S := 1/2*q - 1/2;

   T := 1/2*p - 1/2;

   alpha := floor(q/p);

    r := q - alpha*p;

   for s to S do

     for t to T do

       g := abs((t*alpha - s)*p + t*r) - 1;

        printf("%4d,", g);

      end do;

     printf("\n");

 end do;

end proc

 

MapleSource.pdf

MapleSource.mw

 

How to find all occurrences with Fibonacchi numbers?
100=89+8+2+1=89+5+3+1=55+34+8+2+1 etc...

fib := proc(n::nonnegint) option remember; if n <= 1 then n; else fib(n - 1) + fib(n - 2); end if; end proc;
zeck := proc(n::posint) local k, d; k := 2; while fib(k) <= n do k := k + 1; end do; d := n - fib(k - 1); if d = 0 then k - 1; else k - 1, zeck(d); end if; end proc;
zeck(100);
E := [fib(11), fib(6), fib(4)]; add(E[i], i = 1 .. nops(E));

Cong:=proc(n)
 local  a,b,An,Bn,Cn,Dn:
if n mod 2 = 1    
An:=0:     Bn:=0:    
for a  from (round(-sqrt(n/(2)))) to round(sqrt(n/(2)) )
do:           
for b  from (round(-sqrt(n)) )to round(sqrt(n) )do :               
if (sqrt(n-2*a^(2)-b^(2)) )/(32)isInteger                      
then An:=An+1                
elif (sqrt(n-2*a^(2)-b^(2)) )/(8) isInteger                      
then Bn:=Bn+1  fi:          
od:  od:
 if 2*An=Bn  
 return(True)  else  return(False)
fi: else if n mod 2 = 0 : 
Cn:=0:  Dn:=0:      
for a  from (round(-sqrt(n/(8)))) to round(sqrt(n/(8)) )
do :          
 for b  from (round(-sqrt(n/(2)))) to round(sqrt(n/(2))) do:                 
f (sqrt(n/(2)-4*a^(2)-b^(2)) )/(32)isInteger                      
then Cn:=Cn+1                
elif (sqrt(n/(2)-4*a^(2)-b^(2)) )/(8) isInteger
then Dn:=Dn+1 fi: od:  od:  
if 2*Cn=Dn:   
return(True)  else  return(False)fi:  
end:  

Why do I get this messge : Error, unterminated procedure. Thank you.

with(geometry);
with(LinearAlgebra);
xA := 1;
yA := 0;
xB := 0;
yB := 0;
xC := 0;
yC := 1;
Mat := Matrix(3, 3, [xA, xB, xC, yA, yB, yC, 1, 1, 1]);
Miv := MatrixInverse(Mat);
phi := (x, y) -> Transpose(Multiphy(Miv), <x, y, 1>);
for i to 6 do
    B || i := phi(xA || i, yA || i);
end do;
Error, (in LinearAlgebra:-Transpose) invalid input: too many and/or wrong type of arguments passed to LinearAlgebra:-Transpose; first unused argument is Vector(3, {(1) = xA1, (2) = yA1, (3) = 1})
How to correct this error ? Thank you.

Hi Maple friends,

Id like to create an animation that rotates my 3d plot. Here is the file: https://www.dropbox.com/scl/fi/zop0jpid0ik0a1unxrzzn/Dynamisches_Modell_Final_filled_conts-1.mw?rlkey=eo482ihqw9pw3vn6qolnxlrwa&dl=0

This is the 3d plot:

plot3d([Vth - Vps], E = 0 .. 1000000, T = 0 .. 15, labels = ["E in (EUR)", "T (in Jahren)", "V (in EUR)"], view = 0 .. 180000, labelfont = [times, bold, 12]);

The starting view should be the following (ankle: -137, 74, -2):

After rotation, tId like to see this view (ankle: 180, 0, 180):

Can someone please help me with this issue? That would be so nice!!

Thanks a lot in advance and best regards
Rebekka


Hello everyone, I am working on a Maple code where I am dealing with a matrix X and performing several operations, so I can subsitute a set of lists. However, I feel Im doing some redundant things and I wonder if there are ways to make it more concise and efficient. More specifically,

  1. 'vals' and 'ecs' :
    'vals' gives me a set of lists with the values I'll use in matrix X , e.g., vals := {[-1, 1, 0], [0, -1, -1], [0, -1, 1]}.
    'ecs' creates a set of lists of equations that I can use in 'eval' (or 'subs') function, e.g., ecs := {[[X3_4 = -1, X3_3 = 1, X2_3 = 0]], [[X3_4 = 0, X3_3 = -1, X2_3 = -1]], [[X3_4 = 0, X3_3 = -1, X2_3 = 1]]}.
    But clearly, I'm getting an extra pair of brackets for each list so I will need to use double index in the eval command. Is there a way to avoid this?
  2. In the subsitution step, I've tried with both 'eval' and 'subs' and many modifications to avoid what I did in step 1 but without success. Also I need this extra 'Nelem' to get a list of indices so I can substitute all possible lists of values in 'ecs'.
  3. Finally, I'm wondering if what I'm getting from 'BoolEigs' is actually what I want. My final goal is to check if the eigenvalues of all possible solution matrices I got in 'Xs'  are nonnegative. So I need to avoid numerical computations and perform this step exactly. Is my code correct for this?
     
X := Matrix([[1, -X3_3/2 - 1/2, 0, -X2_3], [-X3_3/2 - 1/2, -2*X3_4 - 1, X2_3, 0], [0, X2_3, X3_3, X3_4], [-X2_3, 0, X3_4, 1]]);
vars := [X3_4, X3_3, X2_3];

w := A^3 - A;
rootz := RootOf(w, A);
Pols := [(-A^2 + 1)/(3*A^2 - 1), (-A^2 - 1)/(3*A^2 - 1), A*(3*A^2 - 1)*1/(3*A^2 - 1)];

vals := {allvalues(eval(Pols, A = rootz))};
ecs := map(x -> convert(vars = x, listofequations), vals);

Nelem := [seq(k, k = 1 .. numelems(vals))];
Xs := map(x -> eval(X, ecs[x][1]), Nelem);#double index for eval
Xz := map(x -> subs(ecs[x][1], X), Nelem);#same for subs

with(LinearAlgebra);
Eigs := map(x -> Eigenvalues(x), Xs);
BoolEigs := map(x -> map(y -> is(Im(y) = 0) and is(0 <= Re(evalf(y))), x), Eigs);
evalf(Eigs);

point(A, xA, yA);
point(B, xB, yB);
point(C, xC, yC):
L3 := linestyle = 3
triangle(Tr, [A, B, C])
line(AP, [A, P]);
line(BP, [B, P]);
line(CP, [C, P]);
dr := draw([Tr(t3), AP(cbl, L3), BP(cbl, L3), CP(cbl, L3)]),
textplot([[coordinates(A)[], "A"], [coordinates(B)[], "B"], [coordinates(C)[], "C"]], align = {above, right});
display({dr, ellip}, scaling = constrained, axes = none, view = [-1 .. 14, -1 .. 11]);
Why doesn’t Maple show me the expected effect ? Thank you.

condi := [p1 + p2 + p3 = 1];
simplify(s, condi);
                  condi := [p1 + p2 + p3 = 1]

 /      c (-1 + p1 + p2)        c (-1 + p1 + p2)         
{ a = - ----------------, b = - ----------------,           c = c, 
 \             p1                               p2                

      c (p1 + p2) (-1 + p1 + p2)           c (p2 - 1)          c (p1 - 1)
  d = --------------------------,             e = ----------, f = ----------
                p1 p2                                       p1                 p2    

  \ 
   }
  / 


assigne(%);
c := 10;
a := factor(simplify(a, condi));
b := factor(simplify(b, condi));
d := factor(simplify(d, condi));
e := factor(simplify(e, condi));
f := factor(simplify(f, condi));
                            c := 10

                             a := a

                             b := b

                             d := d

                             e := e

                             f := f

NULL;
Why "factor" does not play its role ?   Thank you.

dr := draw([Tr(t3), AP(cbl), BP(cbl), CP(cbl)]),
textplot([coordinates(A)[], "A"], [coordinates(B)[], "B"], [coordinates(C)[], "C"], align = {above, right});
Error, (in plots:-textplot) unexpected options: [[0, 0, "B"], [13, 0, "C"]]
Why the coordinates are unrecognized ? Thank you.

xA := 4;
yA := 10;
xB := 0;
yB := 0;
xC := 13;
yC := 0;
Mat := matrix(3, 3, [xA, xB, xC, yA, yB, yC, 1, 1, 1]);
phi := (x, y) -> 1/Mat &x [x, y, z];
phi(4, 18/2);
phi(4, 10);
phi(13, 0);
Why the results are not calculated ? Thank you.

how to write the elements of the triangle of Pascal so that all 1 are aligned on a same vertical. Thank you.

f := x -> 2*x/(x + 3)

p1 := plot(f(x), x = 0 .. 100);

p2 := with(plots);
inequal(58 < x, x = 0 .. 100, y = 0 .. 2);

display([p1, p2]);

Error, (in plots:-display) expecting plot structures but received:

How do i combine to p1 and p2 in the same graph. They print well individually..  Its maple 2021

restart;
with(geometry);
with(plots);
_EnvHorizontalName = 'x';
_EnvVerticalName = 'y';
point(A, -3, 9);
point(B, -5, 0);
point(C, 6, 0);
xA := -3;
yA := 9;
xB := -5;
yB := 0;
xC := 6;
yC := 0;
triangle(ABC, [A, B, C]);
midpoint(M2, A, C);
midpoint(M1, B, C);
midpoint(M3, A, B);
coordinates(M1);
coordinates(M2);
coordinates(M3);
segment(sA, [A, M1]);
segment(sB, [B, M2]);
segment(sC, [C, M3]);
centroid(G, ABC);
midpoint(J1, A, G);
midpoint(J2, B, G);
midpoint(J3, C, G);
coordinates(J1);
coordinates(J2);
coordinates(J3);
zA := xA + yA*I;
zB := xB + yB*I;
zC := xC + yC*I:
diff((z - zA)*(z - zB)*(z - zC), z)*I;);
allvalues(%, z)
;I am trying to find focus of Steiner ellipse with Marden's theoreme. Thank you.

Dear Maple users/ experts

I have three functions, each with two parameters, alpha and delta, changing over 0..1. I want to partition the region in terms of what part gets the highest value. In the attached maple file, I used "implicit plot" and did it for any pair of functions in a reasonable time. But I don't know how these three plots can be consolidated into one. ('inequal' command was not precise while taking too long).  2D_implicitplot_with_three_functions.mw

Hi everyone and happy new year to all.

My question is: Is there a way to change the position of the axes labels in a plot? say, put them at the far end of the axes as some other softwares do. And is there any way to end the axes with arrows?

Axes labels position

kernelopts(version)

`Maple 2021.2, APPLE UNIVERSAL OSX, Feb 1 2022, Build ID 1590019`

(1)

y := proc (x) options operator, arrow; 1/abs(x) end proc

proc (x) options operator, arrow; 1/abs(x) end proc

(2)

plot(y(x), x = -4 .. 4)

 

Download labels.mw

1 2 3 4 5 6 7 Last Page 1 of 35