Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

The inverse problem of a mathematical question is often very interesting.

I'm glad to see that Maple 2023 has added several new graph operations. The GraphTheory[ConormalProduct], GraphTheory[LexicographicProduct], GraphTheory[ModularProduct] and GraphTheory[StrongProduct] commands were introduced in Maple 2023.

In fact, we often encounter their inverse problems in graph theory as well. Fortunately, most of them can find corresponding algorithms, but the implementation of these algorithms is almost nonexistent.

 

I once asked a question involving the inverse operation of the lexicographic product.

Today, I will introduce the inverse operation of line graph operations. (In fact, I am trying to approach these problems with a unified perspective.)

 

To obtain the line graph of a graph is easy, but what about the reverse? That is to say, to test whether the graph is a line graph. Moreover, if a graph  g is the line graph of some other graph h, can we find h? (Maybe not unique. **Whitney isomorphism theorem tells us that if the line graphs of two connected graphs are isomorphic, then the underlying graphs are isomorphic, except in the case of the triangle graph K_3 and the claw K_{1,3}, which have isomorphic line graphs but are not themselves isomorphic.)

Wikipedia tells us that there are two approaches, one of which is to check if the graph contains any of the nine forbidden induced subgraphs. 

Beineke's forbidden-subgraph characterization:  A graph is a line graph if and only if it does not contain one of these nine graphs as an induced subgraph.

This approach can always be implemented, but it may not be very fast. Another approach is to use the linear time algorithms mentioned in the following article. 

  • Roussopoulos, N. D. (1973), "A max {m,n} algorithm for determining the graph H from its line graph G", Information Processing Letters, 2 (4): 108–112, doi:10.1016/0020-0190(73)90029-X, MR 0424435

Or: 

  •   Lehot, Philippe G. H. (1974), "An optimal algorithm to detect a line graph and output its root graph", Journal of the ACM, 21 (4): 569–575, doi:10.1145/321850.321853, MR 0347690, S2CID 15036484.


SageMath can do that: 

   root_graph()

Return the root graph corresponding to the given graph.

    is_line_graph()

Check whether a graph is a line graph.

For example, K_{2,2,2,2} is not the line graph of any graph.

K2222 = graphs.CompleteMultipartiteGraph([2, 2, 2, 2])
C=K2222.is_line_graph(certificate=True)[1]
C.show() # Containing the ninth forbidden induced subgraph.

 

enter image description here

 

Another Sage example for showing that the complement of the Petersen graph is the line graph of K_5.

P = graphs.PetersenGraph()
C = P.complement()
sage.graphs.line_graph.root_graph(C, verbose=False)

 

(Graph on 5 vertices, {0: (0, 1), 1: (2, 3), 2: (0, 4), 3: (1, 3), 4: (2, 4), 5: (3, 4), 6: (1, 4), 7: (1, 2), 8: (0, 2), 9: (0, 3)})

 

Following this line of thought, can Maple gradually implement the inverse operations of some standard graph operations? 

Here are some examples:

  •   CartesianProduct
  •   TensorProduct
  •   ConormalProduct
  •   LexicographicProduct
  •   ModularProduct
  •   StrongProduct
  •   LineGraph
  •  GraphPower

For a list containing at least one element, 

F~(list0); # element-wise

is (almost) equivalent to 

map(F, list0);

However, it seems that in practice, using `~` can be faster than its equivalent map version.
Here is a typical test: 

 

 

restart;

w := [`$`](0 .. 1e4):
x := [`$`](0 .. 2e3):
y := [`$`](0 .. 3e2):
z := [`$`](0 .. 4e1):

undefine(f)

NULL

 

 

# Compute a generalized outer product of [w, x] and [y, z] without using the inefficient `ArrayTools:-GeneralOuterProduct`.

""(* Note that we cannot use the ""unapply"" command here. (Use ""->"" instead.) *)""

p2 := CodeTools[Usage](`~`[proc (s4) options operator, arrow; `~`[proc (s3) options operator, arrow; `~`[proc (s2) options operator, arrow; `~`[proc (s1) options operator, arrow; f(s3, s1) end proc](s2) end proc]([y, z]) end proc](s4) end proc]([w, x]), iterations = 10)

memory used=282.53MiB, alloc change=0.59GiB, cpu time=21.67s, real time=7.41s, gc time=17.33s

p4 := CodeTools[Usage](map(proc (s4) options operator, arrow; map(proc (s3) options operator, arrow; map(proc (s2) options operator, arrow; map(proc (s1) options operator, arrow; f(s3, s1) end proc, s2) end proc, [y, z]) end proc, s4) end proc, [w, x]), iterations = 10)

memory used=230.48MiB, alloc change=-4.00MiB, cpu time=23.26s, real time=8.67s, gc time=17.71s

evalb(p2 = p4);

true

NULL


 

Download `~`_and_map.mw

But I cannot find any explanations in Comparison of element-wise operators and map function or Difference between 'map' and '~' (element-wise operation). Does anyone know why?

I used ‘solve’ command in Maple to solve the following system of two variables with two nonlinear equations:

where

The denominators are nonzero and positive, and all parameters , , , ,  and  are positive real numbers. The solution was easily obtained, that is

Is there any way that I can follow the steps? The issue is that I need to verify whether there is not an alternate solution.

The standard way of writing quotes and double quotes in LaTeX is with `` and ''

So a string should be translated to Latex using ``the_string' '  and not ``the_string"  which is what Maple does.

see for example this  

 

For example, Maple translates  "regular" to

                "\text{``regular\"}"

It should be

                "\text{``regular' '}"

i.e. instead of closing it on the RIGHT with string quote  \"  it should close it with two upticks, like this ' '

Hard to see the differene here, so here is screen shot

s:="regular";
latex(s,output=string);
lprint(%)

The difference will show up depending on what font one is using. Here is an example below where when using different font, the effect is now visible. 

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

\usepackage[T1]{fontenc}
\usepackage{mlmodern}

\begin{document}

\text{``regular"}

\text{``regular''}

\end{document}

The first one above is what Maple generates, the second one is what it should have been. Compiling with luatex gives this pdf, You can see clearly the difference now

It is important to note that this behavior shows depending on font used. For example, this code

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

\text{``regular"}

\text{``regular''}

\end{document}

When compiled gives

So to be safe, it is better to always use the standard  `` ....' '   and not `` .... \" because it then works the same for different fonts being used.

So, would it be possible to make Maple generate quoted string using the standard latex by closing it with ' ' instead of \"  ?  

 

 

the command singular can return results with _Z or _N as it says in help

The singular function may return expressions prefixed by _Z or _N, representing the integers and positive integers, respectively.
 

But it changes these letters by adding different number at the end for each call., Yet they all mean the same thing, which is an integer:

singular(1/sin(x),x)
                         {x = Pi*_Z1}

singular(x/sin(x),x)
                         {x = Pi*_Z2}

singular(x^2/sin(x),x)
                        {x = Pi*_Z3}

 

This makes it little hard when I try to make union of these results to only keep the unique singular points, since they are different symbols, yet they are really the same: integer times Pi.

Is there an option to tell Maple to use _Z for everything? And not keep adding new numbers each time it is called?

May be clear some internal memory table after each call?  Otherwise, I have to add more code to parse all these results and convert all _Znnn to just _Z  if it is there in each result, after each call is made.

Same issue for _N

Update

Additional example to try/test against

expr:=1/(sin(x)*cos(x)*tan(x));
s := singular(expr, x);

expr:=1/((x-1)*sin(x));
s := singular(expr, x);

expr:=1/(sin(x)*cos(x-Pi/3)*tan(x));
s := singular(expr, x);

In all the outputs above, I'd like to have same _Z show up. This will make it easier for postprocessing later on. Best solution will be to tell Maple itself not to change _Z if possible, otherwise one will need to add code to do this afterwords for all possible cases.

Is there a way to map a neutral operator "&^" over a list L := [a,b,c,d], so that the output is a &^ b &^ c &^ d. 

I can do this with a loop, but I'm wondering if there is already a built-in function for this. 

Consider the task of finding the eigenvalues and eigenvectors of a simple 2x2 matrix.

Usually I can insert the contents of a Maple worksheet here, but for some reason the following worksheet cannot be inserted: Eigenvectors.mw

In that worksheet I try to use LinearAlgebra:-Eigenvectors(A). The eigenvalues contain a complex term, even though they are real for the given matrix. It's not clear what criteria are used in selecting a specific eigenvector for each eigenvalue.

I then show a more manual calculation.

I was expecting to obtain a simpler solution to this problem using LinearAlgebra:-Eigenvectors(A). Is this expectation unjustified? I am asking primarily from the perspective of a user of the software. 

It would be interesting to know the answer from the perspective of someone who knows the ins and outs of the implementation of the software as well, but as a user my initial expectation is a more digestible result that doesn't rely on knowing such implementation details.

hi,

What command can I use to solve the attached equation and draw its graph?

ode := -(q2-q4)*(q2-q3)*(q1-q4)*(q1-q3)*y(w)^2+(q1+q2-q3-q4)*(2*q1*q2-q1*q3-q1*q4-q2*q3-q2*q4+2*q3*q4)*(diff(y(w), w))*y(w)+(-2*q1^2-2*q1*q2+3*q1*q3+3*q1*q4-2*q2^2+3*q2*q3+3*q2*q4-6*q3*q4)*(diff(y(w), w))^2+(q1-q2+q3-q4)*(q1-q2-q3+q4)*(diff(y(w), w, w))*y(w)+(3*q1+3*q2-3*q3-3*q4)*(diff(y(w), w, w))*(diff(y(w), w))-3*(diff(y(w), w, w))^2+(-q1-q2+q3+q4)*(diff(y(w), w, w, w))*y(w)+2*(diff(y(w), w, w, w))*(diff(y(w), w)) = 0

-(q2-q4)*(q2-q3)*(q1-q4)*(q1-q3)*y(w)^2+(q1+q2-q3-q4)*(2*q1*q2-q1*q3-q1*q4-q2*q3-q2*q4+2*q3*q4)*(diff(y(w), w))*y(w)+(-2*q1^2-2*q1*q2+3*q1*q3+3*q1*q4-2*q2^2+3*q2*q3+3*q2*q4-6*q3*q4)*(diff(y(w), w))^2+(q1-q2+q3-q4)*(q1-q2-q3+q4)*(diff(diff(y(w), w), w))*y(w)+(3*q1+3*q2-3*q3-3*q4)*(diff(diff(y(w), w), w))*(diff(y(w), w))-3*(diff(diff(y(w), w), w))^2+(-q1-q2+q3+q4)*(diff(diff(diff(y(w), w), w), w))*y(w)+2*(diff(diff(diff(y(w), w), w), w))*(diff(y(w), w)) = 0

(1)

ans := dsolve(ode, y(w))

``

Download Ode_equation.mw

 

ODE for electrical circuit (right click on Documentblock, unselect show command does not work. Command still visble)u(t) = T*(diff(`ϕ`(t), t))+L*(diff(i(t), t))+i(t)*R

u(t) = T*(diff(varphi(t), t))+L*(diff(i(t), t))+i(t)*R

(1)

 

ODE for motor (toggle Documentblock, unselect show command is only effective on equations  3 and 4)i(t)*T = J*(diff(`ϕ`(t), t, t))

i(t)*T = J*(diff(diff(varphi(t), t), t))

(2)

Isolate i(t) and taking the derivative

i(t) = J*(diff(diff(varphi(t), t), t))/T

(3)

``

diff(i(t), t) = J*(diff(diff(diff(varphi(t), t), t), t))/T

(4)

``

Download Document_Block_hide_command.mw

dear all

am trying to do a task that Find all the roots of the equation (or three roots if there are more than three roots in the equation) by Newton's method f(x) = e^x^2 sin(x-5) accuracy = 10^-5 maple

and i wrote this code on maple 

f := x -> exp(x^2)*sin(x - 5);
df := x -> evalf(diff(f(x), x));
x0 := -1.0;
tol := 0.00001;
for i to 3 do
    x := x0;
    n := 0;
    while tol < abs(f(x)) do
        x := x - f(x)/df(x);
        n := n + 1;
    end do;
    printf("Root %d: %.5f (found in %d iterations)\n", i, x, n);
    x0 := x + 1.0;
end do;
f := proc (x) options operator, arrow; exp(x^2)*sin(x-5) end proc

 df := proc (x) options operator, arrow; evalf(diff(f(x), x)) 

    end proc


                           x0 := -1.0

                         tol := 0.00001

                           x := -1.0

                             n := 0

 

am getting an error message

" Error, (in df) invalid input: diff received -1.0, which is not valid for its 2nd argument "

hope you can help me with this issue

in Maple 2023 one can do File->Open and select an .mpl file and that will automatically open in new window using code editor.  see Maple2023-CodingTools.pdf

One problem I saw right away on windows 10, is that the diagonstic window has funny character at the end of the messages. Here is screen shot

 

To see if you reproduce this, here is the code I used. Simply save this in foo.mpl file and then use Maple file->open to open it (must use 2023 only for this to work)

A_class :=module()
    option object;

    #my variable
    export c::integer;

    export a::integer;

end module;

 

That is not all. If I simply shift the code up so the starting line in the file is not empty as above, the funny characters change to something else

 

 

Yet, it is the same exact code.  Can any one confirm this problem, and how to fix it so one can read the variable name?

 

I think I will stick to using notepad++ for my .mpl files for now.

 

I have some c# function that i want to use in maple, and I doing all according to this arcticle : https://www.mapleprimes.com/posts/38019-Calling-Out-To-C-From-Maple
but i still get this: 
Any ideas what i should do?

Hi MaplePrimes,

I've updated to the 2023 version of Maple. After the update I chose to remove older version folders in Windows.

Since then I cant't use my tasks any longer. I've re created the tasks and the are also shown in the Task Palette, but clicking on a task results in nothing. I can though create a new Task and after the creation all my tasks can then be used again.

Its like Maple doesn't recognize the correct Help Database from the beginning. I've reinstalled Maple 2023 two or three times to try to reset the whole installation to something from scratch. Nothing that I do seems to produce the desired result. Does anybody out there have a solution or suggestion to a probable solution?

I don't know of any file that I could attach to exemplify my problem. It's not a math/maple problem relating directly to the maple code language. My tasks themselves work fine once inserted in a document. It's the insertion itself that's the problem.

Thanks.

Consider the worksheet below containing a function that I came across while studying Apostol's Calculus. 

At the origin, this function has a defined directional derivative in all directions. It is not, however, continuous at the origin. We can see this by consider all points on the parabola x=y^2 except for the origin. The function takes on the value 1/2 on all such points but has value 0 at the origin and is thus discontinuous there.

My question is about a 3d plot of this function.

The plot seems a bit inaccurate because the ridge at the top extends all the way to the origin. 

If I hadn't done the calculations to know this, this plot would not give me this information. 

Is there a way to avoid this problem? Ie, to get more accuracy at points such as the origin here?

f := (x,y) -> piecewise(x=0, 0, x <> 0, x*y^2/(x^2+y^4))

f := proc (x, y) options operator, arrow; piecewise(x = 0, 0, x <> 0, x*y^2/(x^2+y^4)) end proc

(1)

plot3d(f,-1..1,-1..1)

 

f(y^2,y)

piecewise(y^2 = 0, 0, y^2 <> 0, 1/2)

(2)

 

Download DiscontScalarField3d.mw

Not getting Mantissa or Exponentb See Bottom

    |\^/|     Maple 2022 (X86 64 LINUX)
._|\|   |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2022
 \  MAPLE  /  All rights reserved. Maple is a trademark of
 <____ ____>  Waterloo Maple Inc.
      |       Type ? for help.
# eqno = 10
> it := solve({
> 83.0 =  (57.9467777777778) * C_prev  + (-1.001) * C_ksteps  + (-67.1782222222222) * C_fat  + (-91.8695555555555) * C_carb  + (-24.4021555555556) * C_prot  + (-11.5003777777778) * C_fiber  + (-3.21432222222223) * C_sugar  + (-14.1697111111111) * C_saturated  + (-1.61272222222222) * C_fasted  + (1.01),
> 153.0 =  (-11.1222222222222) * C_prev  + (-1.001) * C_ksteps  + (99.9887777777778) * C_fat  + (22.2444444444444) * C_carb  + (48.3705444444444) * C_prot  + (17.2283222222222) * C_fiber  + (-5.21632222222223) * C_sugar  + (9.15358888888888) * C_saturated  + (0.389277777777778) * C_fasted  + (1.01),
> 84.0 =  (-17.1282222222222) * C_prev  + (-1.001) * C_ksteps  + (49.9387777777778) * C_fat  + (17.2394444444444) * C_carb  + (7.72994444444445) * C_prot  + (5.01612222222222) * C_fiber  + (29.8186777777778) * C_sugar  + (10.6550888888889) * C_saturated  + (1.39027777777778) * C_fasted  + (1.01),
> 78.0 =  (-8.11922222222223) * C_prev  + (0.) * C_ksteps  + (-23.1342222222222) * C_fat  + (16.2384444444445) * C_carb  + (-26.1038555555556) * C_prot  + (-12.7015777777778) * C_fiber  + (31.8206777777778) * C_sugar  + (6.05048888888888) * C_saturated  + (-1.61272222222222) * C_fasted  + (1.01),
> 87.0 =  (-8.11922222222223) * C_prev  + (3.003) * C_ksteps  + (-19.1302222222222) * C_fat  + (28.2504444444444) * C_carb  + (-16.4942555555556) * C_prot  + (-5.09397777777778) * C_fiber  + (6.79567777777777) * C_sugar  + (14.7591888888889) * C_saturated  + (-0.111222222222222) * C_fasted  + (1.01),
> 87.0 =  (37.9267777777778) * C_prev  + (-4.004) * C_ksteps  + (-48.1592222222222) * C_fat  + (-83.8615555555555) * C_carb  + (-6.08385555555555) * C_prot  + (0.611722222222222) * C_fiber  + (-58.0691222222222) * C_sugar  + (-20.0756111111111) * C_saturated  + (-1.61272222222222) * C_fasted  + (1.01),
> 133.0 =  (-17.1282222222222) * C_prev  + (3.003) * C_ksteps  + (-56.1672222222222) * C_fat  + (15.2374444444444) * C_carb  + (13.4356444444444) * C_prot  + (3.01412222222222) * C_fiber  + (13.8026777777778) * C_sugar  + (-12.2678111111111) * C_saturated  + (-0.111222222222222) * C_fasted  + (1.01),
> 78.0 =  (-11.1222222222222) * C_prev  + (1.001) * C_ksteps  + (52.9417777777778) * C_fat  + (-2.78055555555555) * C_carb  + (5.82804444444444) * C_prot  + (-0.589477777777777) * C_fiber  + (-39.5506222222222) * C_sugar  + (-0.0556111111111198) * C_saturated  + (4.39327777777778) * C_fasted  + (1.01),
> 84.0 =  (-23.1342222222222) * C_prev  + (0.) * C_ksteps  + (10.8997777777778) * C_fat  + (79.3014444444444) * C_carb  + (-2.28005555555555) * C_prot  + (4.01512222222222) * C_fiber  + (23.8126777777778) * C_sugar  + (5.95038888888888) * C_saturated  + (-1.11222222222222) * C_fasted  + (1.01) },
> [C_prev, C_ksteps, C_fat, C_carb,
>  C_prot, C_fiber, C_sugar, C_saturated,
>  C_fasted]);
                                   16                              18
it := [[C_prev = -0.7676394482 x 10  , C_ksteps = 0.1095758760 x 10  ,

                             16                             16
    C_fat = 0.7856937061 x 10  , C_carb = -0.5792833066 x 10  ,

                               17                             17
    C_prot = -0.1954662069 x 10  , C_fiber = 0.3025217874 x 10  ,

                               15                                  17
    C_sugar = 0.7496058869 x 10  , C_saturated = -0.1779505040 x 10  ,

                                 18
    C_fasted = -0.1062355291 x 10  ]]

> C_prev_V := it[1][1];
                                                          16
                   C_prev_V := C_prev = -0.7676394482 x 10

> C_prev_M := SFloatMantissa(C_prev_V);
                                                          16
                   C_prev_M := C_prev = -0.7676394482 x 10

> C_prev_E := SFloatExponent(C_prev_V);
                                                          16
                   C_prev_E := C_prev = -0.7676394482 x 10

> quit;
memory used=2.3MB, alloc=8.3MB, time=0.03

First 101 102 103 104 105 106 107 Last Page 103 of 2097