Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Hi,

this has been asked before but none of the other answers worked for me. I want to generate code from expressions that were simplified using some assumptions. I the assumptions remain on the variables Maple replaces variable names wich I don't understand.

Here is my script where I tried to remove the assumptions based on the answers of previous questions. Unfortunately, even though assumptions are removed in the end, Code generation still replaces the variables.

Thank you in advance!

Here is my minimal exaple Code:

 

restart:

 

# test removing assumptions

funa:=x+y

x+y

(1)

 Maple_proc := codegen[makeproc](funa,(ListTools[Flatten]([eval(alist,1)])));

proc (alist) x+y end proc

(2)

# make some assumptions

assume(x,real);assume(y,real);

x,y

x, y

(3)

#place variables in a list

alist:=[x,y];

[x, y]

(4)

# make cool interferences with assumptions...

# clear assumptions

# try 1 from https://www.mapleprimes.com/questions/207601-Remove-Assumptions-

nms:=convert(indets(alist,name),list);
nmsS:=convert~(nms,string);
L:=StringTools:-Substitute~(nmsS,"~",""); #Removing "~"
L1:=parse~(L);
S:=nms=~L1;
Expr:=subs(S,expr);

[x, y]

 

["x~", "y~"]

 

["x", "y"]

 

[x, y]

 

[x = x, y = y]

 

expr

(5)

hasassumptions(x)

true

(6)

# try 2

nops(alist)

2

(7)

for i from 1 to nops(alist) do
parse(cat(StringTools[Substitute]~(alist[i],"~",""),":='",StringTools[Substitute]~(alist[i],"~",""),"'"));
end do;

'x'

 

'y'

(8)

# check if assumtions are there

hasassumptions(x)

true

(9)

#try 3 https://www.mapleprimes.com/questions/39555-Unassume

for u in alist do
`property/object`[u]:=evaln(`property/object`[u]);
`property/OrigName`[u]:=evaln(`property/OrigName`[u]);
end do;

`property/object`[x]

 

`property/OrigName`[x]

 

`property/object`[y]

 

`property/OrigName`[y]

(10)

hasassumptions(x)

false

(11)

hasassumptions(y)

false

(12)

alist

[x, y]

(13)

funb:=x+y

x+y

(14)

 Maple_proc := codegen[makeproc](funb,(ListTools[Flatten]([eval(alist,1)])));

proc (x, y) x+y end proc

(15)

 Maple_proc := codegen[makeproc](funa,(ListTools[Flatten]([eval(alist,1)])));

proc (x, y) x+y end proc

(16)

 

 CodeGeneration[C](Maple_proc, optimize, declare=[x::float,y::float], defaulttype=float, deducetypes=false, coercetypes=false, output="fun.c");

Warning, the following variable name replacements were made: x~ -> cg, y~ -> cg1

 

 

>

 

 

 

 

 

 

 

 


 

Download testunassuming.mw

please I need the code to calculate the convergence order of a multipoint iterative method to solve nonlinear equation systems.

 

my email is: yjmsigma@gmail.com

 

is there a way to change the color of just the labels on the axis ticks only? 

I wanted to do this for DEplot, but I started with normal plot since it is easier. I could change the colors of the axis, but this changes not only the tick labels but the whole axis itself:

restart;
plot(sin(x),x=-Pi..Pi,axis=[tickmarks=[color=red]], color=blue);

So the axis itself changed color as well. It is OK for the ticks as well as the ticks labels (the numbers of the ticks). But prefer the axis itself not to be red.

Once there is a way to do the above, I wanted to apply to DEtools:-DEplot. Why? Becuase it is hard to read the Axis tick labels on DEplot. I thought that changing the color of the tick labels will it easy. But DEtools:-DEplot does not even accept axis command:

ode:= diff(y(x),x)=2*x:
DEtools:-DEplot(ode,y(x),x = -2 .. 2,y = -2 .. 2, [[0.1,0]],
               labels=["",""],
               linecolour = red,
               color = blue,
               'arrows' = 'medium',
               axesfont=['Times', 'bold', 12]
               );

 

You can see it is hard to read the axis tick labels above, as arrows go over some of them,. If I make them say RED, I think it will make it more clear.

Now when adding the axis options, it gives error

DEtools:-DEplot(ode,y(x),x = -2 .. 2,y = -2 .. 2, [[0.1,0]],
               linecolour = red,
               color = blue,
               arrows = MEDIUM,
               axesfont=['Times', 'bold', 10],
               axis=[tickmarks=[color=red]]
               );

Error is generated, axis is not supported command.

Any idea how to make tick labels red for DEtools:-DEplot? It will be OK if I can get both the axis and the ticks RED, at least it will be better than it is now.

One workaround way I currently use is this:

ode:= diff(y(x),x)=2*x:
p1:=DEtools:-DEplot(ode,y(x),x = -2 .. 2,y = -2 .. 2, [[0.1,0]],
               labels=["",""],
               linecolour = red,
               color = blue,
               'arrows' = 'medium'                    
               );
p2:=plot(0,x=-2..2,y=-2..2,axis=[tickmarks=[color=red]]);
plots:-display([p2,p1]);

 

But this seems like a hack to me. There should be a way to directly set tickmarks color in DEplot?

Help me extracting the data from the Maple figure. I was used the 'implicitplod3D' command to draw the figure.  I want to save the parameters of sigma, A  and f0 in Exce
 

af_eq := (3*alpha[2](t[1], t[2])*A^3*(1/8)-A*sigma)^2+(1/4)*alpha[1](t[1], t[2])^2*A^2 = (1/4)*f0^2

(0.4871250000e-1*A^3-A*sigma)^2+0.2500000000e-2*A^2 = (1/4)*f0^2

(1)

with(plots, implicitplot,implicitplot3d):

 alpha[1]:=0.1;alpha[2]:=0.1299;

.1

 

.1299

(2)

##3D

implicitplot3d(af_eq, sigma = -1.5 .. 1.5,f0 =0..0.5, A = 0 .. 5,numpoints = 20000,style=surfacecontour,contours = 15);

 

 

 


 

Download extract_data_from_the_figure.mw

l format. then, I can use the data draw a picture in other software. Many thanks.

I have a PDE system, which has IBCs that involve the unknown functions of the system. This system describes the mechanical evolution of a material volume, where material boundaries vary (it is an open physical system with mass addition). This problem has an analytical solution, but I am looking for a numerical solution. I do not know how to solve this (actually, I do not know if that's possible). I made a few attempts and I did not succeed.

On the last attempt, pdsolve returned the following error message: "Error, (in pdsolve/numeric/process_PDEs) PDEs can only contain dependent variables with direct dependence on the independent variables of the problem, got {u(H(t), t)}".

PDE_SYS.mw  (I re-uploaded the file because there was an error)

Well, I'd like some help on that. Thank you.

I am a little bit clueless here, about how to use maple to calculate Christoffel symbol and Ricci tensor and scalar?

 

I read the help, but it got me confused; I have the metric ds^2 = du*dv+F(y,z)du^2+dy^2+dz^2

It's not Minkowski nor Cartesian, so how to use maple to calculate these symbols?

 

I am sure it's easy, but I didn't quite follow maple's instructions.

 

Hello!

I am interested in plot the so-called "free space diagram", please see https://en.wikipedia.org/wiki/Fr%C3%A9chet_distance for a formal definition. Essentially, given two curves (i.e., two polygonal from [0,1] to the plane) the "free space" is the points (s,t) in the square [0,1]x[0,1] such that the distance from P(s) to Q(t) (if P and Q are the parametrizations of the curves) is less or equal than a prefixed epsilon>0. An image can be the following (the free space is, in the image, the area not colored in black):

 

 

I have found nothing about this topic in Maple, any suggestion will be welcome!

 

Thanks!

 

Hello guys

I have a simple but crucial question about variation, especially in cosmology and gravity. suppose we have the action such as

S=int(sqrt(-g)*F(R,RµναβRµναβ),d^4x) where g is determinant metric gµν and d^4x is space in 4D and F is an arbitrary function of R (Ricci scalar) and scalar which created by Riemann tensor. How we can define this action in the maple 18 and take variation with respect to the metric.

thanks

how to write in mape 
if x not real set x =b

Is there a place to read about rules for naming constants of integrations for solution of ODE so that Maple odetest will not have problem verifying solution of an ODE?

It seems Maple does not like some constant names. If I use C or C1 or C[1] or A etc... odetest does not give back zero, even thought the solution is exactly the same as Maple's, except Maple uses _C1.

I read one is not supposed to use _ constants in own code, since these are reserved for Maple.

So what is one supposed to use? Here is an example

restart;
ode:=2*sqrt(x)*diff(y(x),x)=sqrt(1-y(x)^2):
my_sol:=y(x)=sin(sqrt(x)+(1/2)*C1);

Compare to Maple own solution

maple_sol:=dsolve(ode,y(x));

You can see, there is no difference, except the name of the constant.  Yet, Maple does not odetest my solution

odetest(my_sol,ode);

I tried naming my constant to C, C[1], A, Z, etc.. I got tired trying. Only when I use _C1 does Maple give zero for odetest.

What is so special about _C1?  And if one can't use _ symbols as Maple says, what is one to to do? 


Maple 2018.1, Physics version `2018, July 21, 4:16 hours, version in the MapleCloud: 78, version installed in this computer: 78`

 

Both the equation defining a PDE and its boundary conditions involve functions that are the result of the numerical resolution process of an ODE system.

The PDE solution is obtained. However, when I want to calculate the value of the solution at some point the following error message is displayed: "Error, (in solnproc) unable to compute solution for t>HFloat(1.8936825887327868e15): unable to store HFloat(undefined)+HFloat(undefined)*I when datatype=float[8]".

I tried to formulate the problem differently. However, the error appeared again.

Where am I going wrong?

I've attached the PDE.mw file to the conference. 

Thank you for your help.

 

I would like to do the following operation:

Apparently, Maple does not do this operation.

Does anyone know how to do this?

Thanks in advance.

Hello,

When 3d-Plotting a function say f(z)=sqrt(z)=sqrt(x+I*y) then Maple automatically only plots the principal branch.

In the example above is it possible to plot the second surface too?

Is it also possible to plot the full continuous Riemann surface as in

https://en.wikipedia.org/wiki/Riemann_surface#/media/File:Riemann_sqrt.svg

or

http://mathworld.wolfram.com/RiemannSurface.html

 

???

From answer posted in https://www.mapleprimes.com/questions/225137-Internal-Symbol-Z1--Causes-Error-

I've learned to use

subsindets(expr, 'suffixed(_)', f->n);

To replace in a Maple generated solution which contains system suffix, such as _Z, _Z1, etc... returned by Solve and Maple calls, with a symbol that I find easier to read. The above works in some cases but not others. For example, it works on this result

restart;
expr:=signum(0, _Z, 1);
subsindets(expr, 'suffixed(_)', f->n);

                      signum(0, n, 1)

But not on this one

restart;
expr:=RootOf(signum(0, _Z, 1));
subsindets(expr, 'suffixed(_)', f->n);

             RootOf(signum(0, _Z, 1))

I do not want to use pattern matching, since the result is something I do not know what it will be. I just want to replace all those Maple symbols that start with _Z in the solution by another symbol. I can't use subs() either, since I do not know what the symbol will be.

What is the correct way to do this?

 

Should this generate an error?

restart;
r:=evalc(Im(1/ln(x)));
solve(r,{x});

 

This did not help. Same error as above.

restart;
r:=evalc(Im(1/ln(x))):
solve(r,{x}) assuming x::real;

This made Maple not give an error

restart;
r:=evalc(Im(1/ln(x))):
solve(r,{x}) assuming x::real, x>0;

       {x = x}

Also this worked, but NULL returned

restart;
r:=evalc(Im(1/ln(x))):
solve(r,{x}) assuming x::real, x<0;

Also this worked with NULL returned

restart;
r:=evalc(Im(1/ln(x))):
solve(r,{x}) assuming   x<0;

Is this how Maple generally works? i.e It generates an exception error when it is not able to solve something? Or does it normally echo back the input back if it can't solve something? Or at least return NULL if it can't solve it? I am havin hard time figuring which method to use to check if Maple is able to solve something or not, because each time it seems to do something different.

Should one then put a try/catch around each Maple call, and treat the try section as if Maple was not able to solve the equation whatever it was?

 

First 777 778 779 780 781 782 783 Last Page 779 of 2218