Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

A := Matrix(2, 2):
CodeGeneration:-Matlab(unapply(A), optimize, resultname = "A");

Warning, unable to optimize
Warning, procedure/module options ignored
function Areturn = A()
  Areturn = [0 0; 0 0;];
 

What is this behaviour. I can't find any explanation online.

Suppose you do this
 

restart:
with(plots):
with(Statistics):
A := Sample(RandomVariable(Normal(0, 1)), 10^4):
B := Sample(RandomVariable(Normal(0, 1)), 10^4):
ScatterPlot(A, B, symbol=point);

The plot shows a greater density of dots around (0, 0) and they become increasingly sparse as one moves away from (0, 0).
A pretty way to represent such clouds is to do "2D density plots".
You will find some example from R here  2d-density-plot-with-ggplot2.html

For the moment I do something like this (which is to be adpated for almost any particular case).
My main question is: do recent versions of MAPLE possess something similar to R's features?
 

restart:

interface(version);

`Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895`

(1)

with(Statistics):

UseHardwareFloats := false:

N := 10^5:
A := Sample(RandomVariable(BetaDistribution(2, 6)), N):
B := Sample(RandomVariable(BetaDistribution(6, 2)), N):

nb := 50:

mA := min(A):
hA := Range(A)/(nb-1):
mB := min(B):
hB := Range(B)/(nb-1):

cA := floor~((A-~mA)/~hA)+~1:
cB := floor~((B-~mB)/~hB)+~1:

NP := Matrix(nb$2, 0):
for n from 1 to N do
  NP[cA[n], cB[n]] := NP[cA[n], cB[n]]+1
end do:

NP:
 

plots:-matrixplot(
  NP,
  heights=histogram,
  colorscheme=["Blue", "White", "Red"],
  orientation=[270, 0, 0],
  style=patchnogrid,
  lightmodel=none,
  labels=["A", "B", ""],
  axis[1]=[tickmarks=[nb+1=max(B), 1=mB]],
  axis[2]=[tickmarks=[nb+1=max(A), 1=mA]]
)

 

 


 

Download 2D_density_plot.mw

 1. Consider this code line: > a := b; b := c; c := matrix([[1, 2, 3], [3, 4, 5]]);
    • if you ask Maple to return the values assigned to a, b and c, which values will be printed?
    • Are these values the ones you would expect? Why? Which kind of evaluation rule is utilized by Maple to return these values?
   • Show the single steps of the evaluation process and briefly explain the outcome of each evaluation step (hint: use eval (a, 1/2/3), to return each evaluation step).
   • How can you “force” Maple to return the “expected” values for a, b and c? • Extract the first row of the matrix in such a way to have [1, 2, 3] as output. Hint: use the command row/Row and its right syntax (it needs two arguments: the name of the matrix and the number of the row to extract). Be careful to load the linalg/LinearAlgebra package before using the command. Instruction: apply the row/Row command to a, b and c.
  • Can you explain what Maple does in the previous step? Can you explain, in other words, why you get the expected outcome? Hint: remember which are the “drivers” of the evaluation process in Maple (position of the assignment/level of evaluation; type of object / data-structure / datacontainer / procedures / local versus global variables / use of built-in commands, etc.).

      how to write a procedure that shuffle a matrix  (c:=matrix([[1,2,3],[3,4,5]] ) by using command randperm in maple?

What is the logic behind this. 

restart;
expr:=int(f(x),x);
lprint(algsubs(int=Int,expr));
lprint(subs(int=Int,expr));

gives


   int(f(x),x)

   Int(f(x),x)

So algsubs failed to replace int by Int

Looked at help. and see nothing. But I might have overlooked something. It says

It is a generalization of the subs command, which only handles syntactic substitution.

Generalization? If so, I expected it to work here. But may be there is a subtle reason why it did not? May be with algsubs, the replacement has to be algebraic expression and "int" is not, it is just a name.

Maple 2020.2
 

Hello Maple experts.

According to our teacher class notes, the ODE   y'=2*sqrt(y) with IC  y(0)=0 has 2 solutions. y(0)=0 and sqrt(y)=x

I am not able to get Maple to give the second solution,. It only gives y(0)=0.

Is there an option I am overlooking to make it give the other solution sqrt(y)=x ?

ode := diff(y(x),x) = 2*sqrt(y(x));
ic:=y(0)=0;
sol:=dsolve([ode,ic],y(x));

One can see the other solution by doing this

ode := diff(y(x),x) = 2*sqrt(y(x));
ic:=y(0)=A;
sol:=dsolve([ode,ic],y(x));
subs(A=0,sol)

I tried this in Mathematica. Mathematica does not give y=0 but it gives the second solution

I tried the singsol=all also, but it had no effect. Maple only shows the y(0)=0 solution.

Any suggestions?

Maple 2020.2

 

Hello everyone,

I have a question about adding references to a non executable math in a document. Namely, If we use an executable math there is a label that appears on the right of a formula. We can use it as a reference. However, there is no label when we use non-executable math. I wonder how can I refer to that, the point is to create a document with a references to formulas.

To illustrate the point I would like to create a text like the following :

...

X=2 (equation 1)

X=3 (equation 2)

.....Some text here......

From the (equation 2) we can achieve that ....

Regards

Hi

cant get the answer, any comments plz

f := (x, y) ->(1/2)*a*(sinh(y-x^2)+tanh(x-y^3));

evalf(int(int(f(x, y), x = -6 .. 5), y = -5 .. 5)):

Is there any simple way to combine the commands ChromaticNumber(G) and DrawGraph(G), in order to get a vertex coloring of a graph G? Thanks

Hi everybody,

This is my code:

assume(0 < a, 0 < L, a < L);

M := piecewise(0 <= x and x < a, P*x*(L-a)/L, a <= x and x < L, P*a*(L-x)/L);
ode := diff(y(x), `$`(x, 2)) = M/(E*I__0);
ic := y(0) = 0, y(L) = 0;
sol := factor(dsolve([ode, ic], y(x))); assign(sol); y1 := y(x);

I have two questions:

1) How to plot y1?

I would like to plot y1, but in the plot can to specify a values of a, L, P, E and I.

2) How can I find a maximun and minimun value of y1?

I tried to use maximize and minimize commands but really I don't know if I used them correctly.

Thank you.

 

 

Hello everybody,

 

Being a beginner in maple, I tried to make some animations involving geometrical objects.

I haven't been through any problems for typical 2-variables or 3-variables functions.

However, I couldn't get to making 3d-objects like spheres/cylinders.... to grow in link with a parameter (radius, axes...)

I've found lots of procedures to get sphere to rotate but I didn't succeed in adapting them to, for example, an animation showing a growing zero-centered sphere from radius zero to a radius n (variable entered by the user).

Thank you for your reading, your patience and your kindness.

 

This is a piece of code from my file.

 g(1,a) should be 0, but not. I find some other questions  mentioned  assuming n::posint, but it does not take effect, so how could I avoid this? Thanks.

a := 0.12;
kn := n -> (n + 0.5)*Pi/a;
g := (n, x) -> cos(kn(n)*x);
g(1, a);
 

Hello  i have this pb i don't now what to do :
 

Error, (in simplify/tools/_zn) too many levels of recursion

thank you 

inside a local proc, when calling a  function such as map using the syntax map(x->x^2, target) does one need to declare as local inside the proc?

Same for other Maple calls, which uses something similar. For example 

subsindets(expr,'specfunc( anything, csgn )', f->simplify(f));

does one need to declare local to the proc where the above call is made?

Which one of these two example is more correct?

restart;
foo:=proc(expr)
  local x;
  map(x->x^2,expr);
end proc;

foo([x,y])

vs.

restart;
foo:=proc(expr)
    map(x->x^2,expr);
end proc;
foo([x,y])

In Mathematica for example, such symbols used by similar functions of the system (for example, Plot command, and others) are automatically localized to the system call itself avoiding any conflict with user own symbols.

I am not sure how Maple handles this. Should one always declare these symbols?

Maple 2020.2

 

 

I have a parametric polynomial which is defined based on the multiplication of different variables and I want to rearrange the polynomial based on specific variables. For example, suppose the polynomial is defined as follows:

a:= (1+x+y)(2x-yx+z)(y^2-zy)

and I want to have a based on first, and second orders of x, or even other variables. Thanks

First 348 349 350 351 352 353 354 Last Page 350 of 2097