MaplePrimes Questions

Please I will like to know if there exists any command to isolate the known regular mathematical functions from an expression. For example, given the equation 

I need a means of isolating (ex & sin(v)) from the above expression

Thanks

How to get a plot where a unit cube [0,1]X[0,1]X[0,1] in R^3 is intersected by a plane $x+z=1$. Please give me a code

 

where p, q, r, a are positive constants and phi(0) be a initial condition

I'm not sure if this can even be done, but if it's possible, how do I do it:

I have a python script called "Blue.py", the path should simply be "Blue.py", since my worksheet and the python script are saved in the same place.

I want to somehow import two arrays and an equation from maple to said python script, use them in a procedure there, and then import the output of said procedure, a 2d array, backwards to maple.

I don't really care what format the equation and the arrays take in python (the current version assumes types "np.array" for the arrays and type procedure for the equation, but I can always adjust it), but the type of the output of Blue.py should be of the form 2d Array (for example [[0,1],[8,-2],[3,3]] ).

Is it possible to shuffle input between maple worksheets and python scripts like that, and if so, how? 

The uploaded worksheet is a failed attempt at this proof.

Please either refer me to or show me a valid proof.

  *** I have tried to upload my worksheet using the green arrow but the insert link operation of the upload failed ***

cc

loading

Error occurred during PDF generation. Please refresh the page and try again

int(int(x^(alpha + 1)*y^(beta + 1)*exp(-(x^2 + y^2)/(4*Pi))/sqrt(x^2 + y^2), x = -R .. R), y = -R..R) assuming x>0, y>0, R>0;

I am trying to evaluate the above symbolic integral but Maple returns the same input in Symbolic form without evaluating it at all. Is there something wrong with my approach?

Hi there!

I'm attempting to develop a custom library in MapleSim (a Modelica solver engine) that can use convolution integrals to model the hydrodynamic behaviour of floating bodies. The convolution integral is mathematically represented as follows:

a general form of a convolution integral, spanning from negative to positive infinity in time

And the equation I'm particularly interested in solving is as follows:

Cummins equation to determine the motion of a floating body in waves

I'm trying to solve this convolution integral in Modelica using a model that can be imported to MapleSim. So far, I've had no luck in implementing this convolution for continuous functions symbolically. I have used a numerical approach on 2 arrays using the following approach in Modelica:

// Modelica function
function convIntegral
  input Real simTime;  // Simulation time
  input Real f[:];     // Kernel function array
  input Real g[:];     // Second function array

  output Real h[(2*simTime) - 1];    // Output the convolution integral in the form of an array
  
  // Define the algorithm to numerically compute the convolution integral of 2 arrays
  algorithm
    // Initialize the output array with zeroes
    for i in 1:((2*simTime) - 1) loop
      h[i] := 0;
    end for;
    
    // Iterate over the simulation time
    // Recursively increment the convolution array with the pointwise product of the 2 functions
    for i in 1:simTime loop
      for j in 1:simTime loop
        h[i+j-1] := (f[i] * g[j]) + h[i+j-1];
      end for;
    end for;
end convIntegral;
// End of function to compute the convolution integral

This works perfectly for discrete samples and I have verified it with output from Matlab's inbuilt function

conv(A,B)  % For 2 arrays A and B

However, I would like to implement this on 2 continuous functions and this numerical approach does not work since MapleSim does not support conversion between discrete and continuous signals.

I understand that convolution is essentially an operation between two functions, where we time-flip one of the functions (kernel) and then slide it across the other function while measuring the bounded area and outputting that as the result of the convolution. I include this image from Wikipedia that sums up convolution: (Not including links as they mark questions as spam)

I've tried implementing this in Modelica using the following code:

// Model to perform convolution on 2 continuous functions
model ConvolutionalIntegral

  extends Modelica.Blocks.Icons.Block;

  // Define model variables
  Real kernelFunction = (e ^ (-0.5 * time)) * cos(0.5 * time);  // I've taken an example of a function I might use
  Real kernelFunctionFlipped = (e ^ (-0.5 * (T_sim - time))) * cos(0.5 * (T_sim - time));  // I've flipped the kernel function about the vertical axis by converting the (time) variable to (T_sim - time) where (T_sim) is a variable storing the simulation duration
  Real secondFunction;  // The other function for the convolution
  Real convolutionIntegralOutput;  // Function to store the output
  
  equation
    // Convolution implementation
    der(convolutionIntegralOutput) = kernelFunctionFlipped * secondFunction;

    // Final equation to solve
    der(secondFunction) + convolutionIntegralOutput = 0;
    // An example of a differential equation I'd like to solve involving the convolution integral
    
end ConvolutionIntegral;

I had hoped that this would yield the output of the convolution since I'm essentially multiplying the time-flipped kernel and the other function and then integrating them over time. However, the output does not provide the expected result and it appears that Modelica interprets my code to mean that I'm integrating the pointwise product of these 2 functions over time instead of sliding the kernel over the other function.

I'd appreciate it if you could take a look at my code and my approach to solving the convolution integral symbolically, and point out where I'm making a mistake and what a possible fix might be.

Thank you!

This is another bizzar behaviour of objects. I created a basic object of type person.  Noticed that after issuing the call copy(object,deep) and not doing anything at all with the result. Just made the call only, then I am not longer able to create new objects of this class. I had to restart the session to be able to create new objects again.

Why?  This seems like something went messy with memory layout. I put a print message in the constructor, and see that this message no longer show up  after the call copy(object,deep) even though this call was not used for any purpose as you see, but to only to see its effect on the session.

Any explanation why one can no longer create new objects after doing this?  Here is the workseet


 

interface(version)

`Standard Worksheet Interface, Maple 2022.1, Windows 10, May 26 2022 Build ID 1619613`

restart;

person:=module()
    option object;
    export name::string:="";  

    export ModuleCopy::static:=proc(_self,proto, name::string, $)
      print("Enter constructor of person");
      _self:-name := name;
    end proc;
end module;

_m2370471750336

p1:=Object(person,"me");
p1:-name;
do_not_care := copy(p1,deep);  

"Enter constructor of person"

_m2370557462816

"me"

_m2370557440576

p2:=Object(person,"me");  #WHy constructor no long called?
p2:-name;   #this no longer work.

_m2370556941056

""

p3:=Object(person,"me");  #WHy constructor no long called?
p3:-name;   #this no longer work.

_m2370556932032

""

restart;  #had to call restart to fix things.

person:=module()
    option object;
    export name::string:="";  

    export ModuleCopy::static:=proc(_self,proto, name::string, $)
      print("Enter constructor of person");
      _self:-name := name;
    end proc;
end module;

_m2370471750336

p4:=Object(person,"me");  #now it works again
p4:-name;   

"Enter constructor of person"

_m2370557462816

"me"

 


 

Download deep_call_problem.mw

I  generated some graphs via maple and would like to put them in my paper. So I am going to convert the following worksheet to pdf.

with(GraphTheory):
Graphs:=[NonIsomorphicGraphs(6,8,output=graphs,outputform = graph)]:
num_g:=nops(Graphs):
num:=ceil((num_g)/5.):
M1:=Matrix (num,5,(i,j)->`if`((i-1)*5+j<=num_g, DrawGraph(Graphs[(i-1)*5+j],size=[250,250] ,overrideoptions ,showlabels=false,style=planar, stylesheet =  [
 vertexcolor     = orange
,vertexfontcolor = black
,vertexborder    = false
,edgethickness   = 0.6
,edgecolor       = MidnightBlue
,vertexshape     =  "circle"
,vertexfont      = [Arial, 4],
vertexthickness=5], caption = cat(H__,5*(i-1)+j),captionfont=["ROMAN",7]),plot(x = 0 .. 1, axes = none))):
DocumentTools:-Tabulate (M1[1..5,.. ],widthmode=percentage ,width=80 , exterior =all) :

 

 

But there was a problem with the exported pdf. There was some mosaic stuff at the vertices of all those graphs. It was strange. (I want to reduce the size of vertices of the graphs in order not to look crowded.)

 

Only when I insert the option vertexpadding and set a large enough size  of vertex (for this example, we set vertexpadding=7),  it won't go wrong. However, in fact, we often need make vertice‘s size smaller , especially when there are more vertices.

As I was trying things with Maple OOP, I noticed strange behavior which I do not understand. I'll explain the problem in words first then given an example.

I have Person class. Then made one instance of it. In this class, there is one method which is defined to take in an object of same type as the class itself.

I found when I pass the object itself to its own method, it gives an error that the method expects a second argument of type person which is missing. But it is not missing.

Then when creating a second object of same type, and passing the second object, it worked! 

Why?  Here is MWE. Attached worksheet.  I would have expected same behavior in both cases. EIther both work, or both do not work. As as long as the object being passed is the correct type (person).

It seems in the first case, Maple noticed the object being passed to the method happened to be same object where this method is, and it did not pass it. Hence the missing second argument.  Is this a documented behaviour somewhere? (I made sure to make all method static though, so same code is used by all instances of the class. This is strange error message).
 

interface(version)

`Standard Worksheet Interface, Maple 2022.1, Windows 10, May 26 2022 Build ID 1619613`

restart;

person:=module()
    option object;
    export name::string:="";  

    #--- constructor---
    export ModuleCopy::static:=proc(_self,proto, name::string, $)
      _self:-name := name;
    end proc;

    export process::static:=proc(_self, the_input::person ,$)
       print("in person::process. name = ", the_input:-name);
    end proc;

end module;

_m2370471750496

p:=Object(person,"me");

_m2370557462912

p:-process(p);  #why this fail

Error, invalid input: process uses a 2nd argument, the_input (of type person), which is missing

o:=Object(person,"new_name"); #make new object and try again

_m2370557450944

p:-process(o); #why this OK?

"in person::process. name = ", "new_name"

 


 

Download why_first_call_fail.mw

Update

Ok, I am all set. I found a good way to do this. i.e. pass the object to one of its method. One has to make a copy of the object first and pass the copy. Can't use the same object. This is how I do it now. 

restart;
person:=module() 
    option object;
    export name::string:="";  

     export ModuleCopy::static:= overload( 
     [ 
         proc(_self,proto, $)option overload;
            print("Enter 2 args constructor of person");  
            #do nothing    
         end proc,

         proc(_self,proto, name::string, $) option overload; 
             print("Enter 3 args constructor of person");      
             _self:-name := name;
        end proc
     ]);

    export process::static:=proc(_self, the_input::person,$)
       print("the_input:-name = ",the_input:-name);
    end proc;
    
end module; 


p:=Object(person,"me");
#p:-process(p);  #instead of this do the following
o:=Object(p);
p:-process(o)

Which works and gives

              "Enter 3 args constructor of person"
                  p := Object<<2370600065568>>
              "Enter 2 args constructor of person"
                  o := Object<<2370600048288>>
                   "the_input:-name = ", "me"

So I am now able to pass the object (or rather copy of it) as explicit argument to other methods and other modules.  I am not sure why it does not work when using the object itself and had to make a copy. 

How to integrate the below function from 0 to eta.

A := P(eta)+S(H-2*`cos&theta;`(eta+1)*F)+`cos&theta;`*(2*F(eta)-2*H*F) = S(eta+1)*`sin&theta;`*F(theta)-`sin&theta;`(F*H(theta)-H*F(theta)+F(theta, eta))

Thanks in advance

How does one undo an overload?                                                                        

:RLC circuit I want to solve.

restart

with(DynamicSystems); with(inttrans)

E := 1; J := 3; R := 3; L := 1; C := 1/2

(1/s-6/s^2)/(s+3+2/s)

(1/s-6/s^2)/(s+3+2/s)

(1)

i__RL := proc (t) options operator, arrow; invlaplace((1/s-6/s^2)/(s+3+2/s), s, t) end proc

proc (t) options operator, arrow; invlaplace((1/s-6/s^2)/(s+3+2/s), s, t) end proc

(2)

"(->)"

-4*exp(-2*t)-3+7*exp(-t)

(3)

e__C := proc (t) options operator, arrow; E-i__RL(t)*R-L*(diff(i__RL(t), t)) end proc

proc (t) options operator, arrow; E-i__RL(t)*R-L*(diff(i__RL(t), t)) end proc

(4)

"(->)"

10+4*exp(-2*t)-14*exp(-t)

(5)

plot([-4*exp(-2*t)-3+7*exp(-t), 10+4*exp(-2*t)-14*exp(-t)], t = 0 .. 10, color = [red, blue], thickness = 3, labels = ["t", "i(t)_red and vc(t)_blue"])

 

NULL

(1/s-6/s^2)/(s+3+2/s)

(1/s-6/s^2)/(s+3+2/s)

(6)

"(->)"

[diff(x1(t), t) = x2(t), diff(x2(t), t) = -(1/3)*x3(t), diff(x3(t), t) = 6*x2(t)-3*x3(t)-3*u1(t), y1(t) = -6*x1(t)+x2(t)]

(7)

How to solve this by Maple? The answer I want to solve is the plot shown above.

Download DynamicSystem-How_to_ODE.mw

Hi experts, I know built in command to solve definite integral by using simpson and trapezoidal rule but i need to show step which is given in the example to satisfy his students of grade 12. Please help me to solve this example


I have an animation in Maple that only works if I use the option frames=120, or anything >120. Anything less and it gives the error "Error, (in plots/animate) points cannot be converted to floating-point values". I don't understand why this restriction is happening, any advice is appreciated.

First 183 184 185 186 187 188 189 Last Page 185 of 2308