## 17 Badges

7 years, 318 days

## A question about the order used in coeff...

Maple

Let P(x) a polynomial with a single indeterminate.
In Maple 2015 (please, do not consider this question if Maple >=2021 doesn't present this problemcoeffs returns the coefficients P(x) in a different in some circumstances:

```m := [\$1..3]:

add(m[k]*(R)^(k-1), k=1..3):
c:= coeffs(%, R, 't'): [c], [t];

[ 2      ]
[3, 2, 1], [R , R, 1]
add(m[k]*(R)^(k-1), k=1..2):
c:= coeffs(%, R, 't'): [c], [t];
[1, 2], [1, R]
```

The order in the first case is R^2, R^1, R^0 while it is R^1, R^0 in the second one.

It's quite easy to check if P(x) is of the form a+b*R and to reverse the output of coeffs. But does it exist an option of coeffs which monitors the output order.

TIA

## How can I obtain this result?...

Maple

Is there a simpler and more elegant way to get the last result in this code snippet?

```add(f~([op(a+b)])[]);
f(a) + f(b)
# simpler and more elegant
map(f, a+b);
f(a) + f(b)
# now I want to obtain this result
add(f~([op(a+b)], t)[]);
f(a, t) + f(b, t)
```

TIA

## How to use the type ':-RandomVariable' i...

Maple 2015

Hi,
I met a an unexpected behaviour of a procedure when the parameter sequence contains the type ':-RandomVariable':

```restart:
with(Statistics):
f1 := proc(A::':-RandomVariable')
Mean(A)
end proc:

Z := RandomVariable(Normal(mu, sigma)):
hastype(Z, ':-RandomVariable');
f1(Z)
true
Error, invalid input: f1 expects its 1st argument, A, to be of type 'RandomVariable', but received _R
# Another attempt
f2 := proc(A)
if hastype(A, ':-RandomVariable') then Mean(A) end if;
end proc:

f2(Z)
mu
```

Why does f1 generate this error?

Type_RandomVariable.mw

## The vertical axis is logarithmic even if...

Maple 2015

Version used MAPLE 2015.2

I use dualaxisplot and want a logarithmic horizontal axis.
I can get the expected graphic using either of these two methods

```restart:
with(plots):
dualaxisplot(
plot(x, x=0..1, color=blue, axis[1]=[mode="log"]),
plot(1-x, x=0..1, color=red, axis[1]=[mode="log"]),
gridlines=true
):

dualaxisplot(
semilogplot(x, x=0..1, color=blue),
semilogplot(1-x, x=0..1, color=red),
gridlines=true
):
```

This worksheet contains my true code
(pink lines correspond to < plot + axis[1]=[mode="log"] > and blue lines to < semilogplot >).
You will see that the vertical axis for the plot declared in second position is logarithmic, whatever the way the logarithmic x-axis is defined.
DecisionProb.mw

I am unable to find out if I made a mistake (which is likely) or if it is a bug?
Could you please have a look at this code and give me an answer?
Thanks in advance

## How does the range option affect the way...

Maple

I recently got stuck on a strange behavior of odeplot which did not return any result (only the axes were drawn).
Convinced that the solution of the differential system was correctly constructed, I noticed that drawing it, without using odeplot, gave me the correct result.
I then discovered that the range option (which I mistakenly defined) was the cause.

But this led me to the following question: what does this option really do?

Here is a notional example. The two questions are at the end of the worksheet.

 > restart:
 > interface(version)
 (1)

EXAMPLE 1

 > sol := dsolve({diff(x(t), t) = t, x(0)=0},numeric, events=[[x(t)=2, halt]], range=0..1)
 (2)
 > # As range is defined up to t=1 and x(t) = t^2/2 = 2 for t=2 it seems "normal" # for the event not to be fired: Tend := sol(eventfired=[1])[]
 (3)
 > # But the limitation induced by range seems ignored by odeplot: plots:-odeplot(sol, [t, x(t)], t=0..4);

EXAMPLE 2

 > sol := dsolve({diff(x(t), t) = t, x(1.1)=0},numeric, events=[[x(t)=2, halt]], range=0..1)
 (4)
 > # For the same reason the event is still not fired here Tend := sol(eventfired=[1])[];
 (5)
 > # odeplot doesn't return any plot. # # This seems logical given that range=0..1 is not consistent with the initial # condition set at t=1.1 # Nevertheless the warning message looks contradictory with the fact that the event is not fired plots:-odeplot(sol, [t, x(t)], t=1.1 .. 4);
 > # Remark: using refine seems to fix this problem plots:-odeplot(sol, [t, x(t)], t=1.1 .. 4, refine=1);
 > # Let's try to plot the solution differently. X := proc(s) eval([t, x(t)], sol(s)) end proc: plot([seq(X(s), s=[seq](1.1 ..4, 0.1))])
 > # Why is the solution calculable? # Why can't odeplot calculate it?
 >

Download The_role_of_range.mw

Please note that the last couple of commands strangely overpasses the < Warning, cannot evaluate the solution further right of 2.2825424, event #1 triggered a halt > limitation.

 5 6 7 8 9 10 11 Last Page 7 of 42
﻿