janhardo

700 Reputation

12 Badges

11 years, 59 days

MaplePrimes Activity


These are replies submitted by janhardo

Is this old package to download somewhere ?, thanks.

sys := [PDE1, PDE2, PDE3, PDE4]:
infolevel[rifsimp]:=3
                    infolevel[rifsimp] := 3

rif := rifsimp(sys, [[w], [z]], indep = [x,y]);
Well done your programming...

restart;

# Load required packages
with(plots): 
with(geometry):

Fig := proc(t)
    local a, b, c, A, B, C, Oo, P, NorA, NorB, NorC, locus, Locus, dr, tx, p, points_coords, points_plot;

    # Constants
    a := 11; 
    b := 7;
    c := sqrt(a^2 - b^2);

    # Define points on the ellipse
    point(A, [a*cos(t), b*sin(t)]):
    point(B, [a*cos(t + 2/3*Pi), b*sin(t + 2/3*Pi)]):
    point(C, [a*cos(t + 4/3*Pi), b*sin(t + 4/3*Pi)]):
    point(Oo, [0,0]):

    # Equation of the locus
    locus := a^2*x^2 + b^2*y^2 - c^4/4 = 0:
    Locus := implicitplot(locus, x = -a .. a, y = -b .. b, color = green):

    # Correct definition of lines
    line(NorA, y - coordinates(A)[2] = ((a^2 * coordinates(A)[2])/(b^2 * coordinates(A)[1]))*(x - coordinates(A)[1]), [x, y]):
    line(NorB, y - coordinates(B)[2] = ((a^2 * coordinates(B)[2])/(b^2 * coordinates(B)[1]))*(x - coordinates(B)[1]), [x, y]):
    line(NorC, y - coordinates(C)[2] = ((a^2 * coordinates(C)[2])/(b^2 * coordinates(C)[1]))*(x - coordinates(C)[1]), [x, y]):

    # Intersection of lines NorA and NorB (the centroid)
    intersection(P, NorA, NorB):

    # Draw ellipse
    p := implicitplot(x^2/a^2 + y^2/b^2 - 1, x = -a .. a, y = -b .. b, color = blue):

    # Text labels
    tx := textplot([
        [coordinates(A)[], "A"],
        [coordinates(B)[], "B"],
        [coordinates(C)[], "C"],
        [coordinates(Oo)[], "O"],
        [coordinates(P)[], "P"]
    ], font = [times, bold, 16], align = [above, left]):

    # Convert geometry lines and points to plot structures
    points_coords := [coordinates(A), coordinates(B), coordinates(C), coordinates(Oo), coordinates(P)]:
    points_plot := pointplot(points_coords, symbol = solidcircle, symbolsize = 8, color = black):

    # Graphical display
    dr := display([
        p, 
        draw(NorA, color=red), draw(NorB, color=red), draw(NorC, color=red), 
        points_plot,
        Locus
    ]):

    return display(dr, tx, scaling=constrained, axes=none, 
        title = "Les triangles inscrits dans une ellipse ont leur centre de gravité en son centre. Lieu du point de concours des perpendiculaires issues des sommets/
                 Triangles inscribed in an ellipse have their centroid at its center. Locus of the intersection point of perpendiculars from the vertices", 
        titlefont = [HELVETICA, 14]):
end proc:

# Animate the figure
plots:-animate(Fig, [t], t=0.1..2*Pi, frames=150);

variants


 

restart;
 

 

H := proc(expr, S) local K,SS,temp;
  K := typefunc(identical(S[]),name);
  SS := freeze~(indets(expr, K)) union S;
  temp := subsindets(expr, K, freeze);
  ormap(s->type(expr, linear(s)), SS)
   and
  andmap(s->type(temp, And(polynom(anything,s),
                           satisfies(t->degree(t,s)<2))), SS);
end proc:
 

H := proc(expr, S)
  local K, SS, temp;
  
  K := typefunc(identical(S[]), name);  # Bepaal de variabelen in S
  SS := indets(expr, K) union S;        # Alle relevante variabelen
  SS := freeze~(SS);                    # Optimaliseer door alles in één keer te "freezen"
  
  temp := subsindets(expr, K, freeze);   # Bevroren versie van de expressie
  
  return ormap(s -> type(expr, linear(s)), SS)
          and andmap(s -> type(temp, And(polynom(anything, s), satisfies(t -> degree(t, s) < 2))), SS);
end proc:

 

H := proc(expr, S)
  local SS, temp;
  SS := freeze~(indets(expr, typefunc(identical(S[]), name)) union S);
  temp := subsindets(expr, typefunc(identical(S[]), name), freeze);
  return ormap(s -> type(expr, linear(s)), SS)
         and andmap(s -> type(temp, polynom(anything, s)) and degree(temp, s) < 2, SS);
end proc:
 

H := proc(expr, S)
  local SS := freeze~(indets(expr, typefunc(identical(S[]), name)) union S);
  return ormap(s -> type(expr, linear(s)), SS)
         and andmap(s -> type(subsindets(expr, typefunc(identical(S[]), name), freeze), polynom(anything, s))
         and degree(subsindets(expr, typefunc(identical(S[]), name), freeze), s) < 2, SS);
end proc:
 

H := (e, S) -> ormap(s -> type(e, linear(s)), freeze~(indets(e, typefunc(identical(S[]), name)) union S))
       and andmap(s -> type(subsindets(e, typefunc(identical(S[]), name), freeze), polynom(anything, s))
       and degree(subsindets(e, typefunc(identical(S[]), name), freeze), s) < 2,
       freeze~(indets(e, typefunc(identical(S[]), name)) union S)):

 

H( a*f(X1, X2)*g(X4) + b*X3*g(X4) + c*X1 + d*X1*X2,
   {X1,X2,X3,X4} );
                             
H( a*b + c,
   {X1,X2,X3,X4} );
                             

H( a*f(X1, X2)*g(X4)^2 + b*X3*g(X4) + c*X1 + d*X1*X2,
   {X1,X2,X3,X4} );
                            

H( a*f(X1, X2)*g(X4) + b*X3^4*g(X4) + c*X1 + d*X1*X2,
   {X1,X2,X3,X4} );
                            

H( a*f(X1, X2)*g(X4) + b*X3*g(X4) + c^2*X1 + d*X1*X2*X3*X4,
   {X1,X2,X3,X4} );

H( a*b*X3 + c^2*X1 + d*X1*X2*X3*X4,
   {X1,X2,X3,X4} );
                              

H( a*b*X3^4 + c^2*X1 + d*X1*X2*X3*X4,
   {X1,X2,X3,X4} );
                             

H( a*b + c^2*X1,
   {X1,X2,X3,X4} );
                             
 

 


 

Download typefunctie_11-2-2025_mprimes.mw


 

What happens when you simplify  ? 

Make this sense?, type is not aware of  commutativity and associativity of addition and multiplication.

Shouldn't you perform a pdetest when checking a solution of a pde and not do this with an odetest ?
Well, pde3 is a ode as it seems ,confusing naming  , i regocnise it because there is only one variable 

ode := simplify(expand(ode/exp((k*x - t*w)*I))) assuming exp((k*x - t*w)*I) <> 0;
odeadvisor(ode);
infolevel[dsolve]:=3;
Sol1 := dsolve(ode, U(xi));
#############
 Sol_n1 := dsolve(eval(ode_final, n=1), U(xi));

By matrix en determinant calculation and this can b eused for polynomial functions 
- for a parabole is needed 3 points , and degree 2 as example 
 

PolynomialFit := proc(P::list, d::integer := 2)
    uses LinearAlgebra, VectorCalculus, plots;
    local n, M, b, coeffs, poly, f, x_range, y_range, 
          x_min, x_max, y_min, y_max, x_padding, y_padding,
          plot_poly, plot_points, final_plot, i;

    # Controleer of er voldoende punten zijn voor de gevraagde graad
    n := nops(P);
    if n < d + 1 then
        error "Er zijn minimaal (d+1) punten nodig om een polynoom van graad d te passen.";
    end if;

    # Constructeer de matrix en vector voor de polynomial fit
    M := Matrix(n, d+1, (i, j) -> P[i][1]^(j-1));  # Elke rij is [1, x, x^2, ..., x^d]
    b := Vector(n, i -> P[i][2]);  # De y-waarden

    # Controleer of de matrix een inverse heeft (geen verticale lijn als alle x gelijk zijn)
    if Determinant(M) = 0 then
        error "Kan geen polynoom vinden: punten zijn niet lineair onafhankelijk of x-waarden zijn identiek.";
    end if;

    # Los het systeem op: M * coeffs = b
    coeffs := LinearSolve(M, b);

    # Constructeer het polynoom op basis van de gevonden coëfficiënten
    poly := add(coeffs[i+1] * x^i, i = 0..d);

    # Maak de functie f(x) in operator-notation
    f := unapply(poly, x);

    # Dynamisch plotbereik bepalen
    x_min := min(seq(P[i][1], i = 1..n));
    x_max := max(seq(P[i][1], i = 1..n));
    y_min := min(seq(P[i][2], i = 1..n));
    y_max := max(seq(P[i][2], i = 1..n));

    x_padding := 0.2 * (x_max - x_min);
    y_padding := 0.2 * (y_max - y_min);
    x_range := x_min - x_padding .. x_max + x_padding;
    y_range := y_min - y_padding .. y_max + y_padding;

    # Plot het polynoom
    plot_poly := plot(poly, x = x_range, y = y_range, color = "Blue", thickness = 3);

    # Plot de gegeven punten
    plot_points := plots:-pointplot(P, symbol = solidcircle, 
                                    color = "Red", symbolsize = 20);

    # Combineer de plots
    final_plot := plots:-display(plot_poly, plot_points,
                                 labels = ["x", "y"], title = cat("Fit met polynoom van graad ", d));

    # Eerst de plot weergeven
    print(final_plot);

    # Daarna de functie printen als operatorfunctie in Maple-notatie
    eval(f);
end proc:

P := [[-1, 1], [0, 0], [1, 1], [2, 8]];
PolynomialFit(P, 3);


 

Seems to be in the good direction ...need some more adjustments
 

restart;
with(combinat):
f := proc(N)
    local M, coeff, all_terms, subsets, s, matchings, matching, B_product, pair, theta_indices, theta_product, term, i, k;
    all_terms := 0;
    for M from 0 to floor(N/2) do
        coeff := 1/(M! * 2^M);
        if M = 0 then
            all_terms := all_terms + coeff * mul(theta[i], i=1..N);
        else
            subsets := choose([$1..N], 2*M);
            for s in subsets do
                matchings := setpartition(s, 2);
                if matchings = [] then
                    matchings := [s];
                end if;
                for matching in matchings do
                    B_product := 1;
                    for pair in matching do
                        B_product := B_product * B[min(pair), max(pair)];
                    end do;
                    theta_indices := {$1..N} minus {op(s)};
                    theta_product := mul(theta[k], k in theta_indices);
                    term := coeff * B_product * theta_product;
                    all_terms := all_terms + term;
                end do;
            end do;
        end if;
    end do;
    return expand(all_terms);
end proc:
# Voorbeeld voor N=4
f(4);

 

@dharr Thanks, This application of diff_table goes beyond the declare mechanism than 
Let me summarise..
Note:  U [ ]  =  u 


 

@Carl Love  Thanks , now using it on the right way...

@dharr Thanks, the next ai code is also a example what needs correction

restart; 

# Definieer de parameters als symbolische variabelen
R1 := 'R1';  
R2 := 'R2';

# Definieer de variabelen en afgeleiden
U := 'U(xi)';      # Functie U(xi) blijft symbolisch
Phi := 'diff(U(xi), xi)';  # Definieer Phi als de eerste afgeleide van U

# Differentiaalvergelijking
eq := diff(Phi, xi) = R1 * U + R2 * U^3;

A solution seems to be 
example : declare(u(xi), Phi(xi));  # Declare functions with PDEtools to prevent recursion 

For solving this reduced louiville pde there were 2 solutions, both by using a substitution (ansatz?) in the liouville pde
- reducing pde to a ode 
- bring pde in a polynomial form 

@dharr Thanks, From the looks of it , it makes quite a difference which substitution you use.  

This solution Sol11 can be derived.
PDE2 is transformed to a new pde and this form suggests that there is  solution possible is for a rational function  or a power function
Some analyse is needed, but done by Maple  



The HINT has this form: HINT = 1/(A*x + B*t + C)^2 * F() 
F() ? 




restart;
with(PDEtools):
declare(u(x,t), w(x,t));  # Declareer afhankelijke variabelen

# Definieer de substitutie: u(x,t) = (1/beta) * ln(w(x,t)/beta)
tr := u(x,t) = ln(w(x,t)/beta)/beta;

# Originele PDE: a^2 u_{xx} + b e^{beta u} - u_{tt} = 0
PDE1 := a^2*diff(u(x,t), x, x) + b*exp(beta*u(x,t)) - diff(u(x,t), t, t) = 0;

# Voer de substitutie uit en vereenvoudig
PDE2 := dchange(tr, PDE1, [w], params={beta}, simplify(normal));

# Los PDE2 op met een HINT voor de vorm (A x + B t + C)^{-2}
sol_w := pdsolve(PDE2, HINT = 1/(A*x + B*t + C)^2 * F());

# Substitueer terug naar u(x,t)
sol_u := eval(tr, sol_w);

# Vereenvoudig de oplossing en hernoem constanten
sol_u := simplify(sol_u, {2*F()/(beta*b) = 2*(B^2 - a^2*A^2)/(beta*b)});
sol_u := subs(A = _C1, B = _C2, C = _C3, sol_u);  # Optioneel: hernoem constanten

# Test de oplossing
Test11 := pdetest(sol_u, PDE1);

u(x, t)*`will now be displayed as`*u

 

w(x, t)*`will now be displayed as`*w

 

u(x, t) = ln(w(x, t)/beta)/beta

 

a^2*(diff(diff(u(x, t), x), x))+b*exp(beta*u(x, t))-(diff(diff(u(x, t), t), t)) = 0

 

((diff(diff(w(x, t), x), x))*w(x, t)*a^2+b*w(x, t)^3-(diff(w(x, t), x))^2*a^2-(diff(diff(w(x, t), t), t))*w(x, t)+(diff(w(x, t), t))^2)/(w(x, t)^2*beta) = 0

 

w(x, t) = (-2*A^2*a^2+2*B^2)/(A^2*b*x^2+2*A*B*b*t*x+B^2*b*t^2+2*A*C*b*x+2*B*C*b*t+C^2*b)

 

u(x, t) = ln((-2*A^2*a^2+2*B^2)/((A^2*b*x^2+2*A*B*b*t*x+B^2*b*t^2+2*A*C*b*x+2*B*C*b*t+C^2*b)*beta))/beta

 

u(x, t) = ln((-2*A^2*a^2+2*B^2)/(b*(A*x+B*t+C)^2*beta))/beta

 

u(x, t) = ln((-2*_C1^2*a^2+2*_C2^2)/(b*(_C1*x+_C2*t+_C3)^2*beta))/beta

 

0

(1)

 


 

Download gereduceerde_liouvill_pde-opl11_via_HINT_uitzoeken.mw

 

DeepSeek ai seems to be smarter then ChatGPT...
Exploreplot 

By Perform travelling wave substitution using dchange,  the pde transform into a ode (reduction) 
This is working in default notation, but with a diff_table notation ?

default notation
restart;
with(PDEtools):

# Step 1: Define the PDE
declare(u(x,t));
pde := diff(u(x,t), t$2) + a^2*diff(u(x,t), x$2) = b*exp(beta*u(x,t));

# Step 2: Perform travelling wave substitution using dchange
# Transformation to the travelling wave coordinate z = x - c*t
tr := {x = z + c*tau, t = tau, u(x,t) = U(z)};
new_pde := dchange(tr, pde, [z, tau, U(z)]);

# Step 3: Simplify the resulting ODE (derivatives with respect to tau vanish)
ode := simplify(new_pde) assuming tau::constant;

# Step 4: Solve the ODE
sol := dsolve(ode, U(z));

# Display the solution
sol;

First 15 16 17 18 19 20 21 Last Page 17 of 74