## calling proc gives a different answer the second t...

Asked by:

Would Any one be able to give some explanation as to why calling a proc, which does not change anything globally but only acts on the input given, returns different answer the second time it is called with the same exact input? I am not able to understand this result at all.

Maple 2023.2 on windows 10.

 > restart;

 > W:=Matrix(3, 3, [[x^(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)*cos(1/2*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))*ln(x)),-x^(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)*sin(1/2*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))*ln(x)),x^(-1/6*(44+12*69^(1/2))^(1/3)+10/3/(44+12*69^(1/2))^(1/3)+2/3)],[x^(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)*(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)/x*cos(1/2*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))*ln(x))-1/2*x^(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))/x*sin(1/2*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))*ln(x)),-x^(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)*(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)/x*sin(1/2*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))*ln(x))-1/2*x^(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))/x*cos(1/2*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))*ln(x)),x^(-1/6*(44+12*69^(1/2))^(1/3)+10/3/(44+12*69^(1/2))^(1/3)+2/3)*(-1/6*(44+12*69^(1/2))^(1/3)+10/3/(44+12*69^(1/2))^(1/3)+2/3)/x],[x^(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)*(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)^2/x^2*cos(1/2*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))*ln(x))-x^(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)*(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)/x^2*cos(1/2*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))*ln(x))-x^(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)*(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)/x^2*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))*sin(1/2*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))*ln(x))+1/2*x^(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))/x^2*sin(1/2*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))*ln(x))-3/4*x^(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))^2/x^2*cos(1/2*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))*ln(x)),-x^(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)*(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)^2/x^2*sin(1/2*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))*ln(x))+x^(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)*(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)/x^2*sin(1/2*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))*ln(x))-x^(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)*(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)/x^2*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))*cos(1/2*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))*ln(x))+1/2*x^(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))/x^2*cos(1/2*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))*ln(x))+3/4*x^(1/12*(44+12*69^(1/2))^(1/3)-5/3/(44+12*69^(1/2))^(1/3)+2/3)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))^2/x^2*sin(1/2*3^(1/2)*(-1/6*(44+12*69^(1/2))^(1/3)-10/3/(44+12*69^(1/2))^(1/3))*ln(x)),x^(-1/6*(44+12*69^(1/2))^(1/3)+10/3/(44+12*69^(1/2))^(1/3)+2/3)*(-1/6*(44+12*69^(1/2))^(1/3)+10/3/(44+12*69^(1/2))^(1/3)+2/3)^2/x^2-x^(-1/6*(44+12*69^(1/2))^(1/3)+10/3/(44+12*69^(1/2))^(1/3)+2/3)*(-1/6*(44+12*69^(1/2))^(1/3)+10/3/(44+12*69^(1/2))^(1/3)+2/3)/x^2]]):
 > foo:=proc(W::Matrix,x::symbol)    local W1:=W,W_det,W1_det;    local F:=2*x^3-ln(x):    W_det := LinearAlgebra:-Determinant(W);    #change the first column    W1[1..3,1] := Vector['column']([0,0,F/x^3]):    W1_det := simplify(LinearAlgebra:-Determinant(W1)):    simplify(W1_det/W_det); end proc:
 > foo(W,x);

 > foo(W,x)

 >

Download why_different_answer.mw

## How to change the placement of arrows in a 2-D/3-D...

Asked by:

In an old question, @nm asked how to . While the answer in that question was almost up to the mark, there remains a regret.

As the instance listed below shows, Maple, by default, draws arrows on a rectangular grid (rather than on a hexagonal mesh):

# Example of a three-dimensional vector field:
vf__2d := VectorCalculus:-VectorField([sin(x)*(cos(x) + cos(y)),
sin(y)*(cos(x) - cos(y))], 'cartesian'[x, y]):
# Example of a two-dimensional vector field:
vf__3d := VectorCalculus:-VectorField([1 - (sin(u - v) + sin(u - w)),
1 - (sin(v - w) + sin(v - u)),
1 - (sin(w - u) + sin(w - v))], 'cartesian'[u, v, w]):
# Phase portrait.
Student:-VectorCalculus:-PlotVector(vf__2d, (x, y) =~ -Pi .. Pi,
'grid' = [\$](25, 2),
'arrows' = 'THICK',
'fieldstrength' = log[63],
'color' = ColorTools:-Color("#0072BD"),
'axes' = "box"(*, …omitted…*));
=

Note that I have changed some of the options in order to make the layout of arrows more prominent.
However, according to the help page of Mma's VectorPoints, among the following methods of location generation, Mma by default uses Hexagonal for 2D field vectors and FaceCenteredCubic for 3D field vector:

Here is a collection of different settings available in Mma:

So if the requirement is to get the Maple's output looking like Mathematica's (see the beginning), the number and placement of vectors to plot should be thought of as well. In Maple, “the number of vectors” can be controlled by the plot (or plot3d) opinion , but how do I specify “the placement of vectors” (e.g., Mma's "Hexagonal" and "Mesh")?

Although there exists an  chapter in the documentation, randomly positioned arrows do not fit the bill. Is there any workaround?

## why such large difference in dsolve answer using t...

Asked by:

This is linear ode, third order, Euler type and inhomogeneous ode.

If I solve the homogeneous ode only, then ask Maple to give me a particular solution, then add these, I get much much smaller solution which Maple verifies is correct.

Now when asking Maple to solve the original inhomogeneous ode as is, the solution is much more complicated and much longer with unresolved integrals.

Why does not Maple give the simpler solution? Both are verified to be correct.

This is my theory: When asking maple to find only the particular solution, it seems to have used a different and advanced method to find yp. Which is new to me and trying to learn it. It is based on paper "D'Alembertian Solutions of Inhomogeneous Equations (differential, difference, and some other).

Undetermined coefficients method can't really be used on ode's such as this because its coefficients are not constant.

Now, when asking Maple to solve the inhomogeneous ode, it seems to have used variation of parameters method, which results in integrals, which can be hard to solve.

My question is: Why does not Maple give the same much shorter answer when asked to solve the ode as is? Should it not have done so? Any thoughts on why such large difference in answer? Why it did not use the same method to find yp when asked to solve the whole ode as that leads to much smaller and more elegant solution.

ps. debugging this, it uses LinearOperators:-dAsolver:-dAlembertianSolver which is called from ODEtools/particularsol/linear to find yp when calling DETools:-particularsol(ode); but for some reason, it does not do this when asking it to solve the whole ode directly (if it did, then one will expect same answer to result, right?)

Maple 2023.2 on windows 10.

 > restart;
 (1)
 > #the ode ode:=x^3*diff(y(x), x, x, x) + x^2*diff(y(x), x, x) + 2*x*diff(y(x), x) - y(x) = 2*x^3 - ln(x);
 (2)
 > # find y_h yh:=dsolve(lhs(ode)=0);
 (3)
 > #find particular solution yp:=DETools:-particularsol(ode);
 (4)
 > #test particular solution is correct odetest(yp,ode);
 (5)
 > #find general solution = yh+ yp y_general:=y(x)=rhs(yh)+rhs(yp);
 (6)
 > #test general solution is correct odetest(y_general,ode);
 (7)
 > #now solve the ode directly using Maple. Why this solution is much more complicated? y_general_direct_method:=dsolve(ode);
 (8)
 > #test the above odetest(y_general_direct_method,ode);
 (9)
 >

Download why_such_difference_in_dsolve_answer.mw

## Laplacian(1/r) in spherical coordinates...

Asked by:

Hi,

I would like to calculate Laplacian(1/r) in spherical coordinates

Considering that 1/r in spherical coordinates defines a distribution function (understood in Laurent Schwartz meaning) , the result has to be -4πDirac(r)

I tried to establish this result on Maple but that doesn't work. The result given is -Dirac(r)/r²  (see below)

What is the mistake I made?

Thanks

with(Physics[Vectors]);

SetCoordinates(spherical[r, phi, theta]);

F := Laplacian(1/r);
Dirac(r)
F := - --------
r²

## Simplifying expression with powers...

Asked by:

Perhaps a stupid question but I fail to convert 21/4a1/4/pi1/4 (a result of a calculation performed by maple) into (2a/pi)1/4.

I tried simplify, combine, collect, ... with options. None of them work.

Thank you.

## Why can't use be used as or within an expression...

Asked by:

This question is an expansion of my previous reply.

There exist sixty kinds of statements in Maple, whose major ​​​​portion can be used as an expression or within an expression (e.g., assignment, loop, and condition). But why is use an exception?

Moreover, since it is reasonable to think of use as a (partial) generalization (see below) of the subs function, shouldn't the behaviour of use be consistent with do/if?

Compare: "seq((…;…;…), x in x__0):" (not allowed) vs. "for x in x__0 do …;…;… od:" (allowed); "subs(x = x__0, (…;…;…)):" (not allowed) vs. "use x = x__0 in …;…;… od:" (Not allowed! Why?).)

Edit. Besides that, is there some workaround to do something like

# If use can be used as an expression or within an expression,
use x = 2 + y in 'use y = 4 in x + y end' end;
# should return “use y~ = 4 in (2 + y) + y~ end use;” and
(use y = 2 + x in x -> x + y end);
# should output “x~ -> x~ + (2 + x);”.
# Unfortunately, I cannot find a workaround to stimulate them.

at present? Note that the subs function is unable to do so, so in my opinion, only when the use of use is no longer limited to statements will it become a sweeping generalization of subs.

## Simplifying expression with sqrt of complex expres...

Asked by:

can be simplified :l *h*t/m

How can I ask Maple to do this.

## trick to show this expression is zero?...

Asked by:

Given

expr:=  (x^(-(44 + 12*sqrt(69))^(1/3)/6 + 10/(3*(44 + 12*sqrt(69))^(1/3)) + 2/3)) - (x^(sqrt(69)*2^(1/3)*((11 + 3*sqrt(69))^2)^(1/3)/100 - (11*(44 + 12*sqrt(69))^(2/3))/600 - (44 + 12*sqrt(69))^(1/3)/6 + 2/3))

could someone come with a trick to show this is zero using simplification and other methods? I know I can use is and coulditbe but I do not trust these too much due to false positives I've seen from them in some places.

Here is my attempts

restart;

expr:=  (x^(-(44 + 12*sqrt(69))^(1/3)/6 + 10/(3*(44 + 12*sqrt(69))^(1/3)) + 2/3)) - (x^(sqrt(69)*2^(1/3)*((11 + 3*sqrt(69))^2)^(1/3)/100 - (11*(44 + 12*sqrt(69))^(2/3))/600 - (44 + 12*sqrt(69))^(1/3)/6 + 2/3));
simplify(expr);
simplify(expr,size);
simplify(expr,symbolic);
simplify(normal(expr));
simplify(normal(expr),symbolic);
simplify(expr) assuming real;
simplify(expr) assuming positive;
is(expr=0);
coulditbe(expr=0);
evalb(expr=0);

Gives

This is for reference, the Mathematica attempt

## Latex problem with spacing before dx. Is there an ...

Asked by:

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

## Why does fsolve only provide one solution?...

Asked by:

I have the function: 2*sin(x)+1/2x-1

I want the x-intercepts, but Maple only provides one answer with fsolve.

## equality of vectors (too subtle for me)...

Asked by:

S := [1, 2];
S := [1, 2]

T := [1, 2];
T := [1, 2]

is(S = T);
true

Sv := Vector([1, 2]);

Tv := Vector([1, 2]);

is(Sv = Tv);
false

is(convert(Sv, list) = convert(Tv, list));
true

## why has works different on seemingly same input?...

Asked by:

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;

 > 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))

 >

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

## Numeric-Formatting: Why is the exponent not format...

Asked by:

With the context-panel

 (1)

 (2)

How to format all occurences of numbers?

Download Number_Format.mw

## Better way to change all indexed variables in an e...

Asked by:

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.

## plot a volumetric body ...

Asked by:

How I can plot a volumetric body with the coordinates provided in the text file attachment?

after finding the geometry curve I want to find the curve that passes through the middle source.

1.txt

 First 8 9 10 11 12 13 14 Last Page 10 of 27
﻿