nm

8552 Reputation

19 Badges

12 years, 349 days

MaplePrimes Activity


These are questions asked by nm

long time ago I asked about automatic spacing to improve latex for sqrt. A nice solution was provided in https://www.mapleprimes.com/questions/231062-Adding-Space-After-Sqrt-To-Improve-The-Latex

The above is activatived using spaceaftersqrt = true option for latex:-Settings

There is a similar issue for inert integration where a space is typically added before the final dx This is done similar to the above fix using \, See for example this Latex web site giving many examples.

But there is no option I could see to tell Maple to do this automatically for integration.

So all my inert integrals now look not too good as the dx is too close to the integrand. Here are 2 examples with the settings I am using

restart;

latex:-Settings(useimaginaryunit=i,
      usecolor = false,
      powersoftrigonometricfunctions= mixed, ## computernotation,
      leavespaceafterfunctionname = true,
      cacheresults = false,
      spaceaftersqrt = true,
      usetypesettingcurrentsettings=true,
      linelength=10000      
);

sol:=sqrt(4*y^3-a*y-b)*a;
Intat( subs(y=a,1/sol),a=y(x));
latex(%);

Int(sol,y);
latex(%);

I copied the latex and compiled it, and this is the result

\documentclass[12pt]{book}
\usepackage{amsmath}
\begin{document}

\[
\int_{}^{y \left(x \right)}\frac{1}{\sqrt{4 a^{3}-a^{2}-b}\, a}d a
\]

\[
\int \sqrt{4 y^{3}-a y -b}\, a d y
\]

\end{document}

Which gives

Compare the output when adding \, by hand to the latex

\documentclass[12pt]{book}
\usepackage{amsmath}
\begin{document}

\[
\int_{}^{y \left(x \right)}\frac{1}{\sqrt{4 a^{3}-a^{2}-b}\, a}\, d a
\]

\[
\int \sqrt{4 y^{3}-a y -b}\, a \, d y
\]

\end{document}

Which now gives much better result

Actually, what would be nice if the "d" in "dx" was mathrm which becomes

\documentclass[12pt]{book}
\usepackage{amsmath}
\begin{document}

\[
\int_{}^{y \left(x \right)}\frac{1}{\sqrt{4 a^{3}-a^{2}-b}\, a}\, \mathrm{d} a
\]

\[
\int \sqrt{4 y^{3}-a y -b}\, a \, \mathrm{d} y
\]

\end{document}

But may be I am asking for too much here. But having an option to add \, only for inert integration will be good to have.

Does there exist an option to do this that may be I overlooked?

Maple 2023.2

 

I obtained a Plot p, then trying to find if it has Float(undefined) in it. I am basically trying to find if DEplot returns an empty plot or not. I found that it the plot structure has HFlat(undefined) then this seems to imply an empty plot. So I said, then in the code I can check for HFlat(undefined) in the plot and it is there, then I know the plot is empty.

But this check is not working.

I used has(....,Float(undefined)) and this returns false. But if I copy and paste part of the plot structure and try the check on the copy, it gives true. 

I do not understand what is the difference. First here is screen shot, and below if complete code to reproduce.

restart;
ode2:=2*y(t)+t*diff(y(t),t) = t^2-t+1;

p:=DEtools:-DEplot(ode2,y(t),t=0..3.5,y=0..3,
                        linecolor = red,                        
                        arrowsize ='magnitude',
                        numpoints = 200 ,
                        axes = boxed,color = ('magnitude[legacy]')):


p0:=Array(1 .. 3,1 .. 2,{(1, 1) = HFloat(undefined), (1, 2) = HFloat(undefined), (2
, 1) = HFloat(undefined), (2, 2) = HFloat(undefined), (3, 1) = HFloat(undefined
), (3, 2) = HFloat(undefined)},datatype = float[8],order = C_order);
whattype(p0);
has(p0,HFloat(undefined)) 

p1:=op([1,2],p);
whattype(p1);
has(p1,HFloat(undefined)) 

Worksheet attached also.

Maple 2023.2 on windows 10
 

``

restart;

185876

ode2:=2*y(t)+t*diff(y(t),t) = t^2-t+1;
p:=DEtools:-DEplot(ode2,y(t),t=0..3.5,y=0..3,
                        linecolor = red,                        
                        arrowsize ='magnitude',
                        numpoints = 200 ,
                        axes = boxed,color = ('magnitude[legacy]')):




 

2*y(t)+t*(diff(y(t), t)) = t^2-t+1

p0:=Array(1 .. 3,1 .. 2,{(1, 1) = HFloat(undefined), (1, 2) = HFloat(undefined), (2
, 1) = HFloat(undefined), (2, 2) = HFloat(undefined), (3, 1) = HFloat(undefined
), (3, 2) = HFloat(undefined)},datatype = float[8],order = C_order);
whattype(p0);
has(p0,HFloat(undefined))

Matrix(3, 2, {(1, 1) = HFloat(HFloat(undefined)), (1, 2) = HFloat(HFloat(undefined)), (2, 1) = HFloat(HFloat(undefined)), (2, 2) = HFloat(HFloat(undefined)), (3, 1) = HFloat(HFloat(undefined)), (3, 2) = HFloat(HFloat(undefined))})

hfarray

true

p1:=op([1,2],p);
whattype(p1);
has(p1,HFloat(undefined))

Matrix(3, 2, {(1, 1) = HFloat(HFloat(undefined)), (1, 2) = HFloat(HFloat(undefined)), (2, 1) = HFloat(HFloat(undefined)), (2, 2) = HFloat(HFloat(undefined)), (3, 1) = HFloat(HFloat(undefined)), (3, 2) = HFloat(HFloat(undefined))})

hfarray

false

 


question is: Why the above give different result? And what is the correct way to check if the output plot from DEplot is empty or not (in code)?

Download why_has_works_different.mw

I have expressions with head Sum that are all either one single Sum or sum of these Sum's. So my expression is either

Sum(.....)+Sum(....)+Sum(...)   or Sum()  

Inside each Sum, I have indexed a[n] and also possibly nonindexed For an example

             Sum( a[n]*x + a, n=1..10)

And I want to change all the indexed a[n] to b[n] 

Hence the example above it will becomes  Sum( b[n]*x + a, n=1..10)

I can't just use eval(expr,a=b) as that will also change the non-indexed a to b which I want to leave as is. There will be only one single indexed variable in the sum. In this example it is `a`

Below is a general example and my solution. I'd like to find if there is a more canonical way or shorter more direct way to do this in Maple. 

restart;
expr:=Sum(x^(n+r)*a[n]*(n+r)*(n+r-1)+a[n-1]+3*a*x^10,n = 0 .. infinity)+Sum(4*a*x^(n+r)*a[n],n = 0 .. infinity)+Sum(4*a[n-1]*x^(n+r)+a[n]*x+a*x,n = 1 .. infinity) = 0;

evalindets(expr,specfunc( anything, 'Sum' ),f->Sum(evalindets(op(1,f),'indexed',ff->b[op(ff)]),op(2,f)))

I used evalindets twice. Once to look for Sum, and then to look for 'indexed' within each sum. It seems to work. Here is screen shot of the output

If you asking why I have indexed a and non indexed a in the same expression? Well, it is because the non-indexed happend to be a coefficient of the ode that the user used. So it is part of the input, which I have no control over. But the indexed is a local variable I am using inside the function being called to process the input.

On the screen they look the same. But they are actually not the same. The indexed is local to the function and the non-indexed is input via argument. So it is global symbol. 

 

 

After I switched to using arrows = curve in the call to DEtools:-DEplot I found errors in some calls. 

Is there a workaround other than not using this option? As phase plot looks like better with this option. For now, I will remove this option.

Here is an example

restart;

ode:=diff(y(x),x)-1/(-x^2+1)^(1/2) = 0;
x_range:=-0.99 .. 0.99;
DEtools:-DEplot(ode,y(x),x =x_range,y = -1.6 .. 1.6,[y(0) = 0],arrows = 'curve')

Error, (in DEtools/DEplot/direction) cannot assign a complex value to a hardware float Array

But this works

restart;

ode:=diff(y(x),x)-1/(-x^2+1)^(1/2) = 0;
x_range:=-0.99 .. 0.99;
DEtools:-DEplot(ode,y(x),x =x_range,y = -1.6 .. 1.6,[y(0) = 0])

I will report this to Maplesoft as it looks like a bug to me. 

May be someone can find a workaround so I can use arrows = curve?

Maple 2023.2 on windows 10

``

restart;

292176

ode:=diff(y(x),x)-1/(-x^2+1)^(1/2) = 0;
x_range:=-0.99 .. 0.99;
DEtools:-DEplot(ode,y(x),x =x_range,y = -1.6 .. 1.6,[y(0) = 0],arrows = 'curve')

diff(y(x), x)-1/(-x^2+1)^(1/2) = 0

-.99 .. .99

Error, (in DEtools/DEplot/direction) cannot assign a complex value to a hardware float Array

restart;

292176

ode:=diff(y(x),x)-1/(-x^2+1)^(1/2) = 0;
x_range:=-0.99 .. 0.99;
DEtools:-DEplot(ode,y(x),x =x_range,y = -1.6 .. 1.6,[y(0) = 0])

diff(y(x), x)-1/(-x^2+1)^(1/2) = 0

-.99 .. .99

 

Download detools_deplot_arrows_curve_problem_NOV_10_2023.mw

Given a system of 2 first order ode's which are autonomous (i.e. the RHS does not explicitly depend on time), one can make phase plot in Maple using DEtools:-DEplot

I am trying to get my Maple output to look like I get with Mathematica. I am getting close, but there are two issues. First, here is what I get in Maple

restart;

ode1:=diff(x(t),t)=2*x(t)*y(t);
ode2:=diff(y(t),t)=1-x(t)^2-y(t)^2;

DEtools:-DEplot([ode1,ode2],[x(t),y(t)],
                           t=0..1,x = -4..4, y = -4..4,arrows=curve,linecolor=red,
                           numpoints =300,arrowsize='magnitude',scene=[x(t),y(t)]);

Here is the same thing in Mathematica

ode1=x'[t]==2*x[t]*y[t]
ode1=y'[t]==1-x[t]^2-y[t]^2

StreamPlot[{2 x*y,1-x^2-y^2},{x,-4,4},{y,-4,4},
    FrameLabel->{{y[t],None},{x[t],None}},BaseStyle->16,ImagePadding->{{50,10},{50,0}}]

Is it possible to get the arrows to be stream lines similar to how they show up? Also, the axes labels in Maple are internal and hard to see. Is it possible to have on the outside like above so they are easier to see?

On a side question: Should one use DEtools:-DEplot or DEtools:-phaseportrait I could never understand when to use one vs. the other.

Maple 2023.2 on windows

First 8 9 10 11 12 13 14 Last Page 10 of 164