janhardo

840 Reputation

12 Badges

11 years, 238 days
B. Ed math

MaplePrimes Activity


These are replies submitted by janhardo

@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("========================================");



 

@acer ,I think the AI is crazy about loops, given my coding experience, and I don't immediately think of the seq command.
AI coding only becomes powerful when you really understand Maple coding.
I'll see if the code can be improved with the help of programming other than standard loop programming, at least if I understand correctly?

Indeed, I used Kitonum's ingenious approach of two exponential functions, which are each other's inverse, and rotate them.

restart;
with(plots): with(plottools):

# ============================================
# 1. DE ORIGINELE MANDALA (EXACT JOUW CODE)
# ============================================

ORIGINELE_MANDALA := proc()
    local Colors, P, n;
    
    Colors := [seq(op(["LightBlue","Indigo","Violet","Red","Orange","Yellow","Green"]), n=1..14)];
    
    P := proc(n)
        uses plots, plottools;
        display(rotate(plot([x^(1+0.1*(n-1)), x^(1/(1+0.1*(n-1)))], 
                           x=0..1, 
                           thickness=5, 
                           color=Colors[round(n)], 
                           transparency=0.4),
                       Pi*n/98, 
                       [0.5,0.5]));
    end proc:
    
    plots:-animate(P, [n], n=1..98, frames=98, trace=[$1..98], 
                   axes=none, size=[700,700], paraminfo=false);
end proc:

# ============================================
# 2. UNIVERSELE MANDALA MAKER - EENVOUDIG
# ============================================

MANDALA := proc(f, soort, sym, lagen)
    # f = aantal frames
    # soort = "origineel", "macht", of "sinus"
    # sym = symmetrie (6, 8, 12, etc.)
    # lagen = aantal lagen (1-5)
    
    local P, n, i, j, trace_lst;
    
    # Maak trace lijst
    trace_lst := [seq(i, i=1..f)];
    
    if soort = "origineel" then
        # Originele stijl
        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 plotje, kleur_idx, exponent_val;
            
            kleur_idx := round(nn);
            if kleur_idx < 1 then kleur_idx := 1;
            elif kleur_idx > f then kleur_idx := f; end if;
            
            exponent_val := 1 + 0.1*(nn-1);
            
            plotje := plot([x^exponent_val, x^(1/exponent_val)], 
                          x=0..1,
                          thickness=3,
                          color=Colors2[kleur_idx],
                          transparency=0.4);
            
            # Symmetrie toevoegen
            local result := plotje;
            for i from 1 to sym-1 do
                result := result, rotate(plotje, 2*Pi*i/sym, [0.5,0.5]);
            end do;
            
            return display(result, axes=none);
        end proc;
        
    elif soort = "macht" then
        # Macht functies
        P := proc(nn)
            local t_val, exp_val, plotje, kleur;
            
            t_val := (nn-1.0)/(f-1.0);
            exp_val := 0.5 + 4.5*t_val;
            kleur := COLOR(HUE, t_val);
            
            plotje := plot([x^exp_val, x^(1/exp_val)], 
                          x=0..1,
                          thickness=2,
                          color=kleur,
                          transparency=0.3);
            
            # Lagen en symmetrie toevoegen
            local result := NULL;
            for i from 1 to lagen do
                for j from 0 to sym-1 do
                    result := result, 
                        rotate(plotje, Pi*nn/f + 2*Pi*j/sym + (i-1)*Pi/(lagen*2), [0.5,0.5]);
                end do;
            end do;
            
            return display(result, axes=none);
        end proc;
        
    elif soort = "sinus" then
        # Sinus golven
        P := proc(nn)
            local t_val, freq_val, plotje, kleur;
            
            t_val := (nn-1.0)/(f-1.0);
            freq_val := 1 + 9*t_val;
            kleur := COLOR(HUE, t_val);
            
            plotje := 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=kleur,
                          transparency=0.3);
            
            # Lagen en symmetrie toevoegen
            local result := NULL;
            for i from 1 to lagen do
                for j from 0 to sym-1 do
                    result := result, 
                        rotate(plotje, Pi*nn/f + 2*Pi*j/sym + (i-1)*Pi/(lagen*2), [0.5,0.5]);
                end do;
            end do;
            
            return display(result, axes=none);
        end proc;
        
    else
        # Default: macht functies
        P := proc(nn)
            local t_val, exp_val, plotje, kleur;
            
            t_val := (nn-1.0)/(f-1.0);
            exp_val := 0.5 + 4.5*t_val;
            kleur := COLOR(HUE, t_val);
            
            plotje := plot([x^exp_val, x^(1/exp_val)], 
                          x=0..1,
                          thickness=2,
                          color=kleur,
                          transparency=0.3);
            
            # Lagen en symmetrie toevoegen
            local result := NULL;
            for i from 1 to lagen do
                for j from 0 to sym-1 do
                    result := result, 
                        rotate(plotje, Pi*nn/f + 2*Pi*j/sym + (i-1)*Pi/(lagen*2), [0.5,0.5]);
                end do;
            end do;
            
            return display(result, axes=none);
        end proc;
    end if;
    
    # Maak de animatie
    animate(P, [n], n=1..f, frames=f,
            trace=trace_lst,
            axes=none,
            size=[500,500],
            paraminfo=false);
end proc:

# ============================================
# 3. TESTEN - BEGIN MET ORIGINEEL
# ============================================

print("=== TEST 1: ORIGINELE MANDALA ===");
ORIGINELE_MANDALA();

# Wacht even voordat we verder gaan
# (In Maple kun je niet echt wachten, maar we printen een bericht)
print("Originele mandala wordt geladen... (klik op play in de plot)");

# ============================================
# 4. KLEINERE VOORBEELDEN
# ============================================

print("=== TEST 2: ORIGINELE STIJL (kleiner) ===");
MANDALA(30, "origineel", 12, 1);

print("=== TEST 3: MACHT MANDALA ===");
MANDALA(25, "macht", 8, 2);

print("=== TEST 4: SINUS MANDALA ===");
MANDALA(20, "sinus", 12, 3);

# ============================================
# 5. SIMPELE GEBRUIKERSFUNCTIES
# ============================================

# Voor snel gebruik
SNEL_MANDALA := proc()
    MANDALA(20, "macht", 8, 2);
end proc:

# Origineel maar kleiner
KLEIN_ORIGINEEL := proc()
    MANDALA(40, "origineel", 12, 1);
end proc:

# Sinus effect
SINUS_EFFECT := proc()
    MANDALA(30, "sinus", 10, 2);
end proc:

# ============================================
# 6. DEMO
# ============================================

DEMO := proc()
    print("=== MANDALA DEMO ===");
    
    print("1. Origineel (klein)");
    MANDALA(15, "origineel", 8, 1);
    
    print("2. Macht functies");
    MANDALA(15, "macht", 12, 2);
    
    print("3. Sinus golven");
    MANDALA(15, "sinus", 10, 3);
    
    print("=== DEMO KLAAR ===");
end proc:

# ============================================
# 7. START HIER!
# ============================================

print("=== START MET ORIGINELE MANDALA ===");
ORIGINELE_MANDALA();

print("=== DAARNA PROBEER DIT: ===");
print("1. Voor snelle test: SNEL_MANDALA();");
print("2. Voor origineel kleiner: KLEIN_ORIGINEEL();");
print("3. Voor sinus: SINUS_EFFECT();");
print("4. Voor volledige demo: DEMO();");

 

Its not yet similar :-)

@Jean-Michel 

Take another look, but I'm afraid Maple won't be able to achieve the same effect in MMA.

bye
Jan

@Jean-Michel 
I am a dutch , from the Netherlands, yeah :-) 
But what is the intention of you examples ?
Tip:  for better reading your code use : the insert code snippet knob - right next  A , use tooltip too

Try to do something now with the Head construction from MMA and this apply in Maple ?

@Jean-Michel 

I tried to extend the module code with this new expression, but it appears to be impossible to obtain the same result in Maple.

.

# Debug versie - show all found paths
N := [a, a, 1 + a, [[1/a] + a^2, [a]]]:
result := FindPositions:-ModuleApply(N, a, 'explain'=true);
Expression: [a, a, 1+a, [[1/a]+a^2, [a]]]
Looking for: a
Levelspec: infinity
Found at 6 position(s):
1. Path [1]
2. Path [2]
3. Path [3, 2]
4. Path [4, 1, 1, 1, 1]
5. Path [4, 1, 2, 1]
6. Path [4, 2, 1]

  result := [[1], [2], [3, 2], [4, 1, 1, 1, 1], [4, 1, 2, 1], 

    [4, 2, 1]]
1 2 3 4 5 6 7 Last Page 1 of 82