vv

12453 Reputation

19 Badges

9 years, 281 days

MaplePrimes Activity


These are replies submitted by vv

@mmcdara 

For me,  answer -> a (possible) solution,  reply -> comment (not containing in general a solution).

restart;
# a simplistic Functional Form "à la dismantle"
FF := proc(e, n:=0)
  if e::atomic then printf("%s\n", cat(" "$n, e)); return fi;
  printf("%s\n", cat(" "$n, op(0,e)));
  map(FF, [op(e)], n+4);
  NULL
end:
FF((x+1)/(x-1)^2+sqrt((exp(-x^2)-1)/(x+1)));
+
    *
        +
            x
            1
        ^
            +
                x
                -1
            -2
    ^
        *
            +
                exp
                    *
                        -1
                        ^
                            x
                            2
                -1
            ^
                +
                    x
                    1
                -1
        1/2

 

@nm It is not just that. In Mathematica the two "forms" are equivalent, the first one being graphical. In Maple they can be obtained easily with op().
The result of dismantle cannot be obtained this way. It reflects the internal representation, not very useful for a regular user.

dismantle(5*x+7*y);

SUM(5)
   NAME(4): x
   INTPOS(2): 5
   NAME(4): y
   INTPOS(2): 7
dismantle(a*x+b*y);

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

From op()'s point of view, the two expressions have the same "structure": 

`+`(`*`(5,x), `*`(7,y));
`+`(`*`(a,x), `*`(b,y));

 

@snowman Do not increase Digits. Increase numpoints or set gridrefine=3 in implicitplot.

p:=plots:-implicitplot(G, -5..5, -5..5, numpoints=10000):

 

@nm Yes, I see it now. But the easiest is to simply copy the code in the startup region.

@Carl Love It seems that there is an easy method.

1. Execute
interface(echo=2);


2. Create a file abc.txt with the procedure to debug (syntax)

P:= proc()
local j;
    for j to 9 do
        x:= x % 1
    od;
    x := x+7
    print("OK");
end proc:
3. Read the file
read "d:/temp/abc.txt";
 
4. Using a text editor correct "%" in the file and read again (goto 3.)
 
Note. Another method is to place the code of the procedure in the startup region (not in a code edit region); then all the syntax errors are found in the "Diagnostics" tab.
Probably, in the future, a code edit region will do the same.

@Preben Alsholm Yes, provided there are no double quotes embedded between quotes. e.g. print(a=`2"`).

@Carl Love Nice idea, vote-up.
Note that the method fails when the code contains double quotes, but fortunately, in this case the cursor is positioned at the line containing "...".

S:=" 
P:= proc()
local j;
    for j to 9 do
        x:= x % 1
    od;
    print("OK");
end proc:
"

 

@acer
sol := y(x) = _C1*x*sin(2*ln(x))+x*cos(2*ln(x))/sin(x)*_C2:
But, will this be the last counter-example?
 

@acer sort may fail when the detected indets are too far from polynomials. E.g.
sol := y(x) = _C1*x*sin(2*ln(x))+_C2*x*cos(2*ln(x))/(x+sin(x));
 

@acer Yes, I know, but the probability is low.
I saw your solution in the other thread, but it also has some issues (see there).

Edit. A workaround is to declare c as local.
BTW, you meant ex1a:=...  So,

restart;
ex1:=1/cosh(x)+   (cosh(x)^2+cosh(x)*sinh(x)+x)/cosh(x)*_C1 + x*exp(_C3+x+_C2)*C:
ex2:=_C1/cosh(x)+ (cosh(x)^2+cosh(x)*sinh(x)+x)/cosh(x):
ex3:=_C1/cosh(x)+ (cosh(x)^2+cosh(x)*sinh(x)+x)/cosh(x)*_C2:
ex1a:=1/cosh(x)+   (cosh(x)^2+cosh(x)*sinh(x)+x)/cosh(x)*c[1] + x*exp(c[3]+x+c[2])*C:
ex2a:=c[1]/cosh(x)+ (cosh(x)^2+cosh(x)*sinh(x)+x)/cosh(x):
ex3a:=c[1]/cosh(x)+ (cosh(x)^2+cosh(x)*sinh(x)+x)/cosh(x)*c[2]:
Cc:=proc(u)
  local c, Cc1 := C -> c[parse(convert(C,string)[3..])];
  subsindets(u, `*`,
    proc(u)
      local k,r;
      k,r:=selectremove(type, [op(u)], suffixed(_C,integer));
      if nops(k)<>1 then return u fi;
      `*`(Cc1(k[]),r[])
    end):
  subsindets(%, suffixed(_C,integer), Cc1)
end:
Cc(ex1); Cc(ex2); Cc(ex3);


 

 

@ecterrab `print/_C`   is applied (in the original version) for _C()  and works (for display).
See my comment above for Latex(_C()...), and my solution above to place c[k] in front of a product.

@nm There are a few problems here.

1. The subs in the original version must be used only for display purposes.

2. Latex fails  for  _Cn()
Latex(_C4()/x+x);
  ==> \frac{1}{x}+x
Latex(_C4()+x);      ==> \mathit{\_C4} {}+x

3. It seems that in order to put c[k] instead of _Ck in front of a product, 
sort is not always useful, so, it will be necessary to use subsindets

 

@nm I think that this works.

assign(seq(`print/_C`||k, k=0..10) = seq(c[k], k=0..10)):
S:=[seq(_C||k = _C||k(), k=0..10)]:

sol:=dsolve(t^2*diff(diff(y(t),t),t)-t*diff(y(t),t)+5*y(t) = 0,y(t)):
subs(S, sol);

 

@JAMET Like this:

qq:=expand(q(3,b)); # a = arbitrary (a=3 here)
Delta:=diff(qq,x,y)^2-diff(qq,x,x)*diff(qq,y,y);
solve(Delta>0); 

Be aware that an ellipse could be complex, so an extended analysis is needed.
Why don't you try something yourself in Maple and show the results?

First 26 27 28 29 30 31 32 Last Page 28 of 166