MaplePrimes Questions

I am using Maple 2020.2 and it seems that the Linear Algebra package is incompatable with the Vector Calculus package:

Why not a friendly error message?
I want to use the Jacobian and the Hessian. Are there alternatives? MTM package can give a Jacobian, but no Hessian (but MTM is also tricky to use).

Harry

 

I am attaching the maple sheet in which you may see the function f I defined. I am using MacBook Pro and Maple 2020

test1.mw

Which one of these two versions, is the recommened one to use? For example, to check for type  integer*x, where x is literal x. i.e. identical(x)

restart;
TypeTools:-AddType('type_1', `&*`(integer,identical(x)));
type(3*x,type_1);

restart;
TypeTools:-AddType('type_1', '`*`'({integer,identical(x)}));
type(3*x,type_1)

Both work.  The difference is that `*` needs {} while `&*` does not.

I read the help page  and I do not understand what it says about the difference, and when is one supposed to use `*` vs. `&*`. it says 

              | `*`(type)  a product of factors of the given type
              | `&*`(type*)  a product of factors in which the nth factor is of the nth type specified in type*

Could possibly someone please explain in simple plain english what is the difference? If I use `&*`  vs. `*` with {}, will they work the same all the time or are there cases when to use one vs. the other?  Any rules of thumb to follow?

I need to simplify terms such as (cos(x)^2+sin(x)^2) to 1 if present in input, but I do not Maple to also do any other simplification rewriting polynomials that might be present in the expression.

And example will make it clear. Given this

expr:= (cos(x)^2+sin(x)^2)+5+(1+x+x^2+x^3)*(cos(x)^2+sin(x)^2)*exp(x);

I want expr to become  6+(1+x+x^2+x^3)*exp(x).   i.e. only simplify trig terms

But simplify(expr,trig); gives

                 6 + (x + 1)*(x^2 + 1)*exp(x)

Which is not what I want. Then I tried the trick of thaw and freeze to tell Maple to freeze polynomial type, like this

restart;
expr:= (cos(x)^2+sin(x)^2)+5+(1+x+x^2+x^3)*(cos(x)^2+sin(x)^2)*exp(x);
thaw(simplify(subsindets[flat](expr,satisfies(Z->type(Z,polynom(integer, x))),(freeze))));

And it actually worked, giving

           6 + (x^3 + x^2 + x + 1)*exp(x)

Question is: Why did simplify(expr,trig) not do what expected, which is to only simplify trig terms in expression and not mess around with the polynomial there? 

Is the above method of thaw/freeze to control which parts of expression gets simplify a recommended way to work around this, or is there a better way?

 

Please help to solve the equation 

Maple Worksheet - Error

Failed to load the worksheet /maplenet/convert/Coefficients.mw .
 

Download Coefficients.mw

Hello everyone,

im new here and i've nerly no expertise in pd-equations. I was trying to solve this pd-system with the following-code:

 

with(plots);
with(DEtools);
with(PDEtools);


`εg` := .4;
`εs` := .6;
mg := 1;
mgs := 1;
`ρg` := 1.2;
`ρs` := 1100;
cpg := 1006;
cps := 880;
cpwa := 1920;
`αGS` := 20;
as := 800;
h_ads := 2700000;
pdgl1 := `εg`*`ρg`*(diff(xG(t, z), t)) = -mgs-mg*(diff(xG(t, z), z));
pdgl2 := `εs`*`ρs`*(diff(xS(t, z), t)) = mgs;
pdgl3 := `εg`*`ρg`*(cpg+xG(t, z)*cpwa)*(diff(TG(t, z), t)) = -mg*(cpg+xG(t, z)*cpwa)*(diff(TG(t, z), z))+`αGS`*as*(TS(t, z)-TG(t, z));
pdgl4 := `εs`*`ρs`*(diff(TS(t, z), t))*(cps+xS(t, z)*cpwa) = mgs*h_ads-`αGS`*as*(TS(t, z)-TG(t, z));
Init := {TG(0, z) = 401.15, TG(t, 0) = 401.15, TS(0, z) = 293.15, TS(t, 0) = 293.15, xG(0, z) = 0.5e-1, xG(t, 0) = 0.5e-1, xS(0, z) = .33, xS(t, 0) = .33};
sol := pdsolve({pdgl1, pdgl2, pdgl3, pdgl4}, Init, type = numeric, range = 0 .. 1, time = t);


Error, (in pdsolve/numeric/par_hyp) Incorrect number of boundary conditions, expected 2, got 4

 

 

When i change initial conditions to 4 it says he expected 2 and when i put 2 it says he expected 4.

Can anyone tell me where my misstake is or in what direction i have to look for an answer.

 

Thanks from before.

 

Can 

 

Hi,

I have the following problem with plots in Maple 2020: I wanted to create several plots which should have the exact same size. I used the command size = [400,400] and Maple is creating a plot with that size, but Maple applies a white frame to my plots which does not have the same size in all cases (see the red mark of different length in the pictures below), so that the effective size differs, which is extremely ugly if you want to arrange several pictures in a document. So my question is

1.) How to remove this white frame, so that the efftictive picture size is actually 400x400?

2.) If 1.) is not possible, how can I adjust the frame so that it always has the same size?

My Code:

with(plots);
with(ColorTools);
with(plottools);
plot1 := inequal(0 <= y^3 + x^2, x = -5 .. 5, y = -5 .. 5, filledregions, color = blue, background = "Gainsboro", size = [400, 400]);
plot2 := plot(x = -5 .. 5, y = -5 .. 5, background = "Gainsboro");
ll := line([-3, 0], [3, 0]), color = blue, thickness = 5;
l := line([-3, 2], [5, 5]), color = blue, thickness = 2;
display(plot2, l, size = [400, 400]);

Thanks for your help.

I can't figure how to make my own type, which is rational and greater than one.

There are buildin types for postive and posint, and so on. But what if I want to make for rational and greater than some value, say 1?

This is easy to do using patmatch, using the conditional. But do not know how to do it to make my own type.

Here is a simple example. I want to check for sin(x)^n, where n is rational and must be >1.  Using pathmatch

restart;
patmatch(sin(x)^(1/2),conditional(sin(x)^a::rational,a>1),'la');la;

does it. Using structured type, the best I could do is this

restart;

TypeTools:-AddType('my_sin',specfunc(sin)^And(rational,positive));
type(sin(x)^(1/2),'my_sin');

But this does not check for >1, only positive.

Any suggestions? I know I could do this using other means, by direct parsing, using op, and so on. But I'd like to learn how to do it using structured type, just to learn the syntax if there is one.

is it possible to use conditional with structured types? But need  name to do that, like with patmatch, but there is no such syntax in structured types. 

ps. I think conditional does not make much sense with structured type. But I need to figure how to make my own type, which is rational and say >1, or integer and say >2 and so on. I just do not know how to do that yet. But I am sure there is a way. Will try to figure it out.

 

 

Hi please  help me in this problem in maple 18 

How do I solve the system K=B and find values 

x_{0},y_{0},z{0}

I posed the problem in the form pdf and mw

thank you 

problem.mw

problem.pdf

 

 

I can't get pdsolve to solve this pde. Here are my tries below. One of them works, but the analytical solution Maple gives is wrong. So I am not sure if it needs some additional hints or some other help to make it give the correct solution.

This is Laplace pde but with non-zero on RHS. On disk centered at origin and with radius 1, with given BC on edge of disk.

restart;
the_rhs := r^2*cos(theta)*sin(theta);
pde := VectorCalculus:-Laplacian(u(r,theta),'polar'[r,theta])=the_rhs;
bc := u(1, theta) = cos(theta)*sin(theta);
sol:=pdsolve([pde, bc], u(r, theta));

Maple gives

But this does not look right. There is a complex exponential on its own there. The solution should be real. 

I tried to solve it using pdsolve numerically, but could not make it work. It kepts complaining about missing BC. I am not good with numerical solvers in Maple. May be someone could try to do it.

evalf(eval(rhs(sol),[r= sqrt(1/4 + 1/4),theta=Pi/4]))

gives 0.5951891582 which is wrong,. It should be  0.23958

It tried to give it the symmetry conditions on theta, but now it did not solve it

restart;
the_rhs := r^2*cos(theta)*sin(theta);
pde := VectorCalculus:-Laplacian(u(r,theta),'polar'[r,theta])=the_rhs;
bc := u(1, theta) = cos(theta)*sin(theta),u(r,0) = u(r,2*Pi),(D[2](u))(r, 0) = (D[2](u))(r, 2*Pi);
sol:=pdsolve([pde, bc], u(r, theta));

No solution. I tried adding HINT = boundedseries(r=0) but that also did not help. No solution.

Could someone solve this PDE numerically in Maple and check the solution at the above location? It should be 0.23958 which shows the analytical solution given is not correct. Can Maple solve this numerically?

Maple 2021.1

ps. Analytical solution was obtained by Mathematica. I did not solve this by hand.

Hello,

I have lists of points of different ranges that I want to plot on the same graph. I would not want to manually cut the list for the range I want to see (there are many lists) so I thought about the view option. But there seems to be a strange behaviour of pointplot combined with view:

restart;
with(plots);
pointplot([[0.1, 0.5], [0.7, 0.7]], view = [0 .. 1, 0 .. 0.1]);

 

Hello Everyone,
I have written a procedure which takes one input and gives one output. Now, if I want to find the root of that procedure (as in when my procedure gives a '0' output), Is there any method to do it directly?
One idea that I got is to use maple's inbuilt Secant method (with(Student[NumericalAnalysis]). But this method can be done only for functions. Hence, my question.
How can we convert a maple procedure which takes one input and gives one output into a maple function? Also, is there a method to apply secant method on such function?
Please consider the following example:

As can be seen, it seems not possible to apply secant method on procedures.
Can someone please help me in doing this or any alternate method to get the job done?


 

I would like to assign the values of basis vectors which are calculated by PlanePlot. Is there anyone who knows how to use them or how to imitate the command?

PlanePlot(z+tan(-Pi/2+alph||29)*(x*sin(-Pi/2+gam||29)-y*cos(-Pi/2+gam||29))=0, [x,y,z],showbasis):
normal vector: <-.2497, .7343e-1, 1.>
equation of plane: -.2497*x+.7343e-1*y+1.*z = 0.
point on plane nearest origin: <-0., 0., 0.>
basis vectors: <.7106e-1, .9959, -.5539e-1>, <.9678, -.5539e-1, .2457>

It looks like as below:

I was expanding an expressions, and found that Maple expands trig also. Then found there is a way to turn that off. Which is great. I tested it in my worksheet and it works. But when I put the same code inside my module, I get an error.  It seems like some scoping issue which I do not understand.

Here is a MWE

restart;
expr:=(1+x)*sin(3*x+k);
forget(expand);
expand(expandoff());
expandoff(cos,sin,exp);
F:=expand(expr);
forget(expand);

which gives 

Which does what I want. But inside a proc, the code fails

foo:=proc(expr)
local F;

forget(expand);
expand(expandoff());
expandoff(cos,sin,exp);
F:=expand(expr);
forget(expand);

end proc;

And now when calling it as 

expr:=x*sin(3*x+k);
foo(expr)

What Am I doing wrong? And how to make it work? I need to prevent expand() from expanding these functions. Help says that expand has memory table, and I want to clear that before and after doing this, so it does not affect later code.

Maple 2021.1

Update

I just found out, if I add a restart before defining my function, then the error goes away

restart;
expr:=(1+x)*sin(3*x+k);
forget(expand);
expand(expandoff());
expandoff(cos,sin,exp);
F:=expand(expr);
forget(expand);

restart;  # had to add this. But why??
foo:=proc(expr)
local F;

forget(expand);
expand(expandoff());
expandoff(cos,sin,exp);
F:=expand(expr);
forget(expand);
end proc;

#
expr:=(1+x)*sin(3*x+k);
foo(expr)

#no error. now it works

I need this to work repeatedly inside a module, so I can't do restart each time ofcourse like the above.

Even if I do restart before defining the function, next time I call it, it will fail:

 

restart; 
foo:=proc(expr)
local F;

forget(expand);
expand(expandoff());
expandoff(cos,sin,exp);
F:=expand(expr);
forget(expand);
end proc;

#
expr:=(1+x)*sin(3*x+k);
foo(expr); #OK
foo(expr); #FAILED

Very strange. 

First 272 273 274 275 276 277 278 Last Page 274 of 2308