MaplePrimes Questions

Each term of the following sequence is derived using the sum of all preceding terms following a simple algorithm. I have tried to code it but without success (keep getting error message "too many levels of recursion"). 

Definition is as follows:

a(0)=0, a(1)=1;  for n>=1,

a(n+2) = n + Sum{k=1..n+1} a(k). 
 

it starts: 0,1,2,5,11,23,47,95,191,767,1536,3071,6143...

(Looks like every prime term is of the form 3*2^m-1). 

Cann anyone suggest a solution?

Thanks,

David.

Hi,

While computing a simple sequence of numbers, I remarked a small difference between the result obtained with $ and with seq.

Digits:=20:
u:=proc(n) evalf(((n+1)/n)^(n+1)) end proc:
a:=[u(n)$n=1..10]:
b:=[seq(u(n),n=1..10)]:
a-b;

 

The result is:

 

[0., 0., -4.*10^(-19), 0., 0., 6.*10^(-19), -9.*10^(-19), 0., -3.*10^(-19), 0.]

I have no idea why there are nonzero values in the output. Does anyone have an explanation?

 

It seems I get the correct values if I quote the expression before $:

a:=['u(n)'$n=1..10]:

However, it's not clear to me why this makes a difference in evalf.

As the title says, I'd like to  divide Non-isomorphism  graphs of order 7   into 6 parts according  diameter of graph.

I write following codes:

restart:
with(GraphTheory):
for i from 1 to 7 do
D||i:=[]:
od:

prc:=NonIsomorphicGraphs(7,output=iterator,outputform=graph,restrictto = connected ):
graphmark := prc():                      
while graphmark <> FAIL  do               
    if Diameter(graphmark) = 1 then  
         D1:=[op(D1),graphmark]; 
      elif Diameter(graphmark) = 2 then
         D2:=[op(D2),graphmark];
      elif Diameter(graphmark) = 3 then
         D3:=[op(D3),graphmark];
      elif Diameter(graphmark) = 4 then
         D4:=[op(D4),graphmark];
      elif Diameter(graphmark) = 5 then
         D5:=[op(D5),graphmark];
      elif Diameter(graphmark) = 6 then
         D6:=[op(D6),graphmark];
      fi:                                
     graphmark:=prc():                 
end do:

But I think  conditional statements  if.. elif are used to many  in  above maple  codes,  it is not concise.  

How to write better?

 

 

Projection will not work with orientation. 

plot3d(x*y, x = 0 .. 10, y = 0 .. 10, projection = 0.2)
                                                        

plot3d(x*y, x = 0 .. 10, y = 0 .. 10, projection = 0.2, orientation = [55, 75, 0])
                                                

After setting:

Digits:=20;

result of:

evalhf(9.3653976306373904636884810627704*10^(-315));

is:

-9.0813464423699167205*10^(-315)

 

This looks nonsesnse. What is going on?

 

 

 

Hello everyone I am trying to solve the transcendental equation by using the regular false position method cannot succeed. is their nay can solve it form me...

F := ((-288*(lambda + (2*k)/3 - 2/3)*sqrt(2)*lambda^2*arctan(sqrt(4*lambda/(1 - k) - 2)*sqrt(2)/2)/(1 - k)^2 - 144*(lambda + (2*k)/3 - 2/3)*Pi*lambda^2*sqrt(2)/(1 - k)^2 - 36*((lambda + (2*k)/3 - 2/3)*(4*lambda/(1 - k) - 2) + (10*lambda)/3 + (4*k)/3 - 4/3)*sqrt(4*lambda/(1 - k) - 2))*(1 - k)^2)/(256*lambda^2)

how to show which region of the plan belongs to the argument points between 0 and Pi/2 and the module points between 0 and 2 ?

Does anyone know how to open .mm file in Maple, as well as using the program or function in .mm file in Maple? Many thanks.

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. 

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