## 370 Reputation

13 years, 191 days

## Thanks to everybody. Axel...

Thanks to everybody. Axel you are right, larger length does not mean higher complexity. Thanks also for the suggestion of using tryhard as a precedure. But what I meant is that using simplify or tryhard element by element (using "map") doesn't optimize the calculation of the array but just the calculation of each element without taking in account the others!!  And I think there is a bug in tryhard with the arrays (and also with the Arrays). Look at this simple example:

stampa:=array(1..4);

for m from 1 to 4 do;
stampa[m] := x^m
end do;

codegen[makeproc](stampa);
codegen[optimize](%);

the result without tryhard is:

proc () local stampa; stampa := array(1 .. 4); stampa[1] := x; stampa[2] := x^2; stampa[3] := stampa[2]*x; stampa[4] := stampa[2]^2; stampa end proc

with tryhard is:

proc () local result; global x; x := 'x'; result := array(1 .. 4,[(1)=x,(2)=x^2,(3)=x^3,(4)=x^4]) end proc

So with tryhard there isn't any kind of optimization!!! So i think there are some problem with arrays. My sheet has just an array like that, just multiplications,divisions,sum,powers,subtractions and absolute values. nothing complex like diff, int, limit.  So for that reason i thought i could be a bug, but i can be wrong.

thanks

alberto

## thanks so much...

thanks so much. To do the optmization by  hand is impossible because I have to run that sheet hundreds of times for different equations. Thanks you did the  best. If you just can say to the Mable developers about the tryhard bug with array(and also Array) so maybe they can fix it with the next releases.

Another fast question:I didn't find this in the help. When I use printlevel to see all the calculation inside a "for "cycle I don't understand how to get only the calculation followed by ";" and not ":". I seems like that printlevel disables the difference between ";" and ":"but sometimes
it can be good to print just a few of lines inside the "for" cycle not all the lines or none of them. Is it possible to do that?

thanks

alberto

## Thanks for the suggestions....

Thanks for the suggestions. 2 fast questions:

1)Is not clear to me how "simplify" works. I had already used  simplify(%,size) for each component in my code. Now you suggest me to use map(simplify, stampa,size) and there is an improvement of the length(small but evident improvement,but if you note the component stampa [3,1] is a little bit worse). It's wierd because if i did it component by component it wouldn't be necessary to do it again,would it be? The optimization that i need is not provided by "map(simplify, stampa,size)" because it consider one component separately from the others in the simplification process. It's codegen[optimize](%,'tryhard') that give the global optimization, avoiding to recompute all the products and sums that are already computed in the other components of the array(there are a lot of operation that are equal in each component of the array.

2)why do you think is better to use array instead of Array?

thanks

Alberto

## hi, I 'm in real...

hi,

I 'm in real diffculty...I tried in all the way to do that cycle but it doesn't work. It's quite strange. can you take a look to my worksheet please? are just a few Iines. I read the guide but i cannot understand why it doesn't accept the cycle.

thanks Alberto

## Thanks now it works how I...

Thanks now it works how I would like.

I have another question:   since I have to do the same thing for every equations and for every order of derivative it would be more general(it would work for any kind and number of equations) and also more efficient to calcolate all the derivatives and just at the end to use  codegen[optimize](%,tryhard] ) and create just one function optimized to get all the derivatives. So I thought to have two external "for" cycles and to create a vector eq[1..Neq,1..Nder]  where in the first column I have the first order time derivative for every equations and in the second one the second order time derivative for every equations and so on.  My problem is just  a problem with  the cycles. Without cycles it works, with the cycle it says me

"Error, invalid input: lhs received 0, which is not valid for its 1st argument, expr".

It is quite strange.  I think it has the problem at the first instruction,becouse it doesn't seem to print anything. Maybe is something that I ignore about cycles in Maple but I read all the section about the cycles in the guide it seems  correct.

I have just put two "for" external cycles and adapted to the cycle the code that you have already seen(now I have correct it with your suggestion to get the CS vector in fortran). Can you please take a look to the file?there are just a  few lines

Thanks

Alberto

## i apologize for the length...

i apologize for the length of the file,I meant if you could read just the first lines. I now how to declare an array in a procedure, my problem is to create a procedure from a formulation that contain an array using "makeproc". I tried in all the way, i have looked for an example in the help but there are no examples of that and i wasn't able to do that. I have problem when I write:

qxt:=codegen[makeproc](FORTR,parameters = [CS::Array(1..4,datatype=float),op(theIndets)]  );

I attach the file to you,just a  few lines.

Thanks

Alberto

ps:I don't understand your proposal of writing a procedure like Y3:= subs(CS(1)=cs1, CS(2)=cs2, CS(3)=cs3, CS(4)=cs4. It has to be general not just for 4 component but also for 100. I'm just trying with 4 but I will generalize.  And I would like to have a only fortran function that has as argument also the array CS. I have to do that  for a lot of time and lot of equation and it s long to substitute everytime all the CS(1.D0),CS(2.D0)...expecially if are 100 component.

## Exactly I would like to use...

Exactly I would like to use CS as argument of the fortran function.  i tried just to use square bracket cs[1] but it  doesn't work. I tried to declare directly CS inside makeproc. Maybe I have to use  codegen[makeparam] , but I tried to declare CS with that but it gives me error.  I ve looked for a solution in the help menu and in the examples but i didn't find some problem similar to this. can you take a look to the file? I attach it to you. You can see in the first part of the MAPLEsheet that  I  tried to declare directly CS inside makeproc and it gives me error.

tahnks

alberto

## Thanks to your help, I write...

Thanks to your help, I wrote the maple code and it works. But I have still a problem when I get my fortran 77 exit:  in the fortran code I would like to have  the variables CS(1),CS(2),CS(3),CS(4)  (the 4 components of the variable CS) but I get CS(1.D0),CS(2.D0),CS(3.D0),CS(4.D0) , i.e. it recognizes the number between brackets like a real  number and not like the component of a variable. And I also would like to have the vector CS between the argoment of the fortran function. Do you know please how I can do that?I read the help but I didn't find the solution. I attach to you my maple classic file.

thanks a lot

Alberto

## thanks wonderful...

sORRY I posted here two times and I don't now how to cancel this post...you can only edit not cancel...

## thanks wonderful...

thanks wonderful suggestions, you are great!!!!!!

But three things are not clear to me:

1)Why I wasn't able to execute with the !!! bottom the file I have attached you above?(EAvoltaBONA.mws)

2)there are not other possibility other then cancel the weird lines one by one?why they appears when I copy the commands in the classic version?

3) when I open your file with the classical worksheet and I execute it (now it work) it shows me all the outputs of the commands Fortran(%): WHY?there are the double point!!!

thanks

alberto

## Thanks. I know if you don't...

Thanks. I know if you don't have 2 GB i think is difficult to open it,with me the Maple interface is using 900MB of RAM!!

I  tryed your suggestion jakubi. It says:  unable to cut/copy to rft selection too large. But it copies it anyway,and  if I past it in the classic worksheet I get that weird lines:  print([output redirected]); input placeholder.

It takes a while to cancel all the lines,expecially if I have to convert more documents. WHy do they appear? In any case I canceled the lines. But I'm not able to run the document. Also if I press the !!! bottom,nothing happens. I attached you the two file mws. One without weird lines

and one with weird lines

thanks a lot

alberto

## THANKS BUT WITH 2D-MATH DOESN'T WORK...

thanks a lot... but why if I use 1D -MATH it works and if i use 2D-MATH it doesn't work,it returns me just a zeros matrix? see the attachment

thanks

alberto

## Thank so much. I don't...

Thank so much. I don't understand 2 thing:

1)what do you mean for classic GUI? I have sought in the help but I didn't find nothing.

2) Very strange the fact of the label. It's true that I reference a label (11), and there is no such label. But it works well!maybe does it use one of the closest label to the (11) , in this case label (12),that became correct for me? and the strange thing is that if  instead of lhs((9))=(11)   i try to write  lhs((9))=(12)   it writes me this error:      Error, `)` unexpected.    Why?very strange

thanks so much

alberto

## Thanks so much. I change my...

Thanks so much. I change my program with your suggestion. I have some short question.

1) I have changed % with a call to a label . The time for compiling seems to me to be the same with labels or with % (around 6 real life seconds in my pc pentium4 3800mhz). It' s very slow or not?is it normal?if it is normal maple is  slower then what I thought.

2)I convert to 1D MATH IMPUT. And the time seems to by not so much different, around 5.5 seconds instead of 6. If a misure with time() (initial minus final,as in Robert Israel's attachment) it gives me 0.2 with math1D and 1.2 with MATH2D, but the real time,as I said you before, is almost the same(5.5 versus 6 seconds).Why this difference?

3)when I call with(PDEtolls)  it writes me

[CanonicalCoordinates, ChangeSymmetry, CharacteristicQ, D_Dx, DeterminingPDE, `&Eta;k`, FromJet, InfinitesimalGenerator, Infinitesimals, InvariantSolutions, InvariantTransformation, Invariants, PDEplot, ReducedForm, SimilaritySolutions, SimilarityTransformation, SymmetryTest, SymmetryTransformation, TWSolutions, ToJet, build, casesplit, charstrip, dchange, dcoeffs, declare, diff_table, difforder, dpolyform, dsubs, mapde, separability, splitstrip, splitsys, undeclare]

but it seems to work. What does it mean?

I attach you my files one with label and one with %.

thanks so much

## Dear Doug, please can you...

Dear Doug,

thanks so much

Alberto

 1 2 3 Page 2 of 3
﻿