janhardo

850 Reputation

12 Badges

11 years, 245 days
B. Ed math

MaplePrimes Activity


These are answers submitted by janhardo

t := 5*Pi/9:
L := [-tan(4*Pi/9) + 4*sin(4*Pi/9)];
evalf~(L,20)[];

identify(-1.7320508075688772935);

A more practical approach ,well done..Maple, for recognizing a root form from the decimal form.

oneliner..( a long line ) 

toPrefix := e -> `if`(type(e,atomic), e,[op(0,e), seq(toPrefix(op(i,e)), i=1..nops(e))]):

ex := (a+b*c)^2:
toPrefix(ex);


exUltra :=
subs(a=b+c,
    expand(
        int(
            diff((x+y)^5*sin(exp(x^2+y^2)),x)
            /(1+sum(k*z^k,k=1..4)),
            x=0..1
        )
    )
):

toPrefix(exUltra );

exInsane :=
((f@g)@@3)(a+b*c)
+
(exp@@2)(sin@@3(x+y))
+
((a&*b)&+c)^5;

 exInsane := f(g(f(g(f(g(b c + a)))))) + @@(exp, 2)(@@(sin, 3))

                   5
    + (a &* b) &+ c 

toPrefix(exInsane );

A name is  a variable when there is a valued assigned to it. 


Used seq command here instead  a loop construction
Note: how fast the trees are growing :-) 

NULL

 

 

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

# Define the L-system generator
LGenerator := proc(n, Init, Angle0, Param, Rules, Color)
    local Iteration;
    
    # Use try-catch to avoid errors
    try
        if n = 0 then
            Iteration := Init;
        else
            Iteration := Iterate(Init, Rules, n);
        end if;
    catch:
        # If there's an error, use the initial string
        Iteration := Init;
    end try;
    
    # Draw the L-system
    LSystemPlot(
        Iteration,
        Param,
        initialangle = Angle0,
        color = Color,
        scaling = constrained,
        axes = none,
        thickness = 2
    );
end proc:

# First L-system (number 17)
Init17 := "X":
Angle17 := 90:

Param17 := [
  "F" = "draw:1",
  "+" = "turn:-25.7",
  "-" = "turn:25.7",
  "[" = "push:position;push:angle",
  "]" = "pop:position;pop:angle"
]:

Rules17 := [
  "F" = "FF",
  "X" = "F[+X][-X]FX"
]:

# Second L-system (number 18)
Init18 := "X":
Angle18 := 90:

Param18 := [
  "F" = "draw:1",
  "+" = "turn:20",
  "-" = "turn:-20",
  "[" = "push:position;push:angle",
  "]" = "pop:position;pop:angle"
]:

Rules18 := [
  "F" = "FF",
  "X" = "F[+X]F[-X]+X"
]:

# Test both L-systems without animation
print("L-system 17, iteration 4:");
display(LGenerator(4, Init17, Angle17, Param17, Rules17, "Red"));

print("L-system 18, iteration 4:");
display(LGenerator(4, Init18, Angle18, Param18, Rules18, "DarkGreen"));

# Create smoother animations with more frames
print("Smooth animation of L-system 17 (iterations 0-7):");
display([seq(LGenerator(i, Init17, Angle17, Param17, Rules17, "Red"), i = 0 .. 7)],
        insequence = true,
        frames = 64);  # More frames for smoother animation

print("Smooth animation of L-system 18 (iterations 0-7):");
display([seq(LGenerator(i, Init18, Angle18, Param18, Rules18, "DarkGreen"), i = 0 .. 7)],
        insequence = true,
        frames = 64);  # More frames for smoother animation

# Optional: Show all iterations side by side in a grid
print("All iterations of L-system 17 (0-7):");
display(Matrix(2, 4, [seq(LGenerator(i, Init17, Angle17, Param17, Rules17, "Red"), i = 0 .. 7)]));

print("All iterations of L-system 18 (0-7):");
display(Matrix(2, 4, [seq(LGenerator(i, Init18, Angle18, Param18, Rules18, "DarkGreen"), i = 0 .. 7)]));

# Even smoother version with interpolation (more iterations shown)
print("Extra smooth animation of L-system 17 (more frames):");
display([seq(LGenerator(i, Init17, Angle17, Param17, Rules17, "Red"), i = 0 .. 7)],
        insequence = true,
        frames = 128);  # Even more frames for extra smoothness

print("Extra smooth animation of L-system 18 (more frames):");
display([seq(LGenerator(i, Init18, Angle18, Param18, Rules18, "DarkGreen"), i = 0 .. 7)],
        insequence = true,
        frames = 128);

"L-system 17, iteration 4:"

 

 

"L-system 18, iteration 4:"

 

 

"Smooth animation of L-system 17 (iterations 0-7):"

 

 

"Smooth animation of L-system 18 (iterations 0-7):"

 

 

"All iterations of L-system 17 (0-7):"

 

 

 

 

 

 

 

"All iterations of L-system 18 (0-7):"

 

 

 

 

 

 

 

"Extra smooth animation of L-system 17 (more frames):"

 

 

"Extra smooth animation of L-system 18 (more frames):"

 

 

NULL


 

Download fractal_animatie_mprimes_26-1-2026.mw

@jalal 
Some experiment, but needs more thought 
I do need more math background/information for this figure in order to get this as a plot in Maple 

restart;
with(plots):

# parameters
p := 54.62;           # exponent
N := 120;             # number  rotaties
tmin := -1;
tmax := 1;

curves := []:

for k from 0 to N do
    theta := 2*Pi*k/N;

    x := t*cos(theta) - t^p*sin(theta);
    y := t*sin(theta) + t^p*cos(theta);

    curves := [op(curves),
        plot([x, y, t = tmin .. tmax],
             color = ColorTools:-Color([sin(theta)^2,
                                         cos(theta)^2,
                                         abs(sin(2*theta))]))];
end do:

display(curves,
        scaling = constrained,
        axes = none,
        background = white);

 

 

 

 

restart

with(PDEtools)

undeclare(prime, quiet)

declare(u(x, t), quiet); declare(U(xi), quiet); declare(V(xi), quiet); declare(Omega(x, t), quiet); declare(Q(x, t), quiet); declare(R(x, t), quiet)



# --- Symbols ---
declare(R(xi), phi(xi)):
#assume(alpha::real, beta::real, v::real):  ?????????????????

# --- Imaginary part Eq. (2.4) ---
ImEq :=
alpha*R(xi)*diff(phi(xi),xi$2)
+ 2*alpha*diff(R(xi),xi)*diff(phi(xi),xi)
- v*diff(R(xi),xi)
+ beta*(2*n+1)*R(xi)^(2*n)*diff(R(xi),xi):

# --- Chirp ansatz (Eq. 2.5) ---
phip  := eta_1*R(xi)^(2*n) + eta_2:
phipp := diff(phip, xi):

# --- Substitute ansatz ---
ImEq2 := subs(
  diff(phi(xi),xi)=phip,
  diff(phi(xi),xi$2)=phipp,
  ImEq
):

# --- Divide out R' ---
ImEq3 := factor(ImEq2/diff(R(xi),xi)):

# --- Helper symbol ---
Z := 'Z':
ImEq4 := subs(R(xi)^(2*n)=Z, ImEq3):

# --- Collect ---
C := collect(ImEq4, Z):

# --- Coefficients ---
C_Z := coeff(C, Z, 1):
C_0 := coeff(C, Z, 0):

# --- Solve ---
eta[1] := solve(C_Z = 0, eta_1);
eta[2] := solve(C_0 = 0, eta_2);

#eta1_sol, eta2_sol;

 

R(xi)*`will now be displayed as`*R

 

phi(xi)*`will now be displayed as`*phi

 

-(1/2)*beta*(2*n+1)/(alpha*(n+1))

 

(1/2)*v/alpha

(1.1)
 

``

Download chirped_parameter_eta1_eneta_2_mprimes_11-1-2026.mw

@salim-barzani 

HirotaTau :=
proc(N::posint, xi, A)
    local mu, f0, mus, muvals, f, i, j, mui, muval;

    # binaire variabelen mu[1]..mu[N]
    mu := array(1..N):

    # generieke subset-term
    f0 :=
    exp(
        add(mu[i]*xi[i], i=1..N)
      + add(
            add(mu[i]*mu[j]*ln(A[i,j]),
                i=1..j-1),
            j=1..N
        )
    );

    # alle binaire combinaties van mu (Gray code)
    mus := Iterator:-BinaryGrayCode(N);

    # vervangingen mu[i]=0/1
    muvals :=
    seq(
        { seq(mu[i], i=1..N) =~ seq(mui) },
        mui in mus
    );

    # subset-som
    f := add( eval(f0, muval), muval in muvals );

    return simplify(f);
end proc:

#restart;

N := 3:

xi := table():
A  := table():

f3 := HirotaTau(N, xi, A);

First doing by hand , to see where it goes wrong in the code : 
Step 3 is a vital one , but not easy to get , by knowing this 
A nightmare this 

# Step 1: Define original expression
expr := sqrt(4 - 2*y*(x + 1));

# Step 2: Expand the expression inside the root
expandedjd := expand(4 - 2*y*(x + 1));  # Gives -2 x y - 2 y + 4

# Step 3: Factor using symbolic simplification
factored := simplify(expandedjd, symbolic);  # Returns 2*(2 - y*(x + 1))

# Step 4: Apply the square root to the factored expression
root_factored := sqrt(factored);  # sqrt(2*(2 - y*(x + 1)))

# Step 5: Split the root into a product of square roots
split_root := sqrt(2)*sqrt(2 - y*(x + 1));

# Step 6: Verify equivalence
check := simplify(root_factored - split_root);  # Should return 0

Yes — for elliptic integrals of the second (and first) kind with real arguments, this is always true.
sin(x) never causes branching there; all branch information runs via cos(x). ( ai  ?) 
Turns out it has a very unique approach?
 

I don't know how to use all elliptic integrals to obtain the desired output by specifying conditions for the integral definitions.
That would need to be investigated, but is it now known for one elliptic integral, but not direct?

 

restart:
f := sqrt(1 + sin(x)^2);
F := int(f, x);
df := diff(F, x):
simplify(df - f);
simplify(df - f, symbolic);

restart;
f := sqrt(1 + sin(x)^2);
F := int(f, x);
F := simplify(F);
#F := simplify(F,symbolic);
df := diff(F, x);
assume(cos(x) > 0):
simplify(df - f);


 

piecewise(
  cos(x) > 0,  EllipticE(sin(x), I),
  cos(x) < 0, -EllipticE(sin(x), I)
);

restart:
f := sqrt(1 + sin(x)^2):
F := int(f, x);
df := diff(F, x);
simplify(df - f);  # ==> must be give  0 


Maybe too much ?
Showing a histogram plot for the 3 methods seperately is better ?
It is in build in maple ?

"maple.ini in user"

(1)

NULL

 

 

restart;
with(Student:-Calculus1):
with(plots):

f := x -> x^2;
a := -2;
b := 2;
exact := int(f(x), x = a..b);

# Compacte animatie
animate(
    n -> display(
        # Drie methodes
        RiemannSum(f(x), x = a..b, method = left, partition = trunc(n),
                  output = plot, caption = "", boxoptions = [filled = [color = "LightBlue"]]),
        RiemannSum(f(x), x = a..b, method = right, partition = trunc(n),
                  output = plot, caption = "", boxoptions = [filled = [color = "LightCoral"]]),
        RiemannSum(f(x), x = a..b, method = midpoint, partition = trunc(n),
                  output = plot, caption = "", boxoptions = [filled = [color = "LightGreen"]]),
        
        # Functie
        plot(f(x), x = a..b, color = "Black", thickness = 2),
        
        # Info
        title = typeset("Riemann Methods: n=", trunc(n),
                       ", Exact=", evalf[5](exact)),
        view = [a..b, -0.2..4.5]
    ),
    [n],
    n = 1..150,
    frames = 25,
    size = [1000, 400]
);

"maple.ini in user"

 

proc (x) options operator, arrow; x^2 end proc

 

-2

 

2

 

16/3

 

 

NULL

 

 

restart;
with(Student:-Calculus1):
with(plots):

f := x -> x^2;
a := -2;
b := 2;
exact := evalf(int(f(x), x = a..b));

# CLEAR VISUALIZATION: Three separate plots side by side
animate(
    n -> display(
        Array([
            # COLUMN 1: LEFT ENDPOINT METHOD
            display(
                RiemannSum(f(x), x = a..b, method = left, partition = trunc(n),
                          output = plot, caption = "",
                          boxoptions = [filled = [color = "Blue", transparency = 0.6]]),
                plot(f(x), x = a..b, color = "Black", thickness = 2),
                title = typeset("LEFT ENDPOINT METHOD\n",
                               "Uses: f(x₋₁₎) at LEFT of each interval\n",
                               "Approximation: ",
                               evalf[5](RiemannSum(f(x), x=a..b, method=left, partition=trunc(n)))),
                view = [a..b, -0.5..4.5]
            ),
            
            # COLUMN 2: RIGHT ENDPOINT METHOD
            display(
                RiemannSum(f(x), x = a..b, method = right, partition = trunc(n),
                          output = plot, caption = "",
                          boxoptions = [filled = [color = "Red", transparency = 0.6]]),
                plot(f(x), x = a..b, color = "Black", thickness = 2),
                title = typeset("RIGHT ENDPOINT METHOD\n",
                               "Uses: f(xᵢ) at RIGHT of each interval\n",
                               "Approximation: ",
                               evalf[5](RiemannSum(f(x), x=a..b, method=right, partition=trunc(n)))),
                view = [a..b, -0.5..4.5]
            ),
            
            # COLUMN 3: MIDPOINT METHOD
            display(
                RiemannSum(f(x), x = a..b, method = midpoint, partition = trunc(n),
                          output = plot, caption = "",
                          boxoptions = [filled = [color = "Green", transparency = 0.6]]),
                plot(f(x), x = a..b, color = "Black", thickness = 2),
                title = typeset("MIDPOINT METHOD\n",
                               "Uses: f((x₋₁₎+xᵢ)/2) at MIDDLE of each interval\n",
                               "Approximation: ",
                               evalf[5](RiemannSum(f(x), x=a..b, method=midpoint, partition=trunc(n)))),
                view = [a..b, -0.5..4.5]
            )
        ]),
        title = typeset("VISUAL COMPARISON OF RIEMANN SUM METHODS\n",
                       "f(x) = x² on [", a, ", ", b, "] | n = ", trunc(n),
                       " partitions | Δx = ", evalf[5]((b-a)/trunc(n)),
                       " | Exact integral = ", evalf[5](exact)),
        size = [1200, 450]
    ),
    [n],
    n = 1..50,
    frames = 25,
    paraminfo = false
);

"maple.ini in user"

 

proc (x) options operator, arrow; x^2 end proc

 

-2

 

2

 

5.333333333

 

 

 

 

 

 

 

 

NULL


 

Download riemann_som_mprimes_DEF_22-12-2025.mw

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