janhardo

850 Reputation

12 Badges

11 years, 246 days
B. Ed math

MaplePrimes Activity


These are replies submitted by janhardo

@Kitonum , Thank you, it's now clear what it's about.

@Kitonum 
This Graph has 12 Hamilton circuits
Note: animation is not working?

restart;
with(GraphTheory): with(combinat):
G := CompleteGraph(5):
# Genereer alle permutaties van {2,3,4,5}
P := permute([2,3,4,5]):
# Houd slechts één richting (vermijd spiegeling)
HCs := [seq([1,op(p),1],p in P)]:
HCs := select(p->p[2]<p[5],HCs);
# 12 kleuren (Maple-kleurnamen)
Colors := [red,blue,green,magenta,cyan,gold,
           violet,orange,brown,pink,navy,black]:
# Highlight elk circuit met andere kleur
Frames:=[seq(DrawGraph(HighlightTrail(G,HCs[i],inplace=false),
   stylesheet=[edgethickness=4,edgehighlightcolor=Colors[i],
               edgecolor=grey,edgehighlightthickness=4]),i=1..nops(HCs))]:
# Animatie
plots:-display(Frames, insequence);

@Kitonum 
How do you call this graph ?
Its not a Hamilton graph.

There is a Physics and DifferentialGeometry package and it seems that you can do this in both  packages 

Apparently, it works via a different type of derivative.
The differential geometry in Maple has a geometric object calculation from which components can be derived
In addition, the usual standard calculation method in Maple
I am trying to familiarize myself with the package.

 

 

 

restart:

with(DifferentialGeometry):
with(Tensor):
with(Tools):

#========================================================
# (1) Definieer de 2-sfeer S^2
#========================================================

DGsetup([theta, phi], S2):

g := evalDG( dtheta &t dtheta
           + sin(theta)^2 * dphi &t dphi ):

print("---- (1) METRIEK g ----"):

DGinfo(g, "ObjectType");
DGinfo(g, "ObjectComponents");
convert(g, DGArray);

#========================================================
# (2) Inverse metriek
#========================================================

ginv := InverseMetric(g):

print("---- (2) INVERSE METRIEK ----"):

DGinfo(ginv, "ObjectType");
DGinfo(ginv, "ObjectComponents");
convert(ginv, DGArray);

#========================================================
# (3) Directional derivative van scalar
#========================================================

X := D_theta + 2*D_phi:
f := cos(theta):

 Xf := DirectionalDerivative(X, f):

print("---- (3) DIRECTIONAL DERIVATIVE ----"):

#whattype(Xf);     # toont dat dit gewoon een scalar is
# DGinfo(Xf, "ObjectComponents");  # <-- zou fout geven!

#########  om een waarde te krijgen  JD ####
# Optioneel: met LieDerivative
Xf_lie := LieDerivative(X, f);
simplify(Xf_lie);

#========================================================
# (4) Christoffel-symbolen
#========================================================

Gamma := Christoffel(g):

print("---- (4) CHRISTOFFEL ----"):

DGinfo(Gamma, "ObjectType");
DGinfo(Gamma, "ObjectComponents");

# convert(Gamma, DGArray);  # <-- geeft fout (geen tensor!)

#========================================================
# (5) Riemann tensor
#========================================================

R := CurvatureTensor(g):

print("---- (5) RIEMANN TENSOR ----"):

DGinfo(R, "ObjectType");
DGinfo(R, "ObjectComponents");

#========================================================
# (6) Ricci tensor
#========================================================

Ric := RicciTensor(R):

print("---- (6) RICCI TENSOR ----"):

DGinfo(Ric, "ObjectType");
DGinfo(Ric, "ObjectComponents");
convert(Ric, DGArray);


#========================================================
# (7) Ricci scalar
#========================================================

Rscalar := RicciScalar(g):

print("---- (7) RICCI SCALAR ----"):

whattype(Rscalar);   # scalar, geen tensor

#========================================================
# (8) Gausskromming
#========================================================

detg := MetricDensity(g, 2):

K := simplify(
      DGinfo(R, "CoefficientList", [[1,2,1,2]])[1]
      / detg ):

print("---- (8) GAUSSKROMMING ----"):

K;

"---- (1) METRIEK g ----"

 

"tensor"

 

[[[1, 1], 1], [[2, 2], sin(theta)^2]]

 

Matrix(2, 2, {(1, 1) = 1, (1, 2) = 0, (2, 1) = 0, (2, 2) = sin(theta)^2})

 

"---- (2) INVERSE METRIEK ----"

 

"tensor"

 

[[[1, 1], 1], [[2, 2], 1/sin(theta)^2]]

 

Matrix(2, 2, {(1, 1) = 1, (1, 2) = 0, (2, 1) = 0, (2, 2) = 1/sin(theta)^2})

 

"---- (3) DIRECTIONAL DERIVATIVE ----"

 

Xf_lie := -sin(theta)

 

-sin(theta)

 

"---- (4) CHRISTOFFEL ----"

 

"connection"

 

[[[1, 2, 2], -(1/2)*sin(2*theta)], [[2, 1, 2], cot(theta)], [[2, 2, 1], cot(theta)]]

 

"---- (5) RIEMANN TENSOR ----"

 

"tensor"

 

[[[1, 2, 1, 2], sin(theta)^2], [[1, 2, 2, 1], -sin(theta)^2], [[2, 1, 1, 2], -1], [[2, 1, 2, 1], 1]]

 

"---- (6) RICCI TENSOR ----"

 

"tensor"

 

[[[1, 1], 1], [[2, 2], sin(theta)^2]]

 

Array(%id = 36893490623282316820)

 

"---- (7) RICCI SCALAR ----"

 

integer

 

"---- (8) GAUSSKROMMING ----"

 

sin(theta)^2/_DG([["tensor", S2, [[], [["bas", 2]]]], [[[], sin(theta)^2]]])

(1.1)
 

 

Download directionl_derative_word_lie_derative_nog_niet_berekend_16-2-2026.mw

@acer 

Use table then...but a procedure for this seems to be better, but for that  it is not a one- liner code length anymore.

toPrefix:=T->['table', seq([op(1,k),T[op(1,k)]], k in indices(T))]:

Warning, (in toPrefix) `k` is implicitly declared local
T:=table([f=a,q=s]):
toPrefix(T);

using  H := e ->eval(subsindets(e, algebraic, u -> `if`(type(u,atomic),
                       u, `[]`(op(0,u),op(u)))));

@Carl Love 
I had already made a calculation with the osculation circles, but I didn't know enough about it ,and the question was asked as a circle?
Interesting code example with the ~ operator

@sand15 

Suppose you draw a circle with center (0,0), then the points of intersection will touch the graph.
But not in this example, it are two tangent points
There is only one hyperbole type possible for two tangent points on the circle. 
hyperboolvergelijking_voor_2_ryaakpuontuen_aan_ciprkel_mprimes_10-.mw



 

restart:

# Conic and circle as functions
F := (x,y) -> A*x^2 + B*x*y + C*y^2 + D*x + E*y + F0;
G := (x,y) -> x^2 + y^2 - r^2:

# Expressions for differentiation
Fx := F(x,y):
Gx := G(x,y):

# Tangency condition (parallel gradients)
Detm := expand(
    diff(Fx,x)*diff(Gx,y)
  - diff(Fx,y)*diff(Gx,x)
):

# Conditions at ±(r,0)
eqs := [
    F(r,0) = 0,
    F(-r,0) = 0,
    subs({x=r,y=0},Detm) = 0,
    subs({x=-r,y=0},Detm) = 0
]:

# Eliminate A, C, F0
eliminate(eqs,{A,C,F0});

# Structural constraints
solve([
    r*(B*r - E) = 0,
    r*(B*r + E) = 0,
    2*D*r = 0
],[B,D,E]);

# Reduced conic
F2 := (x,y) -> A*x^2 + C*y^2 + F0;

# Normalize to standard form
Fstd := simplify(subs({A=-F0/a^2,C=F0/b^2}, F2(x,y))):
expr := simplify(Fstd/(-F0)):
simplify(expand(expr+1 = 1));

 

@sand15 
You could say there is space to draw a circle, but not tangent to the curve points is possible by circle geometry.
That f(0) is undefined, has nothing to do with the circle 

@Alfred_F 

If a left limit and a right limit for a function value are not the same , then there is no derivative function (geometrically a tangent line).

The function is continuous, but I do not know how Maple handles this. Maple will probably respond that the limit does not exist.  ( f(x)= |x| example ? )

@acer 
Thanks, so Maple calls a name with or without a value assigned to it a “variable” in a procedure application.

@acer 

But just looking at it from a practical point of view, how you work with variables in a procedure to calculate something.
Then the description I gave of a variable is correct, isn't it?
Note: 
Of course, I know the expression: "this depends on a lot of variables", without the variables in question changing in value.

@dharr 

How about this ?

restart:
with(Fractals[LSystem]):
with(plots):

L := (Init,Ang,Par,Rules,Col) ->
display(
  [seq(
     LSystemPlot(
       `if`(i=0, Init, Iterate(Init, Rules, i)),
       Par,
       initialangle=Ang,
       color=Col,
       scaling=constrained,
       axes=none,
       thickness=2
     ),
   i=0..7)],
  insequence=true,
  frames=64
):

# --- L-system 17 ---
L("X",90,
  ["F"="draw:1","+"="turn:-25.7","-"="turn:25.7",
   "["="push:position;push:angle","]"="pop:position;pop:angle"],
  ["F"="FF","X"="F[+X][-X]FX"],
  "Red");

# --- L-system 18 ---
L("X",90,
  ["F"="draw:1","+"="turn:20","-"="turn:-20",
   "["="push:position;push:angle","]"="pop:position;pop:angle"],
  ["F"="FF","X"="F[+X]F[-X]+X"],
  "DarkGreen");


==========================================================

restart:
with(Fractals[LSystem]):
with(plots):

Frame := (i, S) ->
display(
  [seq(
     LSystemPlot(
       `if`(i=0, s[1], Iterate(s[1], s[4], i)),
       s[3],
       initialangle=s[2],
       color=s[5],
       scaling=constrained,
       axes=none,
       thickness=2
     ),
   s in S)]
):

Animate := (Systems, N) ->
display(
  [seq(Frame(i, Systems), i=0..N)],
  insequence=true,
  frames=64
):

# --- Definieer L-systems als lijsten ---
LS := [
 ["X",90,
  ["F"="draw:1","+"="turn:-25.7","-"="turn:25.7",
   "["="push:position;push:angle","]"="pop:position;pop:angle"],
  ["F"="FF","X"="F[+X][-X]FX"],
  "Red"],

 ["X",90,
  ["F"="draw:1","+"="turn:20","-"="turn:-20",
   "["="push:position;push:angle","]"="pop:position;pop:angle"],
  ["F"="FF","X"="F[+X]F[-X]+X"],
  "DarkGreen"]
]:

# --- Start animatie ---
Animate(LS, 7);

Used seq command for plot construction.
Seems that more animations at the same time can be runnning ..

restart;


# ============================================
# UNIVERSAL MANDALA MAKER WITH CLASSIC STYLE USING SEQ
# ============================================

MANDALA := proc(f, kind, sym, layers)
    local P, n, trace_list, i, Colors;
    uses plots, plottools;
    trace_list := [seq(i, i=1..f)];
    
    if kind = "classic" then
        # CLASSIC STYLE - WITH SEQ for full rotation animation
        Colors := [seq(op(["LightBlue","Indigo","Violet","Red","Orange","Yellow","Green"]), i=1..ceil(f/7))];
        Colors := Colors[1..f];
        
        P := proc(nn)
            local plot_obj, color_idx, rotations, j;
            
            color_idx := round(nn);
            if color_idx < 1 then color_idx := 1;
            elif color_idx > f then color_idx := f; end if;
            
            plot_obj := plot([x^(1+0.1*(nn-1)), x^(1/(1+0.1*(nn-1)))], 
                            x=0..1, 
                            thickness=5, 
                            color=Colors[color_idx], 
                            transparency=0.4);
            
            # WITH SEQ for full rotation animation
            # Create 1 rotation per frame that rotates completely
            rotations := seq(
                rotate(plot_obj, Pi*nn/f + 2*Pi*j, [0.5,0.5]),
                j = 0..0  # One rotation per frame, but with progressive angle
            );
            
            return display(rotations, axes=none);
        end proc;
        
    elif kind = "original" then
        # ORIGINAL STYLE - with seq for symmetry
        local Colors2;
        Colors2 := [seq(op(["LightBlue","Indigo","Violet","Red","Orange","Yellow","Green"]), i=1..ceil(f/7))];
        Colors2 := Colors2[1..f];
        
        P := proc(nn)
            local plot_obj, color_idx, exponent_val, rotations, j;
            
            color_idx := round(nn);
            if color_idx < 1 then color_idx := 1;
            elif color_idx > f then color_idx := f; end if;
            
            exponent_val := 1 + 0.1*(nn-1);
            
            plot_obj := plot([x^exponent_val, x^(1/exponent_val)], 
                            x=0..1,
                            thickness=3,
                            color=Colors2[color_idx],
                            transparency=0.4);
            
            # Add symmetry WITH SEQ
            rotations := display(
                seq(
                    rotate(plot_obj, 2*Pi*j/sym, [0.5,0.5]),
                    j = 0..sym-1
                ),
                axes=none
            );
            
            return rotations;
        end proc;
        
    elif kind = "power" then
        # POWER FUNCTIONS - with seq for layers and symmetry
        P := proc(nn)
            local t_val, exp_val, plot_obj, color_hue, rotation_seq, i, j;
            
            t_val := (nn-1.0)/(f-1.0);
            exp_val := 0.5 + 4.5*t_val;
            color_hue := COLOR(HUE, t_val);
            
            plot_obj := plot([x^exp_val, x^(1/exp_val)], 
                            x=0..1,
                            thickness=2,
                            color=color_hue,
                            transparency=0.3);
            
            # Layers and symmetry WITH NESTED SEQ
            rotation_seq := seq(
                seq(
                    rotate(plot_obj,
                           Pi*nn/f + 2*Pi*j/sym + (i-1)*Pi/(layers*2),
                           [0.5,0.5]),
                    j = 0..sym-1
                ),
                i = 1..layers
            );
            
            return display(rotation_seq, axes=none);
        end proc;
        
    elif kind = "sine" then
        # SINE WAVES - with seq for layers and symmetry
        P := proc(nn)
            local t_val, freq_val, plot_obj, color_hue, rotation_seq, i, j;
            
            t_val := (nn-1.0)/(f-1.0);
            freq_val := 1 + 9*t_val;
            color_hue := COLOR(HUE, t_val);
            
            plot_obj := plot([0.5+0.3*sin(2*Pi*freq_val*x),
                             0.5+0.3*cos(2*Pi*freq_val*x)],
                            x=0..1,
                            thickness=2,
                            color=color_hue,
                            transparency=0.3);
            
            # Layers and symmetry WITH NESTED SEQ
            rotation_seq := seq(
                seq(
                    rotate(plot_obj,
                           Pi*nn/f + 2*Pi*j/sym + (i-1)*Pi/(layers*2),
                           [0.5,0.5]),
                    j = 0..sym-1
                ),
                i = 1..layers
            );
            
            return display(rotation_seq, axes=none);
        end proc;
        
    else
        error "Unknown mandala kind: %1", kind;
    end if;
    
    # Animate for all styles
    return animate(P, [n], n=1..f, frames=f,
                   trace=trace_list,
                   axes=none,
                   size=[500,500],
                   paraminfo=false);
end proc:

# ============================================
# TEST 4 ANIMATIONS - ALL USING SEQ
# ============================================

print("========================================");
print("TEST 4 MANDALA ANIMATIONS - ALL USING SEQ");
print("========================================");
print("");

print("=== 1. CLASSIC STYLE (WITH SEQ) ===");
print("Classic with seq for progressive rotation: Pi*nn/f");
MANDALA(30, "classic", 8, 1);

print("");
print("=== 2. ORIGINAL STYLE (WITH SEQ) ===");
print("With seq for symmetry: 12-fold");
MANDALA(30, "original", 12, 1);

print("");
print("=== 3. POWER FUNCTIONS (WITH NESTED SEQ) ===");
print("With nested seq for layers and symmetry");
MANDALA(25, "power", 8, 2);

print("");
print("=== 4. SINE WAVES (WITH NESTED SEQ) ===");
print("With nested seq for layers and symmetry");
MANDALA(20, "sine", 12, 3);

print("");
print("========================================");
print("NOW EVERYTHING USES SEQ!");
print("========================================");



 

1 2 3 4 5 6 7 Last Page 1 of 83