Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I want to insert each row at a time into a excel sheet from a maple code .  But i dont want a new excel file created for each insert.

First my list L has say [(a,1),(a,2),(a,3),.....,(a,100)] 100 elements this is first i insert it into my excel first row
next  [(b,1),(b,2),(a,3),.....,(b,100)] 100 elements i should insert into excel second row and so on

but dont want to store them here on a rtable, vector,array "all together" then export

I justt store 1 row at a time insert it and do on the same excel file file dynamically. without creating multiple copies of the same file

can anyone help with a code using exceltools package or any

 


 

``assume(0 < k, k < 1)

int(x^2/sqrt((-x^2+1)(-k^2*x^2+1)), x = 0 .. k)

int(x^2/(-x(-k^2*x^2+1)^2+1)^(1/2), x = 0 .. k)

(1)

sqrt(k^2)

k

(2)

``


 

Download ellipticIntegralTest.mw

Hi everyone, 

I am trying to use elliptic integral from Maple, however, it did not generate any result. Can you help me with that?

let me just explains the big picture first, then give small example.

When using standard modules, I had one module, and number of smaller modules, all private to the main module. This worked well.

Each sub module, can only be accessed from the top module, which is seen by user. The sub modules can't be called by user directly.

Now I changed the main module to become an object (since I want to make more instances of it).

I want to still use the code in those submodules I had, but want to keep them private to the object class, so they can be seen only from inside the object class methods. So they are part of the object class now. But remain as modules. I do not want to copy all those methods in these submodules and put them in the object class directly.

But I can't get the syntax right to do this. I do not want to modify the code inside the sub-modules, but only how to integrate them into the object.

Notice that I can call those external modules fine from the object, but I simply want to make them private to the object class, so they can't be called from outside. 

The question is how to do this? 

Here is a very small example. (in practice, I have these submodules in .mpl files, but here I put them all in the example).

restart;	
module car_class()
      option object;
      local name::string :="UNKNOWN";

      export set_name::static:=proc(o::car_class,_name::string)
        o:-name := _name;
        o:-big_car:-set_name(o,_name);#this call does not work
      end proc;

      #this is module, that I want to be private to this class only
      #eventually, I'd like this module be in separate mpl file also.
      local big_car::static :=module()  #module does not take arguments!

            #this below should be private only to the this module
            #and not seen by the enclosing object.
            local big_car_name::string:="UNKNOWN";  

            #this export to allow parent object to call it
            export set_name::static:=proc(o::car_class,_name::string)
                   o:-big_car:-big_car_name:=_name;
            end proc;

      end module;

end module:

o:=Object(car_class);
o:-set_name(o,"GM");

Error, (in set_name) module `car_class` does not export `big_car`

I found after playing more with it, that this works

I just replaced o:-big_car:-big_car_name:=_name;  with big_car:-big_car_name:=_name; had to remove ::static from definition of proc inside the private module.

restart;	
module car_class()
      option object;
      local name::string :="UNKNOWN";

      export set_name::static:=proc(o::car_class,_name::string)
        o:-name := _name;
        o:-big_car:-set_name(o,_name);
      end proc;

      local big_car::static  :=module() 
          local big_car_name::string:="UNKNOWN";  

          export set_name:=proc(o::car_class,_name::string)
              big_car_name:=_name;
          end proc;

     end module;
end module:

Now it works. However, maple help says "In Maple, method names should be declared as static. "

I would like to factor

factor(98-28*sqrt(7));

which I would like to output 14*(7 - 2*sqrt(7)),

but Maple keeps returning 98 - 28*sqrt(7).

code_(1).mw
 

 

 

Hello! hope you all be fine. i m running a code for `Anew Technique of intial Boundary Value Problem Using ADM `(Elaf*Jaafar*Ali) but my code is for positive integer and i want to run it for fractional can anyone help me please code file is attached 

 

If one refers to a name in Maple, I thought it will look at the global context to find it. So when one does latex(....) then this is assumed to be the system latex command. No need to do :-latex()

But if there is local variable in Object class called latex, why then is object:-latex gets confused with global Maple command latex()?  Here is an example

module ode_class()
      option object;
      local latex::strring :="";

      export init::static:=proc(o::ode_class)
        o:-latex:= latex(1/2,output=string);
      end proc;
end module:

my_ode:=Object(ode_class): 

Error, static procedure `ode_class:-init` refers to non-static local or export `ode_class:-latex::strring` in surrounding scope
 

ofcourse easy to fix, I just replace the RHS latex(1/2,output=string);  with :-latex(1/2,output=string); 

But my question why is object:-latex := latex(...)  makes Maple think the latex in the RHS is the variable name in the class, when it does not have the  object:- prefix?  Is this expected  behaviour in Maple? 

But now I am starting to worry that each maple command/function/name used inside the Object needs  :- added to it, just in case of a current or future name conflict with local object variables names.

 

 

For example the below is a c code how to write this in maple

 

void swap(int *a, int *b)

 {

     int temp;

emp = *a;

*a = *b;    

 *b = temp;  

}    //permutation function

 void permutation(int *arr, int start, int end)

 {      

if(start==end)

     {        

 printarray(arr, end+1);

         return;    

 }      

int i;    

 for(i=start;i<=end;i++)  

   {          //swapping numbers      

   swap((arr+i), (arr+start));      

   //fixing one first digit          //and calling permutation on          //the rest of the digits          permutation(arr, start+1, end);          swap((arr+i), (arr+start));  

   }  

}

Please, anyone with the idea on how to plot D1 against alpha[n]. The link is attached below

Help!!!.mw

 

The pdf shows the derivation procedure of Image from 1.2.1 to 1.2.5. However, when we obtain the (7) in pdf, which is the 

 

expansion of 1.2.4, we hope to see the hamiltonian operator in the output.  We obtain the (10) in pdf (Maple). Actually, it is the expansion of 1.2.5. However, it is too cockamamie compared with that (1.2.5) in the textbook.

 

Hence, I hope to show the hamiltonian operator in the (10) in PDF. I hope to see the simplest type of equation.

How could I do? Appreciate the kind help from anyone!

The Maple code is also uploaded.
 

 

 

 

restart*with(Physics[Vectors])

Step(mathematicalnotation = true)*SetCoordinates('cartesian'[i, j, k])

Step(mathematicalnotation = true)*SetCoordinates(cartesian[i, j, k])

(1)

``

NULL``

"  UU(x,y,z):=ux(x,y,z)*(_i)+uy(x,y,z)*_j+uz(x,y,z)*_k; "

proc (x, y, z) options operator, arrow, function_assign; Physics:-Vectors:-`+`(Physics:-Vectors:-`+`(ux(x, y, z)*_i, uy(x, y, z)*_j), uz(x, y, z)*_k) end proc

(2)

"&nabla;(pressure(x,y,z));  Laplacian(UU(x,y,z));  BB(x,y,z):=0*_i+0*_j+10*_k"

proc (x, y, z) options operator, arrow, function_assign; Physics:-Vectors:-`+`(Physics:-Vectors:-`+`(0*_i, 0*_j), 10*_k) end proc

(3)

-VectorCalculus[Nabla](pressure(x, y, z))+Laplacian(mu*UU(x, y, z))+BB(x, y, z) = 0*_i+0*_j+0*_k

_i*(-(diff(pressure(x, y, z), x))+mu*(diff(diff(ux(x, y, z), x), x))+mu*(diff(diff(ux(x, y, z), y), y))+mu*(diff(diff(ux(x, y, z), z), z)))+_j*(-(diff(pressure(x, y, z), y))+mu*(diff(diff(uy(x, y, z), x), x))+mu*(diff(diff(uy(x, y, z), y), y))+mu*(diff(diff(uy(x, y, z), z), z)))+_k*(-(diff(pressure(x, y, z), z))+mu*(diff(diff(uz(x, y, z), x), x))+mu*(diff(diff(uz(x, y, z), y), y))+mu*(diff(diff(uz(x, y, z), z), z))+10) = 0

(4)

``

Divergence(-VectorCalculus[Nabla](pressure(x, y, z))+Laplacian(mu*UU(x, y, z))+BB(x, y, z) = 0*_i+0*_j+0*_k)

-(diff(diff(pressure(x, y, z), x), x))+mu*(diff(diff(diff(ux(x, y, z), x), x), x))+mu*(diff(diff(diff(ux(x, y, z), x), y), y))+mu*(diff(diff(diff(ux(x, y, z), x), z), z))-(diff(diff(pressure(x, y, z), y), y))+mu*(diff(diff(diff(uy(x, y, z), x), x), y))+mu*(diff(diff(diff(uy(x, y, z), y), y), y))+mu*(diff(diff(diff(uy(x, y, z), y), z), z))-(diff(diff(pressure(x, y, z), z), z))+mu*(diff(diff(diff(uz(x, y, z), x), x), z))+mu*(diff(diff(diff(uz(x, y, z), y), y), z))+mu*(diff(diff(diff(uz(x, y, z), z), z), z)) = 0

(5)

 

algsubs(Divergence(UU(x, y, z)) = 0, %)

-(diff(diff(pressure(x, y, z), x), x))+mu*(-(diff(diff(diff(uy(x, y, z), x), x), y))-(diff(diff(diff(uz(x, y, z), x), x), z)))+mu*(-(diff(diff(diff(uy(x, y, z), y), y), y))-(diff(diff(diff(uz(x, y, z), y), y), z)))+mu*(-(diff(diff(diff(uy(x, y, z), y), z), z))-(diff(diff(diff(uz(x, y, z), z), z), z)))-(diff(diff(pressure(x, y, z), y), y))+mu*(diff(diff(diff(uy(x, y, z), x), x), y))+mu*(diff(diff(diff(uy(x, y, z), y), y), y))+mu*(diff(diff(diff(uy(x, y, z), y), z), z))-(diff(diff(pressure(x, y, z), z), z))+mu*(diff(diff(diff(uz(x, y, z), x), x), z))+mu*(diff(diff(diff(uz(x, y, z), y), y), z))+mu*(diff(diff(diff(uz(x, y, z), z), z), z)) = 0

(6)

simplify(%)

-(diff(diff(pressure(x, y, z), x), x))-(diff(diff(pressure(x, y, z), y), y))-(diff(diff(pressure(x, y, z), z), z)) = 0

(7)

Laplacian(-VectorCalculus[Nabla](pressure(x, y, z))+Laplacian(mu*UU(x, y, z))+BB(x, y, z) = 0*_i+0*_j+0*_k)

(mu*(diff(diff(diff(diff(ux(x, y, z), x), x), x), x))+2*mu*(diff(diff(diff(diff(ux(x, y, z), x), x), y), y))+2*mu*(diff(diff(diff(diff(ux(x, y, z), x), x), z), z))+mu*(diff(diff(diff(diff(ux(x, y, z), y), y), y), y))+2*mu*(diff(diff(diff(diff(ux(x, y, z), y), y), z), z))+mu*(diff(diff(diff(diff(ux(x, y, z), z), z), z), z))-(diff(diff(diff(pressure(x, y, z), x), x), x))-(diff(diff(diff(pressure(x, y, z), x), y), y))-(diff(diff(diff(pressure(x, y, z), x), z), z)))*_i+(mu*(diff(diff(diff(diff(uy(x, y, z), x), x), x), x))+2*mu*(diff(diff(diff(diff(uy(x, y, z), x), x), y), y))+2*mu*(diff(diff(diff(diff(uy(x, y, z), x), x), z), z))+mu*(diff(diff(diff(diff(uy(x, y, z), y), y), y), y))+2*mu*(diff(diff(diff(diff(uy(x, y, z), y), y), z), z))+mu*(diff(diff(diff(diff(uy(x, y, z), z), z), z), z))-(diff(diff(diff(pressure(x, y, z), x), x), y))-(diff(diff(diff(pressure(x, y, z), y), y), y))-(diff(diff(diff(pressure(x, y, z), y), z), z)))*_j+(mu*(diff(diff(diff(diff(uz(x, y, z), x), x), x), x))+2*mu*(diff(diff(diff(diff(uz(x, y, z), x), x), y), y))+2*mu*(diff(diff(diff(diff(uz(x, y, z), x), x), z), z))+mu*(diff(diff(diff(diff(uz(x, y, z), y), y), y), y))+2*mu*(diff(diff(diff(diff(uz(x, y, z), y), y), z), z))+mu*(diff(diff(diff(diff(uz(x, y, z), z), z), z), z))-(diff(diff(diff(pressure(x, y, z), x), x), z))-(diff(diff(diff(pressure(x, y, z), y), y), z))-(diff(diff(diff(pressure(x, y, z), z), z), z)))*_k = 0

(8)

algsubs(-(diff(pressure(x, y, z), x, x))-(diff(pressure(x, y, z), y, y))-(diff(pressure(x, y, z), z, z)) = 0, %)

(mu*(diff(diff(diff(diff(ux(x, y, z), x), x), x), x))+2*mu*(diff(diff(diff(diff(ux(x, y, z), x), x), y), y))+2*mu*(diff(diff(diff(diff(ux(x, y, z), x), x), z), z))+mu*(diff(diff(diff(diff(ux(x, y, z), y), y), y), y))+2*mu*(diff(diff(diff(diff(ux(x, y, z), y), y), z), z))+mu*(diff(diff(diff(diff(ux(x, y, z), z), z), z), z)))*_i+(mu*(diff(diff(diff(diff(uy(x, y, z), x), x), x), x))+2*mu*(diff(diff(diff(diff(uy(x, y, z), x), x), y), y))+2*mu*(diff(diff(diff(diff(uy(x, y, z), x), x), z), z))+mu*(diff(diff(diff(diff(uy(x, y, z), y), y), y), y))+2*mu*(diff(diff(diff(diff(uy(x, y, z), y), y), z), z))+mu*(diff(diff(diff(diff(uy(x, y, z), z), z), z), z)))*_j+(mu*(diff(diff(diff(diff(uz(x, y, z), x), x), x), x))+2*mu*(diff(diff(diff(diff(uz(x, y, z), x), x), y), y))+2*mu*(diff(diff(diff(diff(uz(x, y, z), x), x), z), z))+mu*(diff(diff(diff(diff(uz(x, y, z), y), y), y), y))+2*mu*(diff(diff(diff(diff(uz(x, y, z), y), y), z), z))+mu*(diff(diff(diff(diff(uz(x, y, z), z), z), z), z)))*_k = 0

(9)

collect(%, mu)

((diff(diff(diff(diff(ux(x, y, z), x), x), x), x)+2*(diff(diff(diff(diff(ux(x, y, z), x), x), y), y))+2*(diff(diff(diff(diff(ux(x, y, z), x), x), z), z))+diff(diff(diff(diff(ux(x, y, z), y), y), y), y)+2*(diff(diff(diff(diff(ux(x, y, z), y), y), z), z))+diff(diff(diff(diff(ux(x, y, z), z), z), z), z))*_i+(diff(diff(diff(diff(uy(x, y, z), x), x), x), x)+2*(diff(diff(diff(diff(uy(x, y, z), x), x), y), y))+2*(diff(diff(diff(diff(uy(x, y, z), x), x), z), z))+diff(diff(diff(diff(uy(x, y, z), y), y), y), y)+2*(diff(diff(diff(diff(uy(x, y, z), y), y), z), z))+diff(diff(diff(diff(uy(x, y, z), z), z), z), z))*_j+(diff(diff(diff(diff(uz(x, y, z), x), x), x), x)+2*(diff(diff(diff(diff(uz(x, y, z), x), x), y), y))+2*(diff(diff(diff(diff(uz(x, y, z), x), x), z), z))+diff(diff(diff(diff(uz(x, y, z), y), y), y), y)+2*(diff(diff(diff(diff(uz(x, y, z), y), y), z), z))+diff(diff(diff(diff(uz(x, y, z), z), z), z), z))*_k)*mu = 0

(10)

``

``

 


``

 

Download 20200619.mw

 

 

Download 20200619-1.mw

20200619.pdf

 

in my object, I have few private variables. To make sure the object is correctly initialized between each use, I'd like to initialize these private variables each time at the start of the call each time the object is called to process something.

Some of these variables represent equations, or symbols or functions. Some of these are set by the user of the object, but some are not. And I do not want to leave those that are not set, using old values from last call.

The problem  I can't use {} nor NULL to initialized these private variables, since I am telling Maple they are of type `=` or `symbol` or `function`.

To give a small example, I use a proc here to illustrate, since it the same idea, but less code.

restart;
kernelopts('assertlevel'=2):
foo:=proc(input_ode::`=`)
   local ode::`=`:={};  #i'd like to give this some initial value. But what?
   ode:=input_ode;
end proc;

now foo(diff(y(x),x)=5) gives

Error, (in foo) assertion failed in assignment, expected `=`, got {}
Same type of error happens if I use NULL.

Is there a special value or tag one can use to initialize/reset any variable, regardless of its type? I thought at first that NULL will work, but it is not.

The idea is that I'd like all my object private variable to always have known state when the same object is called each time. ie. to clean it up before the next time is made.

The above is just an example. Ofcourse I could just do this

restart;
kernelopts('assertlevel'=2):
foo:=proc(input_ode::`=`)
   local ode::`=`; #leave it un-initialized since it will be overwritten next
   ode:=input_ode;
end proc;

And now no error. 

I read  help document of :

with(Physics[Vectors]):
(%Nabla)(f(x,y,z))
value(%)

 

But if I want to use Composition function , is it not useful? why? how to do?

(%Nabla@@4)(f(x,y,z));
value(%)

we know that:

(Nabla@@4)(f(x,y,z))

 

Hello all, 

Would you tell me how to replace a part of an equation with another expression?

I tried to replace the expression '(1-Lm^2/(Ls*Lr))' in the equation below ('LD') with an expression 'sigma', but no success. 

restart;

LD := Lambda_ds = (-Lm^2/Lr + Ls)*i_ds + Lm*Lambda_dr/Lr;

Lambda_ds = (-Lm^2/Lr+Ls)*i_ds+Lm*Lambda_dr/Lr

(1)

sigma := (1-Lm^2/(Ls*Lr));

1-Lm^2/(Ls*Lr)

(2)

algsubs(1-Lm^2/(Ls*Lr)=ss,LD);

Lambda_ds = (-Lm^2/Lr+Ls)*i_ds+Lm*Lambda_dr/Lr

(3)

subs({(1-Lm^2/(Ls*Lr)) = sigma}, (3));

Lambda_ds = (-Lm^2/Lr+Ls)*i_ds+Lm*Lambda_dr/Lr

(4)

 


 

Download question20200618.mw

From a newbie:

Is there any way to get the Simpify from the Context Panel to clean up a little more?

I'm impressed with the job it does because it really did the job on some very hairy 5x5 matrices I had.

But I was not able to get it to completely collection all the terms of the following:

Clearly w,x, and y could have been collected like z was.  but I tried a number of approaches and could not get any of them to collect the w,x, and y terms..

Any thoughts about it?

Thanks,


 

First 412 413 414 415 416 417 418 Last Page 414 of 2097