vv

13977 Reputation

20 Badges

10 years, 36 days

MaplePrimes Activity


These are answers submitted by vv

with(plots):

cylx := y^2 + z^2 - 1;
cylz := x^2 + y^2 - 1;

y^2+z^2-1

 

x^2+y^2-1

(1)

cyl:=implicitplot3d([cylx,cylz], x=-2..2, y=-2..2, z=-2..2,
scaling=constrained, style=surface, grid=[40, 40, 40], labels=[x, y, z]):

s:=solve([cylx,cylz],[x,y,z], explicit)

[[x = z, y = (-z^2+1)^(1/2), z = z], [x = z, y = -(-z^2+1)^(1/2), z = z], [x = -z, y = (-z^2+1)^(1/2), z = z], [x = -z, y = -(-z^2+1)^(1/2), z = z]]

(2)

a:=1.05:
ell:=spacecurve([seq(a*rhs~(s[i]),i=1..4)], z=-1..1, color=[red$2,yellow$2], thickness=4):

display(cyl,ell);

 

 

Download cyl.mw

Here is a procedure for Conic classification (general case). It was extracted (& adapted) from a MathApp.
It will not be useful to you, unless you read about this subject.

P:=proc(a,b,c,d,e,f)  #  See ?MathApps,ConicSections
    local equ,disc,Delta, Type, Point, deg, equ2;
    equ := sort(a*x^2+b*x*y+c*y^2+d*x+e*y+f);
    Delta := 4*a*c*f-a*e^2+b*e*d-b^2*f-c*d^2;
    disc := b^2-4*a*c;
    if Delta <> 0 then

        if disc < 0 then
            if c*Delta > 0 then
                Type := "This equation has no real solutions.";
            elif b = 0 and a = c then
                Type := "A circle.";
            else
                Type := "An ellipse.";
            end if;
        elif disc = 0 then
            Type := "A parabola.";
        else
            Type := "A hyperbola.";
        end if;

    # From here on, Delta = 0 : we have the degenerate cases

    elif disc > 0 then #OK
        Type := "Two intersecting lines.";
    elif disc < 0 then #OK
        Type := "A single point.";
        Point := [(2*c*d-b*e)/disc, (2*a*e-b*d)/disc];
    elif equ = 0 then
        Type := "Every point is a solution.";
    else
        deg := degree(equ, [x,y]);
        if deg = 0 then
            Type := "This equation has no solutions.";
        elif deg = 1 then
            Type := "A line.";
            equ2 := equ;
        else
            # a,b,c not all 0
            if c = 0 then
                # c=b=e=0
                disc := d^2-4*a*f;
            else
                # if a = 0 then                
                    # a=b=d=0
                    disc := e^2-4*c*f;
                # else
                    # both discs above have same sign,
                    # so either one is sufficient
                # end if;
            end if;
            if disc > 0 then
                Type := "Two parallel lines.";
            elif disc = 0 then
                Type := "A line.";
                equ2 := select(has, factor(equ)*t, [x,y]);
                if type(equ2, `^`) and op(2, equ2) = 2 then
                    equ2 := op(1, equ2);
                end if;
            else
                Type := "This equation has no solutions.";
            end if;
        end if;
    end if;
    equ=0,'Type'=Type;
end proc:
P(1,2,3,4,5,-6);
plots:-implicitplot(%[1], x=-10..10,y=-10..10, scaling=constrained);
        x^2 + 2*x*y + 3*y^2 + 4*x + 5*y - 6 = 0, Type = "An ellipse."

Why do you say that the first ODE y' = p1/p2 is exact? It became exact, after you have multiplied it with the integrating factor p2.
Most ODEs are in this situation. Should all be declared exact?

## The simplest way is to solve the equation in x
X:=fsolve(1/x^3-sin(12*x)=0, x=1.2..2, maxsols=10); # there are 3 solutions

     X := 1.266058342, 1.591679996, 1.818677859

Y := seq(1/x^3, x=X);

     Y := 0.4927638533, 0.2479891760, 0.1662389018

 

## As a system
s:={fsolve([y-sin(12*x)=0,x^3*y=1], {x,y}, {x=1.2..2})}; # first root

     s := {{x = 1.818677859, y = 0.1662389017}}

fsolve([y-sin(12*x)=0,x^3*y=1], {x,y}, {x=1.2..2}, avoid=s): # repeat if you want
s:=s union {%};

     s := {{x = 1.266058343, y = 0.4927638522}, {x = 1.818677859, y = 0.1662389017}}

N := 100:
for a to N do
for b from a to N do
for c from b to N do
  s:=[isolve(t^3-(a+b+c)*t^2+(a*b+a*c+b*c)*t-2*a*b*c)];
  if nops(s)>1 then print(rhs~(op~(s)), [a,b,c]) fi;
od od od:
                     [3, 5, 16], [1, 8, 15]
                    [7, 8, 30], [2, 15, 28]
                    [6, 10, 32], [2, 16, 30]
                    [5, 16, 42], [2, 21, 40]
                    [9, 15, 48], [3, 24, 45]
                    [8, 21, 45], [3, 35, 36]
                    [7, 33, 80], [3, 40, 77]
                   [14, 16, 60], [4, 30, 56]
                   [12, 20, 64], [4, 32, 60]
                   [11, 24, 70], [4, 35, 66]
                   [10, 32, 84], [4, 42, 80]
                   [15, 25, 80], [5, 40, 75]
                   [13, 35, 96], [5, 48, 91]
                   [21, 24, 90], [6, 45, 84]
                   [18, 30, 96], [6, 48, 90]
                   [16, 42, 90], [6, 70, 72]
                   [18, 55, 112], [7, 88, 90]
 

You have a restart after with(LinearAlgebra).

So, P[0], P[1] are given and you need P[i] for i>1 in terms of L[i,j].
We may suppose P[0] = [0,0] (the origin) and P[1] = [a,0], a>0 (actually a=L[0,1]).
Only L[k,0], L[k,1] will be needed (k>1).

There are 2 solutions (symmetric wrt the x axis), so we may take the y-coordonate of P[k] be positive.

solve( [ x^2+y^2 = L[k,0]^2, (x-a)^2+y^2 = L[k,1]^2 ], {x,y}, explicit ):
select( u -> (sign(eval(y,u))=1), %):
P[k]=eval([x,y],%);

 

 

Use
G1:=RelabelVertices(G,[1,2,3,4,5,6]);

In Maple, a polynomial cannot have symbolic exponents (powers). For example, x^m - x^2 - 2 is not a polynomial, unless m is a (constant) nonnegative integer. This is normal; try for example to compute by hand the quotient and the remainder for the polynomials  x^m - x^2 - 2  and x^3 + 2*x + 3; such operations are essential in the Groebner package.

In conclusion your problem cannot be solved in a CAS (but you may solve it providing integer value(s) for m).

Maple needs a little help.

restart;
eq := x^2+floor(x)-10:
seq( solve({eval(eq, floor(x)=n), n <= x, x < n+1}), n=-5..5);

        {x = -sqrt(14)}, {x = 2*sqrt(2)}

restart;

LongestPath:=proc(a,b, G0::GRAPHLN, all::truefalse:=false)
uses GraphTheory;
local Pab:=Array(1..0), P, LEN, G, k,lengths;

LEN:=(u::list) -> add(GetEdgeWeight(G, u[i..i+1]),i=1..nops(u)-1);

P:=proc(u::list, a, G)
  local c, Ga := DeleteVertex(G,a);
  for c in Neighbors(G, a) do
    if c=b then Pab ,=  [u[],a,b]
    else thisproc([u[],a], c, Ga)
    fi;
  od;
  NULL
end proc:

G:=`if`(IsWeighted(G0), G0, MakeWeighted(G0));  
P([], a, G);  Pab:=seq(Pab);
lengths:=map(LEN,[Pab],G); k:=max[index](lengths);
if all then lprint('paths'=Pab); lprint('lengths'=lengths) fi;
Pab[k], lengths[k]

end proc:

##################

with(GraphTheory):

G:=CycleGraph(5):
G:=AddEdge(G, {1,4}):
a,b:=2,4;

2, 4

(1)

DrawGraph(G, layout=circle);

 

LongestPath(a, b, G);

[2, 1, 5, 4], 3

(2)

LongestPath(a, b, G, true);

paths = ([2, 1, 4], [2, 1, 5, 4], [2, 3, 4])
lengths = [2, 3, 2]

 

[2, 1, 5, 4], 3

(3)

 


 

Download LongestPath-sent2.mw

For such expressions involving principal branches, the solutions are difficult to find, and more important, they are much more difficult to check.

Consider the equation (equivalent to yours):
g:=2*ln(u) + ln(u^2+2);
solve( g - c = 0, u);       # 2 solutions     (1)

solve( g - ln(c) = 0, u);  # 4 solutions   (2)

If we are interested in real solutions (so, u>0, c real) then there is a unique solution.

But for complex u, c, do we have 2? 4? more? Of course (1) and (2) are contradictory (the 4 solutions given in (2) are distinct but not all are true -- for the principal branch of ln: just take a numeric c and check the solutions).
So, it's much more important to determine the true solutions rather than to eliminate the duplicates!

 

 

 

 

 

seq(expand(eval(test,_B1=v)), v=0..1); # 1/2, 1/2

 

Make the first multiplication inert.

restart;
expr:= A*B*C;
o1:= op(1,expr);
expr1:=o1%*(expr/o1);
nops(expr1);  # 2
value(expr1); # = expr

 

@Hnx 

diff  knows piecewise, so you can use it directly:

restart:
with(CurveFitting):
S := Spline([[0,0],[1,1],[2,4],[3,3]], v);
dS := diff(S,v);

 

First 39 40 41 42 43 44 45 Last Page 41 of 120