vv

13922 Reputation

20 Badges

10 years, 10 days

MaplePrimes Activity


These are replies submitted by vv

@mehdi jafari 

You cannot do much. Working with symbolic parameters could be very delicate.
Maple cannot allways use piecewise expressions because the final result would be huge and useless. That is why it works "generically". Very few commands generate such piecewice results (e.g. SemiAlgebraic, but with limitations).

For a correct & complete solution we must try to anticipate such problems, using carefully for example solve and singular.

In my example,

singular(ex);  # singular points
                {x = -1, y = y}, {x = -y, y = y}

So, x=0 followed by y=0  ==> problematic and x=0 must be treated separately.

In your case, look for the singularities in S_NEW.

The unpleasant fact is that a Maple result may not contain singularities (due to generic simplifications) and still may depend on special values for parameters. So, anticipate!

 

 

@Carl Love 

Because I know very little about objects (probably <  "necessary minimum") I'd use modules, with the advantage (for me at least) of being easier to read (almost like a pseudocode).

restart;
FW:=module()
export ModuleApply, Path;
local Next,dist, w, n:=0;
ModuleApply:= proc(G::GRAPHLN)  #FloydWarshallWithPathReconstruction
   local uv,u,v,i,j,k;
   w := `if`(GraphTheory:-IsWeighted(G), GraphTheory:-WeightMatrix(G), GraphTheory:-AdjacencyMatrix(G)); 
   n:=op([1,1],w);
   dist:=Matrix(n,fill=infinity);
   Next:=Matrix(n);
   for uv in indices(Matrix(w, storage=sparse)) do
      u,v:=uv[];
      dist[u,v] := w[u,v];  # the weight of the edge (u,v)
      Next[u,v] := v
   od;
   for v to n do
      dist[v,v] := 0;
      Next[v,v] := v;
   od;
   for k from 1 to n do ## standard Floyd-Warshall implementation
      for i from 1 to n do
         for j from 1 to n do
            if dist[i,j] > dist[i,k] + dist[k,j] then
               dist[i,j] := dist[i,k] + dist[k,j];
               Next[i,j] := Next[i,k]
            fi;
   od od od;
dist;
end proc:

Path:=proc(u0::posint, v0::posint)
   local u:=u0, v:=v0, path:= Array([u]);
   if u>n or v>n then error "Wrong vertex" fi;
   if Next[u,v] = 0 then return [] fi;
   path := Array([u]);
   while u <> v do
       u := Next[u,v];
       path ,=  u
   od;
   path
end proc;

end module:

G:= GraphTheory:-RandomGraphs:-RandomGraph([v||(1..9)], 0.5, connected, directed);
FW(G);
FW:-Path(2,3);

Could you please tell what are the benefits of using objects in this case?


Edit. An advantage seems to be the possibility to have several graphs. But the module could be adapted for this.

 

@tomleslie 

Thank you. For me the tip works only sometimes (but curiously, the font is not changed).
Not a big deal, Notepad always works.

@Thomas Richard 

Screenshot (new session);

@rlopez 

Actually, the problem from a mathematical point of view is not complicated. It's easy to formulate it as a minimization problem.
The embarrassing fact is that good numerical methods for global minimization do not exist!

@nm 

Actually that's why integrating factors were invented. See https://en.wikipedia.org/wiki/Inexact_differential_equation

@nm The ode is supposed (implicitly) to be an expanded polynomial in y'. Your examples are of this type. If you expand the ode, it will be OK.

For the general case of obtaining

G(y',y'^2,y'^3,.....,y'^n)  = F(x,y), (actually you probably want  G(x,y',y'^2,y'^3,.....,y'^n)  = F(x,y))

the problem seems to be very complicated.

For example, (x+y(x))*(1 + diff(y(x),x)^2+x^2+1)=1  ==> (x+y(x))=1/*(1 + diff(y(x),x)^2+x^2+1)
cannot be obtained this way.

The problem reduces to write a relation F(x,y,z)=0 in an equivalent form  f(x,y)=g(x,z).
It seems to be very difficult, a solution (when it exists) is obviously not unique, and probably there is no algorithm for it. 

@gaurav_rs 

My example shows that what you describe could be the normal behavior.
This depends on the nature of your problem.

sol:=
piecewise(And(a+b = 0,a-b = 0,-m+j = 0,-j-m = 0),[[x = 0, y = y, z = 0, t = t],
[x = x, y = 0, z <> 0, t = 0], [x <> 0, y = 0, z = 0, t = 0]],And(a+b = 0,a-b =
0,-m+j = 0,-j-m <> 0),[[x <> 0, y = 0, z = 0, t = 1/2*(-j-m)/x]],And(a+b = 0,a-
b = 0,-m+j <> 0,-j-m = 0),[[x = 0, y <> 0, z = 1/2*(-m+j)/y, t = 0]],And(a+b =
0,a-b <> 0,-m+j = 0,-j-m = 0),[[x = 0, y = 0, z <> 0, t = 1/2*(a-b)/z]],And(a+b
= 0,a-b <> 0,-m+j = 0,-j-m <> 0),[[x <> 0, y = 0, z = -x*(a-b)/(j+m), t = 1/2*(
-j-m)/x]],And(a+b = 0,a-b <> 0,-m+j <> 0,-j-m = 0),[[x = 0, y <> 0, z = 1/2*(-m
+j)/y, t = (a-b)*y/(-m+j)]],Or(And(a+b <> 0,a-b = 0,-m+j = 0,-j-m = 0),And(a+b
<> 0,a-b = 0,-m+j = 0,-j-m <> 0)),[[x <> 0, y = 1/2*(a+b)/x, z = 0, t = 1/2*(-j
-m)/x]],Or(And(a+b <> 0,a-b = 0,-m+j <> 0,-j-m = 0),And(a+b <> 0,a-b <> 0,-m+j
<> 0,-j-m = (a-b)*(a+b)/(-m+j))),[[x <> 0, y = 1/2*(a+b)/x, z = (-m+j)*x/(a+b),
t = 1/2/(-m+j)/x*(a^2-b^2)]],[]);

I'll try later (probably) to post a method to obtain this.

Edited.

@Kitonum 

You have a missing "-" in Sys. As I have mentioned, with u^(2/3) the conclusion is not true.

@Carl Love 

Unfortunately eliminate does not work properly here.
For example, a=b is not enough to have solutions.
So, the "general"  solution {...}  (z<>0)  is valid for   a^2 <> b^2  and  j^2 <> m^2  and  a^2-b^2+j^2-m^2 = 0  

Then the cases  a=b etc  must be considered separately.

A more reliable command is
SolveTools:-SemiAlgebraic(sys,[x,y,z,t]);   # (*)
but it is very slow in this case and I had not enough patience.
But the simpler system

SolveTools:-SemiAlgebraic([t*x=a, y*z=b, t*z=c, x*y=d], [x,y,z,t]);
works, and seems to find all the cases (for reals, it considers >0, <0, =0 ...).
Note that actually the original system can be reduced to (*).

 

 

You recently posted a similar question about the Galerkin finite element method.
After you received an answer and a few comments, you deleted it.
A potential respondent should be warned.

@mmcdara 

I don't know what you are talking about. I have not modified anything.
What insult? By without detours I ment a standalone formula, not depending on some randomly generated objects.
If you don't like/want my answers, just say it and I won't bother you in the future.

 

@waseem 

The method in the article works for linear problems. For nonlinear ones there are lots of complications.
 

@waseem 

Why would you want this for such a simple problem which is solved by Maple at once?
The authors had a strong motivation: they needed a published paper.

First 57 58 59 60 61 62 63 Last Page 59 of 176