nm

11353 Reputation

20 Badges

13 years, 19 days

MaplePrimes Activity


These are questions asked by nm

This is a new question came up from a follow up to https://www.mapleprimes.com/questions/225083-Maple-Command-To-Find-Domain-Of-Function

Does Maple have support for removing points from an interval automatically? An example will make this clear. This is all on the real line. No complex domain.

Given one interval,. say real_domain :=  x>-infinity and x<infinity: and now I want to remove from this interval, another interval. This second interval can be defined as single point(s) or as interval(s) itself. 

I will give an example of both.

when the singularity interval to remove is defined as one or more single points, here is an example using one point:

real_domain :=  x>-infinity and x<infinity:
singlarity_pt := 1/2:

So I want Maple to give me automatically the new interval as   {x>-infinity and x<1/2} , {x>1/2 and x<infinity}:

Becuase the singularity point was "removed" from the real domain. I tried solve, but it did not work

solve(x<>singlarity_pt and real_domain,{x})
                         

I know I could probably code this by hand, and add logic to figure it if the singularities are points. But this can get complicated if the real domain itself has many sub intervals itself. I thought Maple should be able to do this. fyi, In Mathematica, this is done as follows

singularity = 1/2;
realDomain = -Infinity < x < Infinity;
Reduce[x != singularity && realDomain , x, Reals]

Here is second example where now the singulartiy interval to remove, is not single point, but an interval itself. I found that in this case, solve did the right thing

real_domain :=  x>-infinity and x<infinity:
singlarity_domain := x>-1/2 and x<1/2:

Now the final domain should be   -infinity<x<-1/2 , 1/2<x<infinity, 

solve( not(singlarity_domain) and real_domain,{x})

The question is, why it worked when the singulaity is an interval, but it did not work when it is a specific point? And how can one make it work for single points? Is there a different command to use other than solve for this?

In general, singularities can contain single points and also intervals, but single points is more commin. So I need it to work for both cases.

This has to be done non-interactivally and without plotting or such, as it will be part of a script. 

Thanks for any hints

 

I can't final an equivalent to Mathematica's Flatten for sets. I know Maple has ListTools:-Flatten for lists.   

For example, given set r:={a,{b,c},d,{e,f,{g,h}}}; How to convert it to  {a,b,c,d,e,f,g,h}; 

does one have to convert each set and all the inner sets to lists, then apply ListTools:-Flatten to the result? How to map convert(z,list) for all levels?

     map(z->convert(z,list),r);

does not work, since it only maps at top level, giving {[a], [d], [b, c], [e, f, {g, h}]}

So doing

   ListTools:-Flatten(convert(map(z->convert(z,list),r),list));

Gives [a, d, b, c, e, f, {g, h}] 

 

     

I can't figure out why this pattern is failing

restart;
r:= y=3;
patmatch(r,y=z::integer,'la');
patmatch(r,identical(y)=z::integer,'la');
patmatch(r,y::anything=z::anything,'la');

What Am I doing wrong?

 

 

 

Does Maple have a function which finds the domain of its variables such that the function is real valued?

I am only interested in a function of two variables, x and y.  I'd like to know what is the range of x and y, where f(x,y) is real valued.

For example, given f(x,y)= x * ln(y), then the domain is all of x, and for y>0.    So it is the upper half plane.  For f(x,y)=sin(x)*cos(y), then it is the whole plane (all x and all y) and so on. 

I looked at singular(), and this does part of what I want, but it only gives me the singular points. So for the above it gives y=0 and x=x, but I am looking for something a little more specific. I also looked at package called RealDomain, but I do not see how to use this for what I want to do. But I could have missed something.

I do not know what the function is beforehand, but it will always be a function of x and y, and I need an automated way to determine the range of x and y where this function is real valued. 

I can't do plots and look at them, since this is all automated and has to be done algorithmically only and non-interactive.

I could use singular, and try evaluating the function at different points and see if it produces real or complex values, but this is not practial to do and can fail.

Does Maple have support for such functionality?

 

I am still buffled by a Record in Maple.

I simply want to make one variable be a Record. Then make separate variable, by making a COPY of the content of the first variable, then change the second variable. Sounds easy, right?

When I do this, I find that the changes in the second variable are being made also to the first variable.

I used eval() to make a copy of all field of first variable to the second.  May be this is not the correct way, but do not know how else (other by explicit copying one field one at a time).

I looked at help, and see nothing there. It talks about making the Record packed. I tried that, but it is still not working. Not a single example in help of how to copy the "content" of one record to another.

I simply want to make a new instance of the first variable, a copy. and change the second instance without the first changing at same time. Why is this so hard in Maple?

restart;
c:=Record('a','b'):
c:-a:=0:
c:-b:=-1:

c1:=eval(c): #make a copy of c??
print("c1=",eval(c1)); #yes, made a copy

c1:-b:=99:  #change one field  in the second variable

print("c1=",eval(c1));
print("c=",eval(c)); #why did c change?

I tried using Record[packed]('a' , 'b'): since help says something about same Record sharing same memory but that make no difference.

How to make a copy of a record to another in Maple without them being the same? I know I could do this

restart;
c:=Record('a','b'):
c:-a:=0:
c:-b:=-1:

c1:=Record('a','b'):
c1:-a:=c:-a;
c1:-b:=c:-b;

c1:-b:=99:  #change one field  in the second variable

print("c1=",eval(c1));
print("c=",eval(c)); #Now it did not change.

But my actual record has many fields. and I do not want to do the above each time.

First 152 153 154 155 156 157 158 Last Page 154 of 199