janhardo

930 Reputation

13 Badges

11 years, 328 days
B. Ed math

MaplePrimes Activity


These are replies submitted by janhardo

@Harry Garst 

You try to check rule 7 ...
I used the Kron notation, easier to read

Download vraag-_Is_this_correct_mprimes_3-5-2026.mw


 

 

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

# ------------------------------------------------------------
# 1. PRINT THE MATHEMATICAL DERIVATION
# ------------------------------------------------------------
print("Why does stacking these triangles produce a logarithmic spiral?");
print("Definition: Z(0) = 8, Z(1) = 8*(1/4 + I*sqrt(3)/4) = 2+2*I*sqrt(3)");
print("Recurrence: Z(n) = Z(n-1) * (1/4 + I*sqrt(3)/4)");
print("Modulus of the factor = 1/2, argument = Pi/3 (60°)");
print("So |Z(n)| = 8*(1/2)^n, arg(Z(n)) = n*Pi/3");
print("In polar coordinates: r = 8*(1/2)^n, theta = n*Pi/3");
print("Eliminate n: n = 3*theta/Pi -> r = 8*exp(-(3*ln(2)/Pi)*theta)");
print("This is a logarithmic spiral. The vertices Z(n) lie exactly on this spiral.\n");

# ------------------------------------------------------------
# 2. DEFINE THE COMPLEX VERTICES Z(n)
# ------------------------------------------------------------
Z := n -> evalf(8 * (1/4 + I*sqrt(3)/4)^n):   # numeric values for plotting

# ------------------------------------------------------------
# 3. PLOT THE LOGARITHMIC SPIRAL (red, thick) through the vertices
# ------------------------------------------------------------
r0 := 8: b := -3*ln(2)/Pi:
spiral := polarplot(r0*exp(b*theta), theta=0..8*Pi,
                    color="Red", thickness=3, scaling=constrained,
                    axes=boxed, labels=["Re(z)", "Im(z)"]):
# ------------------------------------------------------------
# 4. PREPARE THE TRIANGLES (original definition, animated)
# ------------------------------------------------------------
Triangle := i -> polygon([[0,0], [Re(Z(i-1)), Im(Z(i-1))], [Re(Z(i)), Im(Z(i))]]):

frame := proc(n::posint)
    local i, colors;
    colors := ["Red","Green","Blue","Yellow","Magenta","Cyan"];
    display(seq(Triangle(i), i=1..n),
            color=[seq(colors[(i-1 mod 6)+1], i=1..n)],
            transparency=0.5);   # semi-transparent to see the spiral
end proc:

# Create the animation (first 6 frames)
animation := display(seq(frame(i), i=1..6), insequence, scaling=constrained):

# ------------------------------------------------------------
# 5. PLOT THE VERTICES AS BLACK DOTS (to show they lie on the spiral)
# ------------------------------------------------------------
vertices := [seq([Re(Z(n)), Im(Z(n))], n=0..6)]:
vertex_plot := pointplot(vertices, symbol=solidcircle, symbolsize=7, color="Green"):

# ------------------------------------------------------------
# 6. COMBINE EVERYTHING IN A LARGE DISPLAY
# ------------------------------------------------------------
final_plot := display(animation, spiral, vertex_plot,
                      scaling=constrained, size=[1800,900],
                      title="Logarithmic spiral through the vertices of stacked triangles",
                      titlefont=[Times,16]):

# Show the final plot
final_plot;

"Why does stacking these triangles produce a logarithmic spiral?"

 

"Definition: Z(0) = 8, Z(1) = 8*(1/4 + I*sqrt(3)/4) = 2+2*I*sqrt(3)"

 

"Recurrence: Z(n) = Z(n-1) * (1/4 + I*sqrt(3)/4)"

 

"Modulus of the factor = 1/2, argument = Pi/3 (60°)"

 

"So |Z(n)| = 8*(1/2)^n, arg(Z(n)) = n*Pi/3"

 

"In polar coordinates: r = 8*(1/2)^n, theta = n*Pi/3"

 

"Eliminate n: n = 3*theta/Pi -> r = 8*exp(-(3*ln(2)/Pi)*theta)"

 

"This is a logarithmic spiral. The vertices Z(n) lie exactly on this spiral.
"

 

 

 

 


 

Download logaritmic_spiral_in_complex_planeDEF_3-5-2026.mw

@C_R 

Interesting, thanks for  geodesics_AI.mw

@Harry Garst 
Ja , en hopelijk kan je er iets mee met de module code :-)
Nog wat verder uitbreiden met nieuwe regels 
groet Jan

@janhardo 
Testing commando's 
Performance test.comparison, seems to be quick with the module

with(LinearAlgebra):

# matrix size (adjust as needed!)
n := 40:

# random matrices
A := RandomMatrix(n,n, generator=-5..5):
B := RandomMatrix(n,n, generator=-5..5):
C := RandomMatrix(n,n, generator=-5..5):
d := RandomMatrix(n,n, generator=-5..5):

# ---------- 1. Naive method ----------
t1 := time():

K1 := KroneckerProduct(A,B):
K2 := KroneckerProduct(C,d):
R1 := K1 . K2:

t_naive := time() - t1:

# ---------- 2. Smart method (KRON7) ----------
t2 := time():

R2 := KroneckerProduct(A . C, B . d):

t_smart := time() - t2:

# ---------- Results ----------
printf("Naive time  = %.4f sec\n", t_naive);
printf("Smart time  = %.4f sec\n", t_smart);
printf("Speedup(faster)     = %.2f x\n", t_naive / t_smart);

# ---------- Verification ----------
printf("Equal? %a\n", Equal(R1, R2));
Naive time  = 244.7970 sec
Smart time  = 1.2500 sec
Speedup(faster)     = 195.84 x
Equal? true

restart;
with(LinearAlgebra):
ZehfussReplace := proc(expr::uneval)
    uses LinearAlgebra:
    local replace;
    replace := proc(det)
        local kr_args, A, B;
        kr_args := op(1, det);
        if not type(kr_args, specfunc(KroneckerProduct)) then return eval(det) end if;
        A := op(1, kr_args);
        B := op(2, kr_args);
        'Determinant'(A)^(RowDimension(B)) * 'Determinant'(B)^(RowDimension(A));
    end proc;
    subsindets(expr, specfunc(specfunc(KroneckerProduct), Determinant), replace);
end proc:

A := Matrix(2,2,symbol=a);
B := Matrix(3,3,symbol=b);

# Important: call the procedure directly with the unevaluated form
result := ZehfussReplace( Determinant(KroneckerProduct(A,B)) + 2*Determinant(KroneckerProduct(A,A)) );
# print(result);
  eval(result);

Matrix(2, 2, {(1, 1) = a[1, 1], (1, 2) = a[1, 2], (2, 1) = a[2, 1], (2, 2) = a[2, 2]})

 

Matrix(%id = 36893490552170632124)

 

LinearAlgebra:-Determinant(A)^3*LinearAlgebra:-Determinant(B)^2+2*LinearAlgebra:-Determinant(A)^4

 

(a[1, 1]*a[2, 2]-a[1, 2]*a[2, 1])^3*(b[1, 1]*b[2, 2]*b[3, 3]-b[1, 1]*b[2, 3]*b[3, 2]-b[1, 2]*b[2, 1]*b[3, 3]+b[1, 2]*b[2, 3]*b[3, 1]+b[1, 3]*b[2, 1]*b[3, 2]-b[1, 3]*b[2, 2]*b[3, 1])^2+2*(a[1, 1]*a[2, 2]-a[1, 2]*a[2, 1])^4

(1)
 

 

Download Zehfuss_-kronecker_determinant__mprimes_22-4-2026.mw

@Harry Garst 

It doesn't seem necessary to use two variables.

These are two ways of describing the same variable..

Apparently, the expression hold for all n =1.. 2
proof by induction further

 

Of all closed surfaces in space with a fixed surface area A​, which surface encloses the largest volume?

But there are two variables in the functional here.

a good example to to do by hand...

Via differential geometry 
 

 

 

 

restart;
Typesetting:-Settings(typesetdot=true);

printf("================================================================\n");
printf("ISOPERIMETRIC PROBLEM: Maximize area for fixed perimeter\n");
printf("================================================================\n\n");
printf("Goal: Prove that the optimal closed curve is a circle.\n");
printf("We do this by showing that its curvature must be constant.\n\n");

# Step 1: Lagrangian
F := x(t)*diff(y(t),t) + lambda*sqrt(diff(x(t),t)^2 + diff(y(t),t)^2);
printf("Step 1: Lagrangian F = %a\n\n", F);

# Step 2: Euler-Lagrange equations
printf("Step 2: Euler-Lagrange equations\n");
EL1 := diff(Physics:-diff(F, diff(x(t),t)), t) - Physics:-diff(F, x(t)) = 0;
EL2 := diff(Physics:-diff(F, diff(y(t),t)), t) - Physics:-diff(F, y(t)) = 0;
printf("EL1: %a\n", EL1);
printf("EL2: %a\n\n", EL2);

# Step 3: First integrals (integrate once)
printf("Step 3: First integrals\n");
eq1 := lambda*diff(x(t),t)/sqrt(diff(x(t),t)^2+diff(y(t),t)^2) = y(t) + C1;
eq2 := x(t) + lambda*diff(y(t),t)/sqrt(diff(x(t),t)^2+diff(y(t),t)^2) = C2;
printf("First integral I:  %a\n", eq1);
printf("First integral II: %a\n\n", eq2);

# Step 4: Switch to arc length parameter s
printf("Step 4: Arc length parametrization (ds/dt = sqrt(x'^2+y'^2))\n");
printf("Then dx/ds = x'/(ds/dt), dy/ds = y'/(ds/dt)\n");
printf("The first integrals become:\n");
printf("   lambda * dx/ds = y + C1      (A)\n");
printf("   lambda * dy/ds = C2 - x      (B)\n\n");

# Step 5: Compute curvature explicitly
printf("Step 5: Curvature calculation\n");
printf("For a plane curve, curvature kappa = (dx/ds)*(d^2y/ds^2) - (dy/ds)*(d^2x/ds^2)\n");
printf("From (A) and (B) we obtain:\n");

dx_ds := (y + C1)/lambda;
dy_ds := (C2 - x)/lambda;
printf("   dx/ds = %a\n", dx_ds);
printf("   dy/ds = %a\n", dy_ds);

d2x_ds2 := (C2 - x)/lambda^2;
d2y_ds2 := -(y + C1)/lambda^2;
printf("   d^2x/ds^2 = %a\n", d2x_ds2);
printf("   d^2y/ds^2 = %a\n\n", d2y_ds2);

kappa := dx_ds * d2y_ds2 - dy_ds * d2x_ds2;
kappa_expanded := expand(kappa);
printf("Substituting into the curvature formula and expanding:\n");
printf("   kappa = %a\n", kappa_expanded);
printf("Thus kappa = -(C2-x)^2/lambda^3 - (y+C1)^2/lambda^3\n\n");

# Step 6: Use the arc length normalization
printf("Step 6: Arc length normalization\n");
printf("Since (dx/ds)^2 + (dy/ds)^2 = 1, from (A) and (B):\n");
printf("   ((y+C1)/lambda)^2 + ((C2-x)/lambda)^2 = 1\n");
printf("   => (y+C1)^2 + (C2-x)^2 = lambda^2\n");
norm_eq := (y+C1)^2 + (C2-x)^2 = lambda^2;
printf("Hence: %a\n\n", norm_eq);

# Compact simplification of kappa_final
printf("Step 6a: Compact simplification of curvature\n");
# Substitute the sum directly
kappa_final := algsubs((y+C1)^2+(C2-x)^2 = lambda^2, kappa_expanded);
printf("   kappa = %a\n", kappa_final);
printf("Therefore the curvature is constant: kappa = -1/lambda.\n");
printf("This proves that the optimal curve has constant curvature.\n\n");

# Step 7: Conclusion – circle
printf("Step 7: Conclusion\n");
printf("A plane curve with constant nonzero curvature is an arc of a circle.\n");
printf("Since the curve is closed and smooth, it must be a full circle.\n");
printf("The radius is R = |lambda|, and the center is (C2, -C1).\n");
printf("Thus the optimal shape is a circle.\n\n");

# Step 8: Example plot
printf("Step 8: Example plot (lambda=1, C1=0, C2=0)\n");
lambda_val := 1; C1_val := 0; C2_val := 0; phi := 0;
x_circ := t -> C2_val + lambda_val*cos(2*Pi*t + phi);
y_circ := t -> -C1_val + lambda_val*sin(2*Pi*t + phi);
plot([x_circ(t), y_circ(t), t=0..1], scaling=constrained,
     title="Optimal closed curve: circle", labels=["x","y"],
     color=blue, thickness=2);
printf("Plot displayed.\n");

false

 

================================================================
ISOPERIMETRIC PROBLEM: Maximize area for fixed perimeter
================================================================

Goal: Prove that the optimal closed curve is a circle.
We do this by showing that its curvature must be constant.

 

 

x(t)*(diff(y(t), t))+lambda*((diff(x(t), t))^2+(diff(y(t), t))^2)^(1/2)

 

Step 1: Lagrangian F = x(t)*diff(y(t),t)+lambda*(diff(x(t),t)^2+diff(y(t),t)^2)^(1/2)

Step 2: Euler-Lagrange equations

 

-(1/2)*lambda*(diff(x(t), t))*(2*(diff(x(t), t))*(diff(diff(x(t), t), t))+2*(diff(y(t), t))*(diff(diff(y(t), t), t)))/((diff(x(t), t))^2+(diff(y(t), t))^2)^(3/2)+lambda*(diff(diff(x(t), t), t))/((diff(x(t), t))^2+(diff(y(t), t))^2)^(1/2)-(diff(y(t), t)) = 0

 

diff(x(t), t)-(1/2)*lambda*(diff(y(t), t))*(2*(diff(x(t), t))*(diff(diff(x(t), t), t))+2*(diff(y(t), t))*(diff(diff(y(t), t), t)))/((diff(x(t), t))^2+(diff(y(t), t))^2)^(3/2)+lambda*(diff(diff(y(t), t), t))/((diff(x(t), t))^2+(diff(y(t), t))^2)^(1/2) = 0

 

EL1: -1/2*lambda/(diff(x(t),t)^2+diff(y(t),t)^2)^(3/2)*diff(x(t),t)*(2*diff(x(t),t)*diff(diff(x(t),t),t)+2*diff(y(t),t)*diff(diff(y(t),t),t))+lambda/(diff(x(t),t)^2+diff(y(t),t)^2)^(1/2)*diff(diff(x(t),t),t)-diff(y(t),t) = 0
EL2: diff(x(t),t)-1/2*lambda/(diff(x(t),t)^2+diff(y(t),t)^2)^(3/2)*diff(y(t),t)*(2*diff(x(t),t)*diff(diff(x(t),t),t)+2*diff(y(t),t)*diff(diff(y(t),t),t))+lambda/(diff(x(t),t)^2+diff(y(t),t)^2)^(1/2)*diff(diff(y(t),t),t) = 0

Step 3: First integrals

 

lambda*(diff(x(t), t))/((diff(x(t), t))^2+(diff(y(t), t))^2)^(1/2) = y(t)+C1

 

x(t)+lambda*(diff(y(t), t))/((diff(x(t), t))^2+(diff(y(t), t))^2)^(1/2) = C2

 

First integral I:  lambda/(diff(x(t),t)^2+diff(y(t),t)^2)^(1/2)*diff(x(t),t) = y(t)+C1
First integral II: x(t)+lambda/(diff(x(t),t)^2+diff(y(t),t)^2)^(1/2)*diff(y(t),t) = C2

Step 4: Arc length parametrization (ds/dt = sqrt(x'^2+y'^2))
Then dx/ds = x'/(ds/dt), dy/ds = y'/(ds/dt)
The first integrals become:
   lambda * dx/ds = y + C1      (A)
   lambda * dy/ds = C2 - x      (B)

Step 5: Curvature calculation
For a plane curve, curvature kappa = (dx/ds)*(d^2y/ds^2) - (dy/ds)*(d^2x/ds^2)
From (A) and (B) we obtain:

 

(y+C1)/lambda

 

(C2-x)/lambda

 

   dx/ds = (y+C1)/lambda
   dy/ds = (C2-x)/lambda

 

(C2-x)/lambda^2

 

-(y+C1)/lambda^2

 

   d^2x/ds^2 = (C2-x)/lambda^2
   d^2y/ds^2 = -(y+C1)/lambda^2

 

 

-(C2-x)^2/lambda^3-(y+C1)^2/lambda^3

 

-C2^2/lambda^3+2*C2*x/lambda^3-x^2/lambda^3-C1^2/lambda^3-2*y*C1/lambda^3-y^2/lambda^3

 

Substituting into the curvature formula and expanding:
   kappa = -1/lambda^3*C2^2+2/lambda^3*C2*x-1/lambda^3*x^2-1/lambda^3*C1^2-2/lambda^3*y*C1-1/lambda^3*y^2
Thus kappa = -(C2-x)^2/lambda^3 - (y+C1)^2/lambda^3

Step 6: Arc length normalization
Since (dx/ds)^2 + (dy/ds)^2 = 1, from (A) and (B):
   ((y+C1)/lambda)^2 + ((C2-x)/lambda)^2 = 1
   => (y+C1)^2 + (C2-x)^2 = lambda^2

 

(y+C1)^2+(C2-x)^2 = lambda^2

 

Hence: (y+C1)^2+(C2-x)^2 = lambda^2

Step 6a: Compact simplification of curvature

 

-1/lambda

 

   kappa = -1/lambda
Therefore the curvature is constant: kappa = -1/lambda.
This proves that the optimal curve has constant curvature.

Step 7: Conclusion
A plane curve with constant nonzero curvature is an arc of a circle.
Since the curve is closed and smooth, it must be a full circle.
The radius is R = |lambda|, and the center is (C2, -C1).
Thus the optimal shape is a circle.

Step 8: Example plot (lambda=1, C1=0, C2=0)

 

1

 

0

 

0

 

0

 

proc (t) options operator, arrow; C2_val+lambda_val*cos(2*Pi*t+phi) end proc

 

proc (t) options operator, arrow; -C1_val+lambda_val*sin(2*Pi*t+phi) end proc

 

 

Plot displayed.

 

 

via vectorcalculus 
bewijs_cirkel_gesloten_cvorm_viavectot_calculus_mprimes_20-4-2026.mw

Download bewijs_cirkel_gesloten_cvorm_via_diff_geom_mprimes_20-4-2026.mw

@Rouben Rostamian  
 

Thanks for your educational code , yes, this circle is a  interesting example . I had actually seen another derivation involving the curvature of the circle, but that leads into vector calculus and differential geometry, which require more advanced knowledge.

It’s also instructive to see different approaches to solving the problem.

Of all closed curves with a fixed length L, which curve encloses the largest area?

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