janhardo

690 Reputation

12 Badges

11 years, 36 days

MaplePrimes Activity


These are replies submitted by janhardo

@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;

Can it ever be solved  exact ?
Finding real valued parameters for this function and and at the same time a solution for a npde 

Get rid of the sqrt ?..take the inverse  operation for this.

It's not yet clear to me exactly what you want to do.
- there is a plane. 
- there is a placevector( in Dutch :plaatsvector)  ( start in origin). 
The place vector intersects the plane and an intersection point should be calculated from it?

L4 has a crossterm  x*t  and coeffs command is not working for this ?

Now there is no plot , because k is a unknown




Lets take for k= 1 

Is a one -liner from which there is nothing to learn in my opinion , has no educational value 

@dharr 
# Almost all Maple commands, such as solve, dsolve etc interpret an expression without =0 as though the =0 was present.# ?
check this with ODEsteps 

Two commands for getting a fieldplot for differential equations 


 

Module ODEgenerator 18-1-2025

 

restart;

 

odegenerator := module()
    option package;
  export odegeniter, odegenman;# odegenexpl;
  
######################
  odegeniter := proc(V, t, y, differential_eq, solve_all, range)
    local a0, a1, a2, b0, b1, eq, rows, row_eqs, numrows, i, single_row, selected_rows, dataframe;
    uses PDEtools;

    # Check if the input is a valid differential equation
    if not has(differential_eq, diff(y(t), t)) then
        error "The 'differential_eq' parameter must be a valid differential equation containing diff(y(t), t).";
    end if;

    # Validate solve_all and range parameters
    if not (solve_all = true or solve_all = false) then
        error "The solve_all parameter must be true or false.";
    end if;

    if not (range = 0 or type(range, posint) or type(range, range)) then
        error "The range parameter must be 0, a positive integer, or a range (e.g., 1..5).";
    end if;

    # Initialize storage for equations and solutions
    rows := [];
    row_eqs := [];

    # Iterate through all combinations of parameters in V
    for a0 in V do
        for a1 in V do
            for a2 in V do
                for b0 in V do
                    for b1 in V do
                        # Substitute parameters into the differential equation
                        eq := differential_eq;
                        eq := subs('a__0' = ifelse(a0 = 0, infinity, a0), eq);
                        eq := subs('a__1' = ifelse(a1 = 0, infinity, a1), eq);
                        eq := subs('a__2' = ifelse(a2 = 0, infinity, a2), eq);
                        eq := subs('b__0' = ifelse(b0 = 0, infinity, b0), eq);
                        eq := subs('b__1' = ifelse(b1 = 0, infinity, b1), eq);

                        # Add the equation to the rows
                        rows := [op(rows), [nops(rows) + 1, a0, a1, a2, b0, b1, eq, ""]];
                        row_eqs := [op(row_eqs), eq];
                    end do;
                end do;
            end do;
        end do;
    end do;

    # Get the number of rows generated
    numrows := nops(rows);

    # Generate the full DataFrame when solve_all is true and range is 0
    if solve_all = true and range = 0 then
        printf("Generating full DataFrame...\n");
        for i to numrows do
            try
                rows[i][8] := rhs(dsolve(row_eqs[i], y(t)));
            catch:
                rows[i][8] := "No explicit solution";
            end try;
        end do;

        # Create and return the DataFrame
        dataframe := DataFrame(Matrix(rows), columns = ['Row', 'a__0', 'a__1', 'a__2', 'b__0', 'b__1', 'Equation', 'Solution']);
        return dataframe;

    elif solve_all = true and type(range, posint) then
        # Retrieve a specific row from the DataFrame
        printf("Retrieving row %d from DataFrame...\n", range);
        if range > numrows then
            error "Row index out of bounds.";
        end if;
        single_row := rows[range];
        try
            single_row[8] := rhs(dsolve(row_eqs[range], y(t)));
        catch:
            single_row[8] := "No explicit solution";
        end try;
        return DataFrame(Matrix([single_row]), columns = ['Row', 'a__0', 'a__1', 'a__2', 'b__0', 'b__1', 'Equation', 'Solution']);

    elif solve_all = true and type(range, range) then
        # Retrieve rows within a specified range
        printf("Retrieving rows %a from DataFrame...\n", range);
        selected_rows := [];
        for i from op(1, range) to op(2, range) do
            if i > numrows then
                error "Row index out of bounds.";
            end if;
            selected_rows := [op(selected_rows), rows[i]];
            try
                selected_rows[-1][8] := rhs(dsolve(row_eqs[i], y(t)));
            catch:
                selected_rows[-1][8] := "No explicit solution";
            end try;
        end do;

        # Return the selected rows as a DataFrame
        return DataFrame(Matrix(selected_rows), columns = ['Row', 'a__0', 'a__1', 'a__2', 'b__0', 'b__1', 'Equation', 'Solution']);

    else
        error "Invalid combination of solve_all and range.";
    end if;
 end proc:

 ################
  odegenman := proc(V, x, y, differential_eq, const_values, xrange, yrange, initial_conditions)
    local a0, a1, a2, b0, b1, sol, Fsol, row_number, count,
          a0_iter, a1_iter, a2_iter, b0_iter, b1_iter, modified_eq, eq_type, odeplot_cmd;
    uses PDEtools, plots;

    # Check if const_values is valid
    if not type(const_values, list) or nops(const_values) <> 5 then
        error "The constant values (const_values) must be a list with exactly 5 elements.";
    end if;

    # Check if xrange and yrange are valid
    if not type(xrange, range) or not type(yrange, range) then
        error "Both xrange and yrange must be ranges, e.g., 0..2 or -10..10.";
    end if;

    # Check if initial_conditions is a valid list
    if not type(initial_conditions, list) or nops(initial_conditions) = 0 then
        error "Initial conditions must be provided as a non-empty list.";
    end if;

    # Assign the constant values
    a0 := const_values[1];
    a1 := const_values[2];
    a2 := const_values[3];
    b0 := const_values[4];
    b1 := const_values[5];

    # Find the row number by unique identification
    count := 1;
    row_number := "Unknown";  # Default value if no row is found
    for a0_iter in V do
        for a1_iter in V do
            for a2_iter in V do
                for b0_iter in V do
                    for b1_iter in V do
                        if [a0_iter, a1_iter, a2_iter, b0_iter, b1_iter] = const_values then
                            row_number := sprintf("%d", count);  # Convert to string
                        end if;
                        count := count + 1;
                    end do;
                end do;
            end do;
        end do;
    end do;

    # Create a modified version of the differential equation
    modified_eq := differential_eq;

    if a0 = 0 then
        modified_eq := subs('a__0' = infinity, modified_eq);  # Disable term
    else
        modified_eq := subs('a__0' = a0, modified_eq);
    end if;

    if a1 = 0 then
        modified_eq := subs('a__1' = infinity, modified_eq);
    else
        modified_eq := subs('a__1' = a1, modified_eq);
    end if;

    if a2 = 0 then
        modified_eq := subs('a__2' = infinity, modified_eq);
    else
        modified_eq := subs('a__2' = a2, modified_eq);
    end if;

    if b0 = 0 then
        modified_eq := subs('b__0' = infinity, modified_eq);
    else
        modified_eq := subs('b__0' = b0, modified_eq);
    end if;

    if b1 = 0 then
        modified_eq := subs('b__1' = infinity, modified_eq);
    else
        modified_eq := subs('b__1' = b1, modified_eq);
    end if;

    # Evaluate the type of the ODE
    eq_type := DEtools:-odeadvisor(modified_eq);

    # Solve the equation symbolically
    printf("The corresponding row number is: %s\n", row_number);
    printf("The simplified ODE with the given coefficients is:\n\n");
    print(modified_eq, eq_type);

    printf("Attempting to solve symbolically...\n");
    try
        sol := dsolve(modified_eq, y(x));
        if type(sol, `=`) then
            Fsol := rhs(sol);
            printf("Explicit symbolic solution found:\n");
            print(Fsol);
        else
            Fsol := "No explicit solution (analytically).";
            printf("No explicit symbolic solution found for the differential equation. A DEplot will be generated numerically.\n");
        end if;
    catch:
        Fsol := "Symbolic solution failed.";
        printf("Symbolic solution failed. A DEplot will be generated numerically.\n");
    end try;

    # Generate the DE plot numerically
    printf("Generating DE plot for the differential equation...\n");
    try
        odeplot_cmd := DEtools:-DEplot(
            modified_eq,
            [y(x)],
            x = xrange,
            initial_conditions,
            y = yrange,
            stepsize = 0.1,
            title = "DE Plot for Differential Equation"
        );
        print(plots:-display(odeplot_cmd, size = [550, 550]));
    catch:
        printf("Plotting failed. Ensure the initial conditions and ranges are correct.\n");
    end try;

    return Fsol;
  end proc:
 ####################    
end module:




 

true stands for using DataFrame
false : Error, (in odegeniter) Invalid combination of solve_all and range.

with(odegenerator);

[odegeniter, odegenman]

(1.1)

differential_eq:= diff(y(t), t) = sin(t)/'a__0' + y(t)/'a__1' + y(t)^2/'a__2' + exp(-t)/'b__0' + sinh(-t)/'b__1';
V := {0, 1};

diff(y(t), t) = sin(t)/a__0+y(t)/a__1+y(t)^2/a__2+exp(-t)/b__0-sinh(t)/b__1

 

{0, 1}

(1.2)

odegeniter(V, t, y, differential_eq, true, 0);# all DataFrame rows, using 0

Generating full DataFrame...

 

DataFrame(_rtable[36893489634290664740], rows = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32], columns = [Row, a__0, a__1, a__2, b__0, b__1, Equation, Solution])

(1.3)

odegeniter(V, t, y, differential_eq, true, 2);# a row in DataFrame, using 2 as rownumber ( check in full Dataframe)

 

Retrieving row 2 from DataFrame...

 

DataFrame(Vector[row](8, {(1) = 2, (2) = 0, (3) = 0, (4) = 0, (5) = 0, (6) = 1, (7) = diff(y(t), t) = -sinh(t), (8) = -cosh(t)+_C1}), rows = [1], columns = [Row, a__0, a__1, a__2, b__0, b__1, Equation, Solution])

(1.4)

odegeniter(V, t, y, differential_eq, true, 2..5);# a range of rows in DataFrame ( check in full Dataframe)

Retrieving rows 2 .. 5 from DataFrame...

 

DataFrame(Matrix(4, 8, {(1, 1) = 2, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (1, 6) = 1, (1, 7) = diff(y(t), t) = -sinh(t), (1, 8) = -cosh(t)+_C1, (2, 1) = 3, (2, 2) = 0, (2, 3) = 0, (2, 4) = 0, (2, 5) = 1, (2, 6) = 0, (2, 7) = diff(y(t), t) = exp(-t), (2, 8) = -exp(-t)+_C1, (3, 1) = 4, (3, 2) = 0, (3, 3) = 0, (3, 4) = 0, (3, 5) = 1, (3, 6) = 1, (3, 7) = diff(y(t), t) = exp(-t)-sinh(t), (3, 8) = -exp(-t)-cosh(t)+_C1, (4, 1) = 5, (4, 2) = 0, (4, 3) = 0, (4, 4) = 1, (4, 5) = 0, (4, 6) = 0, (4, 7) = diff(y(t), t) = y(t)^2, (4, 8) = 1/(-t+_C1)}), rows = [1, 2, 3, 4], columns = [Row, a__0, a__1, a__2, b__0, b__1, Equation, Solution])

(1.5)

Now using odegenman for plotting a fieldplot from the differential eqation for a rownumber from the DataFrame

V := {0, 1};
differential_eq := diff(y(t), t) = sin(t)/'a__0' + y(t)/'a__1' + y(t)^2/'a__2' + exp(-t)/'b__0' + sinh(-t)/'b__1';
trange := 0..5;
yrange := -10..10;
initial_conditions := [[y(0) = 1], [y(0) = -1], [y(0) = 2]];# using 3 initial conditions
odegenman(V, t, y, differential_eq, [1, 1, 1, 1, 1], trange, yrange, initial_conditions);

{0, 1}

 

diff(y(t), t) = sin(t)/a__0+y(t)/a__1+y(t)^2/a__2+exp(-t)/b__0-sinh(t)/b__1

 

0 .. 5

 

-10 .. 10

 

[[y(0) = 1], [y(0) = -1], [y(0) = 2]]

 

The corresponding row number is: 32
The simplified ODE with the given coefficients is:

 

 

diff(y(t), t) = sin(t)+y(t)+y(t)^2+exp(-t)-sinh(t), [_Riccati]

 

Attempting to solve symbolically...
No explicit symbolic solution found for the differential equation. A DEplot will be generated numerically.
Generating DE plot for the differential equation...

 

 

"No explicit solution (analytically)."

(1.6)

lest take row 0 : y' = C , row 1 has 5 zeroes to fill in list in command

#odegenman(V, t, y, differential_eq, [1, 1, 1, 1, 1], trange, yrange, initial_conditions);# example of 5 ones in list is last rownumber of 32 rows for V := {0, 1};

odegenman(V, t, y, differential_eq, [0, 0, 0, 0, 0], trange, yrange, initial_conditions);

The corresponding row number is: 1
The simplified ODE with the given coefficients is:

 

 

diff(y(t), t) = 0, [_quadrature]

 

Attempting to solve symbolically...
Explicit symbolic solution found:

 

c__1

 

Generating DE plot for the differential equation...

 

 

c__1

(1.7)

Is correct

V := {0, 1};
differential_eq := diff(y(t), t) = 'a__0'*(y(t))^2 + 'b__0'* t^k;# special Riccati equation , k is an arbititrary number

{0, 1}

 

diff(y(t), t) = a__0*y(t)^2+b__0*t^k

(1.8)

odegeniter(V, t, y, differential_eq, true, 0);#, a0 = 1 and b0 = 1 , there is a overlap of rows  

Generating full DataFrame...

 

DataFrame(_rtable[36893489634206659876], rows = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32], columns = [Row, a__0, a__1, a__2, b__0, b__1, Equation, Solution])

(1.9)

odegeniter(V, t, y, differential_eq, true, 19);# row 19 gives the general solution, but using row 32 is always correct

Retrieving row 19 from DataFrame...

 

DataFrame(Vector[row](8, {(1) = 19, (2) = 1, (3) = 0, (4) = 0, (5) = 1, (6) = 0, (7) = diff(y(t), t) = y(t)^2+t^k, (8) = (BesselJ((3+k)/(k+2), 2*t^((1/2)*k+1)/(k+2))*t^((1/2)*k+1)*_C1+BesselY((3+k)/(k+2), 2*t^((1/2)*k+1)/(k+2))*t^((1/2)*k+1)-_C1*BesselJ(1/(k+2), 2*t^((1/2)*k+1)/(k+2))-BesselY(1/(k+2), 2*t^((1/2)*k+1)/(k+2)))/(t*(_C1*BesselJ(1/(k+2), 2*t^((1/2)*k+1)/(k+2))+BesselY(1/(k+2), 2*t^((1/2)*k+1)/(k+2))))}), rows = [1], columns = [Row, a__0, a__1, a__2, b__0, b__1, Equation, Solution])

(1.10)

now what is dfieldplot of this?

 

V := {0, 1};
differential_eq := diff(y(t), t) = 'a__0'*(y(t))^2 + 'b__0'* t^k;
trange := 0..5;
yrange := -10..10;
initial_conditions := [[y(0) = 1], [y(0) = -1], [y(0) = 2]];# using 3 initial conditions differential_eq := diff(y(t), t) = 'a__0'*(y(t))^2 + 'b__0'* t^k;

{0, 1}

 

diff(y(t), t) = a__0*y(t)^2+b__0*t^k

 

0 .. 5

 

-10 .. 10

 

[[y(0) = 1], [y(0) = -1], [y(0) = 2]]

(1.11)

odegenman(V, t, y, differential_eq, [1, 0, 0, 1, 0], trange, yrange, initial_conditions);#rownumber 19

The corresponding row number is: 19
The simplified ODE with the given coefficients is:

 

 

diff(y(t), t) = y(t)^2+t^k, [[_Riccati, _special]]

 

Attempting to solve symbolically...
Explicit symbolic solution found:

 

(BesselJ((3+k)/(k+2), 2*t^((1/2)*k+1)/(k+2))*t^((1/2)*k+1)*c__1+BesselY((3+k)/(k+2), 2*t^((1/2)*k+1)/(k+2))*t^((1/2)*k+1)-c__1*BesselJ(1/(k+2), 2*t^((1/2)*k+1)/(k+2))-BesselY(1/(k+2), 2*t^((1/2)*k+1)/(k+2)))/(t*(c__1*BesselJ(1/(k+2), 2*t^((1/2)*k+1)/(k+2))+BesselY(1/(k+2), 2*t^((1/2)*k+1)/(k+2))))

 

Generating DE plot for the differential equation...
Plotting failed. Ensure the initial conditions and ranges are correct.

 

(BesselJ((3+k)/(k+2), 2*t^((1/2)*k+1)/(k+2))*t^((1/2)*k+1)*c__1+BesselY((3+k)/(k+2), 2*t^((1/2)*k+1)/(k+2))*t^((1/2)*k+1)-c__1*BesselJ(1/(k+2), 2*t^((1/2)*k+1)/(k+2))-BesselY(1/(k+2), 2*t^((1/2)*k+1)/(k+2)))/(t*(c__1*BesselJ(1/(k+2), 2*t^((1/2)*k+1)/(k+2))+BesselY(1/(k+2), 2*t^((1/2)*k+1)/(k+2))))

(1.12)

How to get a fieldplot for this DE : "(&DifferentialD;)/(&DifferentialD;t) y(t)=(y(t))^2+t^k,[[_Riccati,_special]], "try to find information about this Bessel functions ?

?odeadvisor ;

?special functions;

?FunctionAdvisor;

FunctionAdvisor(Bessel, quiet);

[AiryAi, AiryBi, BesselI, BesselJ, BesselK, BesselY, HankelH1, HankelH2, KelvinBei, KelvinBer, KelvinHei, KelvinHer, KelvinKei, KelvinKer]

(1.13)

FunctionAdvisor(BesselJ, quiet);

FunctionAdvisor(BesselY, quiet);

 

 


 

Download module_odegeniter_odegenman.mw

First 14 15 16 17 18 19 20 Last Page 16 of 73