## 13598 Reputation

19 years, 197 days

## MaplePrimes Activity

### These are replies submitted by Preben Alsholm

I have just set the ordering of answers  Date(oldest first):
I want to see if that makes any difference to the loading speed.
My previous setting was order  by votes.

## Very nice!...

@Carl Love Your last version is very good:

```Include0View(plot([3 + sin(x),4-cos(x)], x= -Pi..Pi, thickness= 3));
Include0View(plot([3 + sin(x),4-cos(x),x=-Pi..Pi],thickness= 2,caption="A parametric plot"));
```

## Maple 2023.2...

@Carl Love In Maple 2023.2 it appears that the default in this case is adaptive=geometric.

## Maple 2024.0...

@Carl Love I get:

This is what I get with adaptive = false:

## Vertical asymptotes...

@Carl Love Just a note: Your procedure doesn't handle Rouben Rostamian's example:

Include0View(plot(10 + 1/(x-1)^2, x=0..2, thickness= 3));

## Well......

@Rouben Rostamian  My intention was to see if it is possible to include an option includeaxis1.
Erik Vestergaard seem to be looking for that kind of thing.
Should MapleSoft decide that an option like that makes sense, they obviously don't need my help!

The above isn't meant as a workaround.  I gave such one earlier.
# Incidentally I just simplified my code above, so that plot errors come directly from plot.

## Handling vertical asymptotes...

@Rouben Rostamian  You are right. This option must be restricted to bounded functions.
It could just ignore the option in this case.
Here is what must be a feeble attempt:

```plot2:=proc(f::{algebraic,procedure},r::{range,name=range(realcons)},{includeaxis1::truefalse:=false}) local VW,p;
if not includeaxis1 then return plot(_passed) end if;
p:=plot(f,r,_rest);
VW:=min(0,Optimization:-Minimize(f,r)[1])..max(0,Optimization:-Maximize(f,r)[1]);
if not VW::range(realcons) or hastype(VW,'infinity') then
printf(cat("A vertical range could not be determined.","\n"));
return p
else
plots:-display(p,'view' = VW)
end if
end proc:
plot2(sin(x),x=0..Pi,color=blue);
plot2(sin(x)+2,x=0..Pi,includeaxis1,color=blue);
plot2(10 + 1/(x-1)^2, x=0..2,includeaxis1,color=blue);
plot2(-10 - 1/(x-1)^2, x=0..2,includeaxis1);
plot2(x->6+sin(x)*x,0..2*Pi,includeaxis1,color=blue);
plot2(x->-10 - 1/(x-1)^2, 0..2,includeaxis1);
plot2(sin(x),0..2*Pi,includeaxis1); # error check
plot2(sin,x=0..2*Pi,includeaxis1);  # error check
```

# Somewhat revised: includes the procedural version.

## Thickness...

@Carl Love Thanks Carl. I wasn't aware of that. I tried plotting sin(x) on -Pi..Pi with thickness=0.05.
First I thought there wasn't anything to see, it's that thin.
With a white background and color = white you obviously can't see anything regardless of thickness.

## It should be possible...

@erik10 An option to plot, something like 'includeaxis1' ::truefalse with default false.
To show that it should be possible I played a little below.
I prefer Optimization:-Maximize and Minimize to maximize and minimize. The former are more reliable.

```restart;
P:=%plot(10 + sin(x), x=3*Pi..4*Pi,view=_VW);
f,r:=op(1..2,P);
VW:=min(0,Optimization:-Minimize(f,r)[1])..max(0,Optimization:-Maximize(f,r)[1]);
value(subs(_VW=VW,P));
############
P:=%plot(-10 + sin(x), x=3*Pi..4*Pi,view=_VW);
f,r:=op(1..2,P);
VW:=min(0,Optimization:-Minimize(f,r)[1])..max(0,Optimization:-Maximize(f,r)[1]);
value(subs(_VW=VW,P));
############################
P:=%plot(sin(x), x=3*Pi..4*Pi,view=_VW);
f,r:=op(1..2,P);
VW:=min(0,Optimization:-Minimize(f,r)[1])..max(0,Optimization:-Maximize(f,r)[1]);
value(subs(_VW=VW,P));
```

This is basically just for fun and certainly not a workaround.

## Kronecker indeed...

@ Thanks, I get your point.

```Int(exp(I*m*theta)*exp(-I*n*theta),theta=0..2*Pi)/(2*Pi);
F:=factor(combine(%));

value(F) assuming m=n; # 1
value(F) assuming posint; # 0,  The generic case

```

## _rest...

@Ronan Notice the underscore before rest. That is a clear signal that it means something to Maple.

```p:=proc(x::algebraic) [x,_rest] end proc;
p(2);
p(2,4,fff=87);
```

Inside the procedure it stands for possible extra input to p that is not mentioned as a parameter in p.

We can define the otherwise neutral operator &sublist as an actual operator:

````&sublist` := proc(N::list,lis::list)
local find_element:=
proc(e,L::list)
local idx:=ListTools:-Search(e,L);
if idx=0 then
return [];
elif idx=numelems(L) then
return [L[idx]];
else
return L[idx+1..-1]
end if
end proc;
local final_result::truefalse:=true;
local item,r::list:=lis;
for item in N do
r:=find_element(item,r);
if numelems(r)=0 then
final_result:=false;
break;
end if;
end do;
final_result;
end proc:
```

Then examples:

```[7,2,4] &sublist [2,6,5,7,3,2,9,4];
[7,2,4] &sublist [2,6,5,7,3,2,9,4];
[7,2,4] &sublist [2,1,4,2,6,7,3,9];
[7,2,4] &sublist [7,4,2,7,2,4];
[7,2,4] &sublist [7,7,7,7,2,2,2,7,4];
```

@Kitonum Using nm's code I tried overloading subset to deal with this concept of sublist.
The idea is taking from the help page for overload. See the example "SetOperations".

```ListOperations := module() option package;  export `subset`;
local find_element:=
proc(e,L::list)
local idx:=ListTools:-Search(e,L);
if idx=0 then
return [];
elif idx=numelems(L) then
return [L[idx]];
else
return L[idx+1..-1]
end if
end proc;
#########
local final_result::truefalse:=true;
local item,r::list:=lis;
for item in N do
r:=find_element(item,r);
if numelems(r)=0 then
final_result:=false;
break;
end if;
end do;
final_result;
end proc:
end module:
```

Here are examples:

```with(ListOperations);
[7,2,4] subset [2,6,5,7,3,2,9,4];
[7,2,4] subset [2,1,4,2,6,7,3,9];
[7,2,4] subset [7,4,2,7,2,4];
[7,2,4] subset [7,7,7,7,2,2,2,7,4];
################## Now actual sets:
{7,2,4} subset {2,6,5,7,3,2,9,4};
{7,2,4} subset {2,1,4,2,6,7,3,9};
{7,2,4} subset {7,4,2,7,2,4};
{7,2,4} subset {7,7,7,7,2,2,2,7,4};
{a,b,c} subset {d,e,f,t};
{a,b,c} subset {d,e,b,f,c,t,a};
```

## Certainly...

It is quite noticeable.

## Yes...

@mmcdara Yes, I do that routinely.
E.g. in a procedure using results from a dsolve/numeric/parameters defined outside the procedure.

```res1:=evalf(Int(z(q1, q2), q1=0.1..0.9, q2=0.1..0.9));