MaplePrimes Questions

Hello colleagues,

I would like to get a suggestion on how to utilize an existing `simplify` function or to define an operator, which allows the following simplification:

O(x^n)/x = O(x^(n - 1))

— Alexander

Hello

I need to test a huge amount of subsets and for doing that I was thinking of using combinat:-subset, since it avoids allocating memory for all subsets.  The problem with subset for my specific application is that it generates sets with all possible sizes and I just need subsets with a chosen number of elements.  Can that be done in maple?  

Many thanks

Ed

 

I have a plot of points in a graphical plot on the domain (x,y).  At each point xi (i=1..N) , there is a numerical value yi = S(xi) from which I plot a series of points (xi, S(xi)) in the (x,y) domain.     

Each point (xi,yi) represents a transient plot of two variables u(x,t) and v(x,t) in a plot file.  Is it possible to define a graph of the points (xi, S(xi)), such that clicking on any such point in the graph opens up a graphical file which is parameterised by (xi, S(xi))?

Would welcome help on this...

Melvin

Hi, 

when running a for do cycle the first two solutions are exact the same numbers, which is not correct. Can someone plesa help me fix this problem?

Thanks a lot.


 

restart

tmin:=10: #°C

tmax:=70: #°C

Tmin:=tmin+273.15:

Tmax:=tmax+273.15:

T:='T':

i:=0:

 

for T from Tmin by 2 to Tmax+1.25 do
i:=i+1:
a12:=2305.28444347652 - 9.14490843016421*T + 0.00680052257590234*T^2:
a21:=-6665.24838284836 + 46.0897018087247*T - 0.0694991633494123*T^2:
alfa:=0.3:
x2:=1-x1:
lng1:=x2^2*(tau21*(G21/(x1+x2*G21))^2+tau12*(G12/((x2+x1*G12)^2))):
lng2:=x1^2*(tau12*(G12/(x2+x1*G12))^2+tau21*(G21/((x1+x2*G21)^2))):
G12:=exp(-alfa*tau12):
G21:=exp(-alfa*tau21):
tau12:=a12/T:
tau21:=a21/T:
lnga1:=subs(x1=xa1,lng1):
lngb1:=subs(x1=xb1,lng1):
lnga2:=subs(x1=xa1,lng2):
lngb2:=subs(x1=xb1,lng2):
r1:=lnga1+ln(xa1)=lngb1+ln(xb1):
r2:=lnga2+ln(1-xa1)=lngb2+ln(1-xb1):
r:=fsolve({r1,r2},{xa1=0..0.22,xb1=0.22..1}):
assign(r):
xA1[i]:=xa1: xB1[i]:=xb1:
print(i,T,xA1[i],xB1[i]);
unassign('r1','r2','r','xa1','xb1'):
od:

1, 283.15, 0.4086195757e-1, .7650860222

 

2, 285.15, 0.4086195757e-1, .7650860222

 

3, 287.15, 0.4109304612e-1, .7564109743

 

4, 289.15, 0.4094687104e-1, .7455613500

 

5, 291.15, 0.4092946881e-1, .7345259571

 

6, 293.15, 0.4103899093e-1, .7233142804

 

7, 295.15, 0.4127502108e-1, .7119337099

 

8, 297.15, 0.4163857511e-1, .7003892047

 

9, 299.15, 0.4213210541e-1, .6886831535

 

10, 301.15, 0.4275956094e-1, .6768151230

 

11, 303.15, 0.4352648605e-1, .6647816285

 

12, 305.15, 0.4444014482e-1, .6525760020

 

13, 307.15, 0.4550971743e-1, .6401880864

 

14, 309.15, 0.4674655982e-1, .6276039487

 

15, 311.15, 0.4816452203e-1, .6148056135

 

16, 313.15, 0.4978038925e-1, .6017705621

 

17, 315.15, 0.5161445760e-1, .5884711603

 

18, 317.15, 0.5369126350e-1, .5748739966

 

19, 319.15, 0.5604059678e-1, .5609387793

 

20, 321.15, 0.5869882131e-1, .5466171048

 

21, 323.15, 0.6171072215e-1, .5318505354

 

22, 325.15, 0.6513208559e-1, .5165679944

 

23, 327.15, 0.6903339246e-1, .5006820935

 

24, 329.15, 0.7350533414e-1, .4840835134

 

25, 331.15, 0.7866732744e-1, .4666324128

 

26, 333.15, 0.8468127263e-1, .4481446382

 

27, 335.15, 0.9177527543e-1, .4283678555

 

28, 337.15, .1002878317, .4069372077

 

29, 339.15, .1107594115, .3832836608

 

30, 341.15, .1241550103, .3564111567

 

31, 343.15, .1425634130, .3241972432

(1)

 


 

Download lle.mw

lle.mw

Dear MaplePrimes community,

I am currently struggling to use the simplify-command in my toolbox for symbolic generation of robot dynamics.

I created a procedure which calls the simplify command with some extra checks. There are symbolic expressions in the term to be simplified that also occur in the workspace of the worksheet calling the procedure.

The simplify command (called from within the procedure) shall regard them as symbolic expressions unaware of the content of the variable in the workspace. Nevertheless, the simplifications are performed with the global variables, even though they are declared local to the procedure.

Minimal example: The variable "l1" stands for "length 1" in a mechanic problem as well as "length of the expression"

restart:
with(LinearAlgebra): with(ArrayTools): with(codegen): with(CodeGeneration): with(StringTools):
read proc_simplify2:
T := m2*(l1+l2)*(qD2)^2: # dummy-expression for kinetic energy
l1 := length(T);
T_simpl := simplify2(T):
l2 := length(T_simpl);

Code for the file proc_simplify2:

simplify2 := proc (Term)
  # Simplify a term. Additionally check if the simplification is advantageous.
  # In some cases the term gets longer after the simplification. Then discard.
  # Give the local procedure variable a long name. They must not be identical in Term.
  local simplify_tmpvar_c1, simplify_tmpvar_c1sum, simplify_tmpvar_c2, \
        simplify_tmpvar_c2sum, simplify_tmpvar_nms, simplify_tmpvar_k, Term2:
  # Assume all contents of the Term to be local variables to this procedure
  # Otherwise, variables like "l1" can be overwritten by occurences in the calling worksheet.
  simplify_tmpvar_nms:=convert(indets(Term,name),list): # get list of symbols
  for simplify_tmpvar_k from 1 to ColumnDimension(simplify_tmpvar_nms) do
    if simplify_tmpvar_nms[simplify_tmpvar_k] = Pi or simplify_tmpvar_nms[simplify_tmpvar_k] = 0 then
      next: # 0 and Pi can not be variables
    end if:
    eval(sprintf("local %s;", String(simplify_tmpvar_nms[simplify_tmpvar_k]))); # assume local
   end do:

  # Get computational effort before simplification
  simplify_tmpvar_c1:=add(cost~(Term)): 
  simplify_tmpvar_c1sum := diff(simplify_tmpvar_c1,functions)+ \
                           diff(simplify_tmpvar_c1,additions)+ \
                           diff(simplify_tmpvar_c1,multiplications)+\
                           diff(simplify_tmpvar_c1,divisions):
  # Perform simplification. Attention: tries to use global variables to simplify the expression (see above)
  Term2 := simplify(Term):
  # Get effort after simplification
  simplify_tmpvar_c2:=add(cost~(Term2)): 
  simplify_tmpvar_c2sum := diff(simplify_tmpvar_c2,functions)+\
                           diff(simplify_tmpvar_c2,additions)+\
                           diff(simplify_tmpvar_c2,multiplications)+\
                           diff(simplify_tmpvar_c2,divisions):
  if simplify_tmpvar_c2sum > simplify_tmpvar_c1sum then
    # The simplification was not successful. Take old version.
    Term2 := Term:
  end if:
  return Term2:
end proc:

I would be glad for suggestions how to define the symbolic expressions in Term as local to the procedure or perhaps a better way to perform simplifications. As my program extends over several worksheets and the user may define an input file, I would not like to have to control all names of temporary variables that may occur at some point in the project. Until I tried to use the simplify-command, there was no problem regarding variable names. Is it perhaps possible that the variables are now only declared local in the for loop and not in the procedure?

Why 

evalf(evalf(''Pi''))

Produces 

But

evalf(''Pi''):
evalf(%)

Produces

      3.141592654

 

 

How do I calculate the derivative of the function f(x)=( (x^3) / (2) ) - 5x + 2 and plot the function and it's derivative on the same graph. 

I am newcommer in Maple. I am using Maple 2019. Just a simple question;

solve(x^2-3*x+4=0, x);

gives

1.50000000000000 + (9.09238836013723*10^(-59))*I, 1.50000000000000 - (9.09238836013723*10^(-59))*I

instead I need to show in the forms of radiacal. I have also the problem in dsolve command;

dsolve(2*diff(y(x),x$2)+3*diff(y(x),x)+4*y(x),y(x));

with the result

y(x) = (2.73949338633639*10^(-116) + (2.73949338633639*10^(-116))*I)*_C1 + (1. + (2.73949338633639*10^(-116))*I)*_C2

Thanks indeed in advance

Sayed

 

Considering the follwoing expr:

A(x):=mue+(mun/gama)+(u0^2)-mud*x-mue*exp(x)-(mun/gama)*exp(gama*x)-(u0^2)*(1-2*x/u0^2)^(1/2);

where 

mue:=1/(1+alpha+beta);
mun:=alpha/(1+alpha+beta);
mud:=beta/(1+alpha+beta);
u0:=(mue+mun*gama)^(-1/2);
 and assuming the values of alpha and beta lie between 0.1..0.6 and gama=15 ro 20.

How do I determine those values of (alpha,beta,gama) satisfying conditions [(3), (4)], [(3), (5)] or [(3),(6)]?

conditions:

A(x[m] <> 0) = 0:

where x_m is an extreme point of A(x) (other than x=0),

d*A(x)/dx, x = x[m] < 0:

d*A(x)/dx, x = x[m] > 0:

d*A(x)/dx, x = x[m] = 0:

Can anyone please help me out with the following integration

 


                      f(x) = tanh(x)/sqrt(x^2+1)

 

limits x_initial =1, x_final =100

 

Thanks

 

Hi, 

 

Does it exist a way to get all the types a variable verifies?
For instance
x:=4;
type(x, t); # true for t in {positive, posint, algebraic, ...}

Thanks in advance

Hi,
How do I simplify the following polynomial:

 -(729 beta (1/2 (-1/9 (-5/27 beta-1/9) lambda^6-1/9 (1/9 beta^2 TT+(10/9 TE+2/3 TT) beta-1/9 TE) lambda^4+5/27 (2/5 TT (3/2 TT+TE) beta+TE (TE-2/5 TT)) beta lambda^2-1/9 TE beta^2 TT (-TT+TE)) p1(m,t)^2+(beta TT-1/3 lambda^2)^2 (-1/3 lambda^2+TE)^3 ((p2(m,t))/(lambda^2-3 TE)+3/2 ((lambda^2+TE) p1(m,t)^2)/((lambda^2-3 TE)^3))))/((3 beta TT-lambda^2)^3 (3 TE-lambda^2)^2),

as follows:

-3*beta*p2(m,t)/(lambda^2-3*beta*TT)+3*beta^2*(5*lambda^2-3*beta*TT)*p1(m,t)^2/(2*(lambda^2-3*beta*TT)^3)
?

restart;
solve({l*(2*l^2*lambda^4*sigma*w*a[2]+l^2*lambda^2*mu*w*b[1]+6*l*lambda^2*m*sigma*a[0]^2-6*l*lambda^2*m*b[1]^2+6*l*m*mu^2*a[0]^2-l*lambda^2*rho*sigma*a[0]-l*mu^2*rho*a[0]+4*lambda^2*sigma*w*a[0]+4*mu^2*w*a[0]) = 0, l*(2*l^2*lambda^3*sigma*w*a[1]+6*l^2*lambda^2*mu*w*b[2]+2*l^2*lambda*mu^2*w*a[1]+12*l*lambda^2*m*sigma*a[0]*a[1]-12*l*lambda^2*m*b[1]*b[2]-l*lambda^2*rho*sigma*a[1]+12*l*m*mu^2*a[0]*a[1]-l*mu^2*rho*a[1]+4*lambda^2*sigma*w*a[1]+4*mu^2*w*a[1]) = 0, l*(5*l^2*lambda^3*sigma*w*b[2]-3*l^2*lambda^2*mu*sigma*w*a[1]-7*l^2*lambda*mu^2*w*b[2]-3*l^2*mu^3*w*a[1]+12*l*lambda^2*m*sigma*a[0]*b[2]+12*l*lambda^2*m*sigma*a[1]*b[1]-l*lambda^2*rho*sigma*b[2]+24*l*lambda*m*mu*b[1]*b[2]+12*l*m*mu^2*a[0]*b[2]+12*l*m*mu^2*a[1]*b[1]-l*mu^2*rho*b[2]+4*lambda^2*sigma*w*b[2]+4*mu^2*w*b[2]) = 0, l*(8*l^2*lambda^3*sigma*w*a[2]+6*l^2*lambda*mu^2*w*a[2]+12*l*lambda^2*m*sigma*a[0]*a[2]+6*l*lambda^2*m*sigma*a[1]^2+l^2*lambda*mu*w*b[1]-6*l*lambda^2*m*b[2]^2-l*lambda^2*rho*sigma*a[2]+12*l*m*mu^2*a[0]*a[2]+6*l*m*mu^2*a[1]^2-6*l*lambda*m*b[1]^2-l*mu^2*rho*a[2]+4*lambda^2*sigma*w*a[2]+4*mu^2*w*a[2]) = 0, -l*(4*l^2*lambda^3*mu*sigma*w*a[2]-l^2*lambda^3*sigma*w*b[1]+l^2*lambda*mu^2*w*b[1]-12*l*lambda^2*m*sigma*a[0]*b[1]+l*lambda^2*rho*sigma*b[1]-12*l*lambda*m*mu*b[1]^2-12*l*m*mu^2*a[0]*b[1]+l*mu^2*rho*b[1]-4*lambda^2*sigma*w*b[1]-4*mu^2*w*b[1]) = 0, 6*l^2*(l*lambda^2*sigma*w*a[2]+lambda^2*m*sigma*a[2]^2+l*mu^2*w*a[2]+m*mu^2*a[2]^2-lambda*m*b[2]^2) = 0, 2*l^2*(l*lambda^2*sigma*w*a[1]+6*lambda^2*m*sigma*a[1]*a[2]+3*l*lambda*mu*w*b[2]+l*mu^2*w*a[1]+6*m*mu^2*a[1]*a[2]-6*lambda*m*b[1]*b[2]) = 0, -2*l^2*(5*l*lambda^2*mu*sigma*w*a[2]-l*lambda^2*sigma*w*b[1]+5*l*mu^3*w*a[2]-6*lambda^2*m*sigma*a[1]*b[2]-6*lambda^2*m*sigma*a[2]*b[1]-l*mu^2*w*b[1]-6*lambda*m*mu*b[2]^2-6*m*mu^2*a[1]*b[2]-6*m*mu^2*a[2]*b[1]) = 0, 6*l^2*b[2]*(l*w+2*m*a[2]) = 0}, {a[0], a[1], a[2], b[1], b[2]});
Warning, solutions may have been lost
{a[0] = 0, a[1] = 0, a[2] = 0, b[1] = 0, b[2] = 0}, 

   /       l rho - 4 w                                        \ 
  { a[0] = -----------, a[1] = 0, a[2] = 0, b[1] = 0, b[2] = 0 }
   \          6 l m                                           / 
 

Problems with incomplete worksheet.

I have saved a .mw worksheet, which i cannot open in Maple, and i get an error code:
"There were problems during the loading process. Your worksheet may be incomplete"

I have attached a link, where a user is helped with the same problem, but i cannot understand the solution there has been given:

https://www.mapleprimes.com/questions/125503-Incomplete-Worksheet

I have attached the worksheets, and would be so gratefull for any help:

Beregningsdokument.mw
Beregningsdokument_2.mw


Best regards

Henrik Jorgensen

I am trying to work through an example in a textbook, but its a few years old and uses maple 2015. I am currently using the 2018 edition of maple. The code is an example of how to generate the points on an elliptic curve given a specific input. 
Here is the example code from the textbook:

epoints := proc(ec, x, ub, p)
    local ecurve, z, pct, k, i;
    pct := 0;
    for k from 0 to p-1 while pct <= ub do
        z := subs(x=k, ec) mod p;
        if z = 0 then
           pct := pct+1;
           ecurve[pct] := [k,z];
        fi:
        if z &^ ((p-1)/2) mod p = 1 then
           z := z &^ ((p+1)/4) mod p;
           ecurve[pct+1] := [k,z];
           ecurve[pct+2] := [k, -z mod p];
           pct := pct+2;
        fi:
    od:
    if pct > ub then
       pct := ub:
    fi:
    seq(ecurve[i], i=1..pct):
end:


Here is my code, written to work with Maple 2018:

ecpoints := proc (ec, x, ub, p) local ecurve, z, pct, k, i;
      pct := 0; for k from 0 to p-1 while pct <= ub
         do z := `mod`(subs(x = k, ec), p);
         if z = 0 then pct := pct+1;
            ecurve[pct] := [k, z] end if;
         if `mod`(z^((1/2)*p-1/2), p) = 1 then
            z := `mod`(z^((1/4)*p+1/4), p) = 1;
           ecurve[pct+1] := [k, z];
           ecurve[pct+2] := [k, `mod`(-z, p)];
           pct := pct+2 end if
   end do;
   if ub < pct then pct := ub end if;


   seq(ecurve[i], i = 1 .. pct)
end proc

The problem is with the output. The output should be [0, 5], [0, 14], [2, 4], [2, 15], [3, 6], [3, 13], [4, 6], [4, 13], [6, 0], [10, 16], [10, 3], [12, 6], [12, 13], [14, 16], [14, 3], [18, 17], [18, 2].
What I get is [0, 5 = 1], [0, 14 = 18], [2, 4 = 1], [2, 15 = 18], [3, 6 = 1], [3, 13 = 18], [4, 6 = 1], [4, 13 = 18], [6, 0], [10, 16 = 1], [10, 3 = 18], [12, 6 = 1], [12, 13 = 18], [14, 16 = 1], [14, 3 = 18], [18, 17 = 1], [18, 2 = 18]. 
Any hints on what I could be doing wrong here or what is going on?

First 443 444 445 446 447 448 449 Last Page 445 of 2308