## 4555 Reputation

6 years, 300 days

## 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?

## 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?
 >

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.

## MatrixPower doesn't give the right answ...

Maple

I incidently(*) discovered that using MatrixPower to find the square root matrix of a relatively small matrix, returns wrong results, even for symetric positive definite matrices.

Trying to understand how MatrixPower proceeds using showstat is not that easy, but something I'm almost sure is that it doesn't ise an Eigenvectors decomposition.

Here is an example where I'm seeking for a matrix M such that C = M^2 and C is symetric definite positive of dimension 40.
(I didn't check if problems already occurs for smaller sizes)

(*)  I was very bored by the prohibitive execution time of MatrixPower and looked for an alternative.

The matrix M that MatrixPower generates is far from verifying C = M^2 (using the option 'shape'='symmetric' doesn't improve anything).
The naive alternative based on an Eigenvectors decomposition works perfectly well while being 200 times faster.

 > restart:
 > with(LinearAlgebra): with(Statistics):
 > f := proc(p)   Sample(Uniform(0, 1), [100, p]):   CorrelationMatrix(%): end proc:
 > C := f(40):
 > M_MP := CodeTools:-Usage( MatrixPower(C, 1/2) ):
 memory used=382.38MiB, alloc change=12.01MiB, cpu time=6.05s, real time=6.26s, gc time=386.00ms
 > LE := proc(R)   local L, E;   L, E := LinearAlgebra:-Eigenvectors(evalf(R)):   L    := map(Re, L):   E    := map(Re, E):   E . DiagonalMatrix(sqrt~(L)) . E^(-1) end proc:
 > IsDefinite(C, query = 'positive_definite'); M_LE := CodeTools:-Usage( LE(C) ):
 memory used=0.90MiB, alloc change=0 bytes, cpu time=29.00ms, real time=10.00ms, gc time=0ns
 > map(fnormal, M_MP . M_MP - C): %[1..5, 1..5];
 (1)
 > map(fnormal, M_LE . M_LE - C): %[1..5, 1..5];
 (2)
 >

## A problem in selecting elements from set...

Maple 2015

I get a problem while selecting elements from sets.

I have a list of two sets apparently ordered in the same order.
When I pick this, for instance, first set from each of these two samples I get the first one from the first set, and the second one from the second set.

 > restart:
 > DF := [ {diff(Theta(x), x), diff(Theta(x), x, x)}, {diff(g(x), x), diff(g(x), x, x)} ]
 (1)
 > # Why are the elements of DF[2] not returned in their correct order? i := 1; DF[i], DF[i][1], DF[i][2]; print(): i := 2; DF[i], DF[i][1], DF[i][2];
 (2)
 > # I suppose we must not trust what is displayed and that lprint is more # trustworthy? lprint(DF)
 [{diff(Theta(x), x), diff(diff(Theta(x), x), x)}, {diff(diff(g(x), x), x), diff(g(x), x)}]
 > # I expected that converting each element of DF into a list would fix this # problem. but anothr does appear: # "Why does the conversion into list change the order of the elements?" # I had never seen that before LDF := convert~(DF, list)
 (3)
 >

Running this command

map(sort, LDF)

displays LDF, which suggests that LDF is already sorted according to some order.
What is this order which makes diff(Theta(x), x$2) the successor of diff(Theta(x), x) but diff(g(x), x) the successor of diff(g(x), x$2)  ?

## Does mathematicalnotation interfere with...

Maple

When you use

restart:
with(Physics):
Setup(mathematicalnotation=true):
diff(x(t), t)


the output is $\dot{x}(t)$
When you write

restart:
alias(x=x(t)):
diff(x, t)

the output is $\frac{\partial}{\partiall t} x$

Is it possible to "mix" these two in such a way that diff(x, t) appears as $\dot{x}$ ?
Notation.mw