mmcdara

7891 Reputation

22 Badges

9 years, 63 days

MaplePrimes Activity


These are replies submitted by mmcdara

@dnaviaux 

V := <1,2,3,4>:
names := <"resistor","opamp","name3","name4">:
names =~ V;
# or
seq(printf("%-10s: %2a\n", names[i] , V[i]), i=1..numelems(V))

 

@Kitonum  @dnaviaux

Funny, we didn't understand the same thing at all.I
I didn't think of "display" in terms of "graphic display".

restart:
interface(version)
# one solution

N := 10:
V := Vector(combinat:-randperm([$1..10])):
Vector(N, [seq(V__||i = V[i], i=1..N)]);


# another one

seq(printf("%-5a = %2a\n", V__||i , V[i]), i=1..N)


# This one takes inspiration from Kitonum's reply

V := Vector([2, 1]):  
if V::Vector then V := convert(V, list) end if:

if numelems(V) = 2 then
  plots:-arrow(
     V,
     scaling=constrained, 
     caption=cat("first:", sprintf("%a", V[1]), "\nsecond:", sprintf("%a", V[2])),
     captionfont=[times,16]
  ):
elif numelems(V) = 3 then
  plots:-arrow(
     V,
     scaling=constrained, 
     caption=cat("first:", sprintf("%a", V[1]), "\nsecond:", sprintf("%a", V[2]), "\nthird:", sprintf("%a", V[3])),
     captionfont=[times,16]
  ):
else
  error "can't plot in spaces of dimension larger than 3, please call Dr Who to fix this"
end if;




Maple Worksheet - Error
Failed to load the worksheet /maplenet/convert/display.mw .

 

display.mw

 

@Carl Love 

In 

DEGREES(HW): ^2 ^1 ^0 ^1 ^0 

the first exponent (^2) is the total degree of the (first) monomial.
Next 

^1 ^0 ^1 ^0 

is just the power of each variables (according to the order in which thay are declared as NAME) in the first monomial.
Thus 

DEGREES(HW): ^2 ^1 ^0 ^1 ^0 

means "the first monomial equals a^1*b^0*x^1*y^0 = a*x"

It seems that this first exponent is redundant 
See for instance
 

dismantle(a^1*x^2*b^3*y^4+a^4*x^3*b^2*y^1);

POLY(6)
   EXPSEQ(5)
      NAME(4): a
      NAME(4): b
      NAME(4): x
      NAME(4): y
   DEGREES(HW): ^10 ^4 ^2 ^3 ^1 
   INTPOS(2): 1
   DEGREES(HW): ^10 ^1 ^3 ^2 ^4 
   INTPOS(2): 1

 

@nm 
 

Do not tell on user.wolfram.com that Mathematica has a feature Maple hasn't, or this will appear on :-)
compare-mathematica-and-maple.html   :-)

More seriously, your reply is very interesting for it could give the Maplesoft Development Team the idea of doing the same thing in Maple.

Thank you nm.

@acer 

"Certainly there is more work to be done in order to manipulate structures returned by ToInert": I agree.

For information:
"I don't know what kinds of expression you wish to cover":

my original issue was to represent graphically (and manipulate) an expression such that F0(X0, F) where X0 is a sequence (possibly void) of variables and F a sequence (possibly void) of functions of the form of F0.
A simple example  is F0(x, F1(y, z), F2(F3(u, v, w), F4(p, q)))  (note that all the set of variables in each Fn are mutually disjoint)
Here is the associated tree graph:

restart
with(GraphTheory):
G := Graph({{F__4, p}, {F__4, q}, {F__3, u}, {F__3, v}, {F__3, w}, {F__2, F__3}, {F__2, F__4}, {F__1, y}, {F__1, z}, {F__0, x}, {F__0, F__1}, {F__0, F__2}}):
DrawGraph(G, style=tree, root=F__0)


This kind of graph and/or expression appears in probability theory: for the example above, p, q, u, v, w, x, y, z are random variables and F0..F4 are functions named "copulas" that define some kind of dependency between the variables they operate on.
Copula_(probability_theory)
Such arborescent structure is called a "hierarchical copula" (HC for short, while hierarchical archimedian copula are far more common), see for instance here
HAC.pdf

I have developped a package to "sample from a HC" (at the image of the R package this last reference refers to) but I wanted two things:

  1. that the user can define directly (as in R) the dependency structure with a formula (the only thing that really matters to sample the HC) but taht he can visualize this formula graphicallyt (which is more easily understandable for other persons);
  2. or, that the user can define the structure graphically (I use Maplets to do this), which implies that  I have to construct the formula from the graph.
     

In fact I have to solve a direct (formula --> Graph) and a reverse (Graph --> formula) problem.
I just came back recently on the first point above and "extended" what I had done to other more general mathematical expressions.
That's why I spoke of this work as "an amusement or an exercice".

 

@acer 

Hi, 
Yes, I was aware of the existence of dismantle but I find that its results are less readable than a real graph... at least as long as the latter is not too big!
As you talk about dismantle, could you explain me this phrase (Maple 2015) taken from it's help page :
"...To produce an easily-manipulate inert form of a Maple structure, use ToInert instead."

When I read it first time, I had hoped that Maple functions did exist to manipulate the output of ToInert: it's probably because I didn't find any that I made this post. Nevertheless do not take it too seriously, it's more  fun or an exercise than anything else (although I think graphical visualization of a mathematical expression is pretty cool).

@nm 

This procedure covers a wider range of situations... maybe it will be enough for you?

F.mw

To overcome possible reading problems the code is here

F := proc(expr)
local nf, df, Expr:
nf := map(numer, [op(expr)]);
df := map(denom, [op(expr)]);
Expr := zip((u, v) -> if patmatch(u, y^b::rational*a::anything,'la') then 
                        [a, b] =~ eval(eval([a/v, b], la), y=__y)
                      else 
                        u 
                      end if, 
                      nf, df
        );
map(u -> if type(u, list) then
           if nops(rhs(u[2])) = 1 then
             eval(a*y^b, u)
           else 
             eval(a*y^b*__y^c, [u[1], b=iquo(op(rhs(u[2]))), c=irem(op(rhs(u[2])))/op(2, rhs(u[2]))])
           end if:
         else
           u
         end if,
         %
);
return eval( convert(add(%), horner, y), __y=y)
end proc:

expr := x+y^2*h(x, y)+y^3*f(y)*sin(x)+3*x*y^(7/2);
F(expr)
               2            3                    (7/2)
          x + y  h(x, y) + y  f(y) sin(x) + 3 x y     

            /          /                 (1/2)  \  \  2
        x + \h(x, y) + \f(y) sin(x) + 3 y      x/ y/ y 


expr := y^2+y^(8/3)/(y+1);
F(expr)
                                (8/3)
                           2   y     
                          y  + ------
                               y + 1 

                        /     (2/3)\   
                        |    y     |  2
                        |1 + ------| y 
                        \    y + 1 /   


 

@nm 

ok, thanks for the feed back

@acer 

Initially, I just wanted details on I , and as is often the case on Mapleprimes, the subject has slightly shifted to other considerations.
Nevertheless thank you for your comments.
 

@Carl Love 

Sorry, I've missed the "where a and are manifest real constants" point.
I understand now your what you have said.
 

@Carl Love 

Thank you for this veri documented reply.

Concerning Complex I had indeed observed it was a little peculiar while doing this:

ToInert(Complex(a, b)); #1
    _Inert_FUNCTION(_Inert_NAME("Complex", _Inert_ATTRIBUTE(

      _Inert_NAME("protected", 

      _Inert_ATTRIBUTE(_Inert_NAME("protected"))))), 

      _Inert_EXPSEQ(_Inert_NAME("a"), _Inert_NAME("b")))
ToInert(irem(a, b)); #2
      _Inert_FUNCTION(_Inert_ASSIGNEDNAME("iquo", "PROC", 

        _Inert_ATTRIBUTE(_Inert_NAME("protected", 

        _Inert_ATTRIBUTE(_Inert_NAME("protected"))))), 

        _Inert_EXPSEQ(_Inert_NAME("a"), _Inert_NAME("b")))
ToInert(f(a, b)); #3
      _Inert_FUNCTION(_Inert_NAME("f"), 

        _Inert_EXPSEQ(_Inert_NAME("a"), _Inert_NAME("b")))

While ToInert says Complex is a function, it's name is not assigned (like irem, cos, ln, ...) and looks like f in #3.
But at the same time Complex differs from f  because it has _Inert_ATTRIBUTE(s)  and protected _Inert_NAME(s), just as irem in #2.
It made me feel like Complex was someting in between an "usual" function (irem, cos, ln, ...) and a "user" one (f)

@nm 

Thank you nm.

@acer @vv 

So it is an alias!

Are there other "predefined" aliases in Maple?

 

Thank to both of you
To acer : I think my 2015 is too older for Help page for topic I, but I followed the link and it is useful.
 

@Carl Love 

"Am I so unlucky?"  
Not at all, it's an issue I have to deal with on a regular basis (Maple 2015, Mac OSX Mojave)
This occured for the first time about a year ago.
I remember Tom Leslie having the same problem suggested that forcing interface(rtablesize=10) at the top the of the worksheet could sometimes helped.

From my experience

  • this trick doesn't seem to be a panacea;
  • the problem is not related to the size of data the worksheet generates; for instance the file wich contains this simple lines cannot be displayed
    restart
    interface(version);
    I__D__moy := -(-1 + R)*I__L__moy;
    collect(expand(I__D__moy), I__L__moy):
    map(sort, %, R, ascending);
    Maple Worksheet - Error
    Failed to load the worksheet /maplenet/convert/arrange.mw .

    Download arrange.mw

     

  • it is more common when you use some packeges such that Statistics, plots/plottools


This of course doesn't help

@Kitonum 

Ok, I was fooled by "solve" and, out of overconfidence, didn't check his result.
Good point, I piteously vote up 

First 94 95 96 97 98 99 100 Last Page 96 of 154