janhardo

700 Reputation

12 Badges

11 years, 43 days

MaplePrimes Activity


These are replies submitted by janhardo

a procedure 


 

 

 

restart;
with(inttrans):       # Load the integral transforms package
with(PDEtools):       # Load the partial differential equations tools
with(LinearAlgebra):  # Load the linear algebra package

# Define the Maple procedure to compute truncated series solutions for u, v, and w
TruncatedSolutions := proc(x, y, t, truncOrder)
    local su, sv, sw, u_sol_s, v_sol_s, w_sol_s, u_sol, v_sol, w_sol;
    local u_n, u_n1, v_n, v_n1, w_n, w_n1;
    local Cuvw, Cuv, Cu, Dvw, Eu, Du, Ev, Ew, Euv;
    local u_n_series, v_n_series, w_n_series;
    local u_final, v_final, w_final;
    local PDE1, PDE2, PDE3, IC1, IC2, IC3;
    local L_uv1, L_uw5, L_uv5, eq_su, eq_sv, eq_sw;
    local u_x_y_t, v_x_y_t, w_x_y_t;
    local X, Y, T;  # Symbolic placeholders for x, y, t

    # Use placeholders X, Y, T instead of x, y, t within the procedure
    # Step (3.22) - (3.24): Define the system of nonlinear PDEs
    printf("Step (3.22): Define PDE for u(X,Y,T)\n");
    PDE1 := diff(u(X, Y, T), T) - v(X, Y) * w(Y, T) = 1;
    
    printf("Step (3.23): Define PDE for v(X,Y,T)\n");
    PDE2 := diff(v(X, Y, T), T) - w(X, Y) * u(X, T) = 5;
    
    printf("Step (3.24): Define PDE for w(X,Y,T)\n");
    PDE3 := diff(w(X, Y, T), T) - u(X, Y) * v(X, T) = 5;
    
    # Step (3.25) - (3.27): Initial conditions for each function at T=0
    printf("Step (3.25): Initial condition for u\n");
    IC1 := u(X, Y, 0) = X + 2 * Y;
    
    printf("Step (3.26): Initial condition for v\n");
    IC2 := v(X, Y, 0) = -2 * Y;
    
    printf("Step (3.27): Initial condition for w\n");
    IC3 := w(X, Y, 0) = -X + 2 * Y;
    
    # Step (3.28) - Laplace transforms for each function
    printf("Step (3.28): Laplace transform of u(X, Y, T)\n");
    su := laplace(u(X, Y, T), T, s);
    
    printf("Step (3.29): Laplace transform of v(X, Y, T)\n");
    sv := laplace(v(X, Y, T), T, s);
    
    printf("Step (3.30): Laplace transform of w(X, Y, T)\n");
    sw := laplace(w(X, Y, T), T, s);
    
    # Define placeholders for the transforms of nonlinear terms
    L_uv1 := L[1 + u*v];
    L_uw5 := L[5 + w*u];
    L_uv5 := L[5 + u*v];
    
    # Step (3.31) - Applying initial conditions in the Laplace domain with placeholders
    printf("Step (3.31): Equation for su with initial conditions applied\n");
    eq_su := su - (X + 2 * Y) = 1 / s * L_uv1;
    
    printf("Step (3.32): Equation for sv with initial conditions applied\n");
    eq_sv := sv + 2 * Y = 5 / s * L_uw5;
    
    printf("Step (3.33): Equation for sw with initial conditions applied\n");
    eq_sw := sw - (X - 2 * Y) = 5 / s * L_uv5;
    
    # Step (3.34) - Express solutions in Laplace domain
    printf("Step (3.34): Solution for u in Laplace domain\n");
    u_sol_s := 1 / s^2 + (X + 2 * Y) / s + 1 / s * L[v * w];
    
    printf("Step (3.35): Solution for v in Laplace domain\n");
    v_sol_s := 5 / s^2 + (X - 2 * Y) / s + 1 / s * L[u * w];
    
    printf("Step (3.36): Solution for w in Laplace domain\n");
    w_sol_s := 5 / s^2 + (-X + 2 * Y) / s + 1 / s * L[u * v];
    
    # Step (3.37) - Applying the inverse Laplace transform to return to time domain
    printf("Step (3.37): Time domain solution for u\n");
    u_sol := invlaplace(u_sol_s, s, T);
    
    printf("Step (3.38): Time domain solution for v\n");
    v_sol := invlaplace(v_sol_s, s, T);
    
    printf("Step (3.39): Time domain solution for w\n");
    w_sol := invlaplace(w_sol_s, s, T);
    
    # Define recursive relations for each function
    printf("Step (3.40): Define recursive term u_n\n");
    u_n := (T -> u_sol);
    
    printf("Step (3.41): Define next recursive term u_n1\n");
    u_n1 := (T -> invlaplace(L[v * w], s, T));
    
    printf("Step (3.42): Define recursive term v_n\n");
    v_n := (T -> v_sol);
    
    printf("Step (3.43): Define next recursive term v_n1\n");
    v_n1 := (T -> invlaplace(L[w * u], s, T));
    
    printf("Step (3.44): Define recursive term w_n\n");
    w_n := (T -> w_sol);
    
    printf("Step (3.45): Define next recursive term w_n1\n");
    w_n1 := (T -> invlaplace(L[u * v], s, T));
    
    # Adomian polynomials for nonlinear terms
    printf("Step (3.46): Polynomial for u*v*w\n");
    Cuvw := u * v * w;
    
    printf("Step (3.47): Polynomial involving derivatives\n");
    Cuv := w * vx + v * wx;
    
    # Additional recursive definitions
    printf("Step (3.48): Sum of products for Du\n");
    Du := sum(u[k] * v[k] * w[k], k = 0 .. truncOrder);
    
    printf("Step (3.49): Initial term for v\n");
    Ev := v0;
    
    printf("Step (3.50): Sum involving initial terms of u and v\n");
    Ew := v0 + u0 + u1;
    
    printf("Step (3.51): Double sum for Euv\n");
    Euv := sum(u[m] * v[truncOrder-m], m = 0 .. truncOrder);
    
    # Steps (3.52) - (3.54) Evaluation of u, v, w in recursive form
    printf("Step (3.52): Evaluation of u in recursive form\n");
    u_x_y_t := diff(u(X, Y, T), T) - v(X, Y) * w(Y, T);
    
    printf("Step (3.53): Evaluation of v in recursive form\n");
    v_x_y_t := diff(v(X, Y, T), T) - w(X, Y) * u(X, T);
    
    printf("Step (3.54): Evaluation of w in recursive form\n");
    w_x_y_t := diff(w(X, Y, T), T) - u(X, Y) * v(X, T);
    
    # Summing recursive terms for final series solutions up to truncOrder
    printf("Step (3.55): Infinite series sum for u\n");
    u_n_series := sum(u_n(X, Y, T), n = 0 .. truncOrder);
    
    printf("Step (3.56): Infinite series sum for v\n");
    v_n_series := sum(v_n(X, Y, T), n = 0 .. truncOrder);
    
    printf("Step (3.57): Infinite series sum for w\n");
    w_n_series := sum(w_n(X, Y, T), n = 0 .. truncOrder);
    
    # Explicit truncated series solutions
    printf("Step (3.58): Truncated series for u\n");
    u_final := sum(u[n](X, Y, T), n = 0 .. truncOrder);
    
    printf("Step (3.59): Truncated series for v\n");
    v_final := sum(v[n](X, Y, T), n = 0 .. truncOrder);
    
    printf("Step (3.60): Truncated series for w\n");
    w_final := sum(w[n](X, Y, T), n = 0 .. truncOrder);
    
    # Substitute the actual values of x, y, and t into the final solutions
    u_final := subs({X = x, Y = y, T = t}, eval(u_final));
    v_final := subs({X = x, Y = y, T = t}, eval(v_final));
    w_final := subs({X = x, Y = y, T = t}, eval(w_final));

    # Output final truncated solutions for u, v, and w, converting expressions to strings to prevent formatting issues
    printf("Final truncated solutions for u, v, and w up to order %d:\n", truncOrder);
    printf("u_final: %a\n", u_final);
    printf("v_final: %a\n", v_final);
    printf("w_final: %a\n", w_final);

    # Return results as a list
    return [u_final, v_final, w_final];

end proc:

"maple.ini in users"

(1)

TruncatedSolutions(1, 2, 0.5, 5);

Step (3.22): Define PDE for u(X,Y,T)
Step (3.23): Define PDE for v(X,Y,T)
Step (3.24): Define PDE for w(X,Y,T)
Step (3.25): Initial condition for u
Step (3.26): Initial condition for v
Step (3.27): Initial condition for w
Step (3.28): Laplace transform of u(X, Y, T)
Step (3.29): Laplace transform of v(X, Y, T)
Step (3.30): Laplace transform of w(X, Y, T)
Step (3.31): Equation for su with initial conditions applied
Step (3.32): Equation for sv with initial conditions applied
Step (3.33): Equation for sw with initial conditions applied
Step (3.34): Solution for u in Laplace domain
Step (3.35): Solution for v in Laplace domain
Step (3.36): Solution for w in Laplace domain
Step (3.37): Time domain solution for u
Step (3.38): Time domain solution for v
Step (3.39): Time domain solution for w
Step (3.40): Define recursive term u_n
Step (3.41): Define next recursive term u_n1
Step (3.42): Define recursive term v_n
Step (3.43): Define next recursive term v_n1
Step (3.44): Define recursive term w_n
Step (3.45): Define next recursive term w_n1
Step (3.46): Polynomial for u*v*w
Step (3.47): Polynomial involving derivatives
Step (3.48): Sum of products for Du
Step (3.49): Initial term for v
Step (3.50): Sum involving initial terms of u and v
Step (3.51): Double sum for Euv
Step (3.52): Evaluation of u in recursive form
Step (3.53): Evaluation of v in recursive form
Step (3.54): Evaluation of w in recursive form
Step (3.55): Infinite series sum for u
Step (3.56): Infinite series sum for v
Step (3.57): Infinite series sum for w
Step (3.58): Truncated series for u
Step (3.59): Truncated series for v
Step (3.60): Truncated series for w
Final truncated solutions for u, v, and w up to order 5:
u_final: u[0](1,2,.5)+u[1](1,2,.5)+u[2](1,2,.5)+u[3](1,2,.5)+u[4](1,2,.5)+u[5](1,2,.5)
v_final: v[0](1,2,.5)+v[1](1,2,.5)+v[2](1,2,.5)+v[3](1,2,.5)+v[4](1,2,.5)+v[5](1,2,.5)
w_final: w[0](1,2,.5)+w[1](1,2,.5)+w[2](1,2,.5)+w[3](1,2,.5)+w[4](1,2,.5)+w[5](1,2,.5)

 

[u[0](1, 2, .5)+u[1](1, 2, .5)+u[2](1, 2, .5)+u[3](1, 2, .5)+u[4](1, 2, .5)+u[5](1, 2, .5), v[0](1, 2, .5)+v[1](1, 2, .5)+v[2](1, 2, .5)+v[3](1, 2, .5)+v[4](1, 2, .5)+v[5](1, 2, .5), w[0](1, 2, .5)+w[1](1, 2, .5)+w[2](1, 2, .5)+w[3](1, 2, .5)+w[4](1, 2, .5)+w[5](1, 2, .5)]

(2)

 

 


 

Download example2_pdesystmprime_salim3-11-2024PROCEDURE.mw

Easier to read.

 

restart;
with(inttrans):       # Load the integral transforms package
with(PDEtools):       # Load the partial differential equations tools
with(LinearAlgebra):  # Load the linear algebra package

# Step (3.22) - Define the system of nonlinear PDEs
printf("Step (3.22): Define PDE for u(x,y,t)\n");
PDE1 := diff(u(x, y, t), t) - v(x, y) * w(y, t) = 1;

printf("Step (3.23): Define PDE for v(x,y,t)\n");
PDE2 := diff(v(x, y, t), t) - w(x, y) * u(x, t) = 5;

printf("Step (3.24): Define PDE for w(x,y,t)\n");
PDE3 := diff(w(x, y, t), t) - u(x, y) * v(x, t) = 5;

# Step (3.25) - (3.27) Initial conditions for each function at t=0
printf("Step (3.25): Initial condition for u\n");
IC1 := u(x, y, 0) = x + 2 * y;

printf("Step (3.26): Initial condition for v\n");
IC2 := v(x, y, 0) = -2 * y;

printf("Step (3.27): Initial condition for w\n");
IC3 := w(x, y, 0) = -x + 2 * y;

# Step (3.28) - Laplace transforms for each function
printf("Step (3.28): Laplace transform of u(x, y, t)\n");
su := laplace(u(x, y, t), t, s);

printf("Step (3.29): Laplace transform of v(x, y, t)\n");
sv := laplace(v(x, y, t), t, s);

printf("Step (3.30): Laplace transform of w(x, y, t)\n");
sw := laplace(w(x, y, t), t, s);

# Define placeholders for the transforms of nonlinear terms
L_uv1 := L[1 + u*v];
L_uw5 := L[5 + w*u];
L_uv5 := L[5 + u*v];

# Step (3.31) - Applying initial conditions in the Laplace domain with placeholders
printf("Step (3.31): Equation for su with initial conditions applied\n");
eq_su := su - (x + 2 * y) = 1 / s * L_uv1;

printf("Step (3.32): Equation for sv with initial conditions applied\n");
eq_sv := sv + 2 * y = 5 / s * L_uw5;

printf("Step (3.33): Equation for sw with initial conditions applied\n");
eq_sw := sw - (x - 2 * y) = 5 / s * L_uv5;

# Step (3.34) - Express solutions in Laplace domain
printf("Step (3.34): Solution for u in Laplace domain\n");
u_sol_s := 1 / s^2 + (x + 2 * y) / s + 1 / s * L[v * w];

printf("Step (3.35): Solution for v in Laplace domain\n");
v_sol_s := 5 / s^2 + (x - 2 * y) / s + 1 / s * L[u * w];

printf("Step (3.36): Solution for w in Laplace domain\n");
w_sol_s := 5 / s^2 + (-x + 2 * y) / s + 1 / s * L[u * v];

# Step (3.37) - Applying the inverse Laplace transform to return to time domain
printf("Step (3.37): Time domain solution for u\n");
u_sol := invlaplace(u_sol_s, s, t);

printf("Step (3.38): Time domain solution for v\n");
v_sol := invlaplace(v_sol_s, s, t);

printf("Step (3.39): Time domain solution for w\n");
w_sol := invlaplace(w_sol_s, s, t);

# Define recursive relations for each function (3.40)-(3.42)
printf("Step (3.40): Define recursive term u_n\n");
u_n := (t -> u_sol);

printf("Step (3.41): Define next recursive term u_n1\n");
u_n1 := (t -> invlaplace(L[v * w], s, t));

printf("Step (3.42): Define recursive term v_n\n");
v_n := (t -> v_sol);

printf("Step (3.43): Define next recursive term v_n1\n");
v_n1 := (t -> invlaplace(L[w * u], s, t));

printf("Step (3.44): Define recursive term w_n\n");
w_n := (t -> w_sol);

printf("Step (3.45): Define next recursive term w_n1\n");
w_n1 := (t -> invlaplace(L[u * v], s, t));

# Adomian polynomials for nonlinear terms (3.43)-(3.47)
printf("Step (3.46): Polynomial for u*v*w\n");
Cuvw := u * v * w;

printf("Step (3.47): Polynomial involving derivatives\n");
Cuv := w * vx + v * wx;

# Step (3.48) - (3.51) Additional recursive definitions
printf("Step (3.48): Sum of products for Du\n");
Du := sum(u[k] * v[k] * w[k], k = 0 .. n);

printf("Step (3.49): Initial term for v\n");
Ev := v0;

printf("Step (3.50): Sum involving initial terms of u and v\n");
Ew := v0 + u0 + u1;

printf("Step (3.51): Double sum for Euv\n");
Euv := sum(u[m] * v[n-m], m = 0 .. n);

# Steps (3.52) - (3.54) Evaluation of u, v, w in recursive form
printf("Step (3.52): Evaluation of u in recursive form\n");
u_x_y_t := diff(u(x, y, t), t) - v(x, y) * w(y, t);

printf("Step (3.53): Evaluation of v in recursive form\n");
v_x_y_t := diff(v(x, y, t), t) - w(x, y) * u(x, t);

printf("Step (3.54): Evaluation of w in recursive form\n");
w_x_y_t := diff(w(x, y, t), t) - u(x, y) * v(x, t);

# Step (3.55) - Summing recursive terms for final series solutions
printf("Step (3.55): Infinite series sum for u\n");
u_n_series := sum(u_n(x, y, t), n = 0 .. infinity);

printf("Step (3.56): Infinite series sum for v\n");
v_n_series := sum(v_n(x, y, t), n = 0 .. infinity);

printf("Step (3.57): Infinite series sum for w\n");
w_n_series := sum(w_n(x, y, t), n = 0 .. infinity);

# Explicit sums for solutions (evaluating where possible)
printf("Step (3.58): Truncated series for u\n");
u_final := sum(u[n](x, y, t), n = 0 .. 5);

printf("Step (3.59): Truncated series for v\n");
v_final := sum(v[n](x, y, t), n = 0 .. 5);

printf("Step (3.60): Truncated series for w\n");
w_final := sum(w[n](x, y, t), n = 0 .. 5);

# Display final truncated solutions
printf("Displaying final truncated solutions for u, v, and w:\n");
u_final;
v_final;
w_final;

"maple.ini in users"

 

Step (3.22): Define PDE for u(x,y,t)

 

diff(u(x, y, t), t)-v(x, y)*w(y, t) = 1

 

Step (3.23): Define PDE for v(x,y,t)

 

diff(v(x, y, t), t)-w(x, y)*u(x, t) = 5

 

Step (3.24): Define PDE for w(x,y,t)

 

diff(w(x, y, t), t)-u(x, y)*v(x, t) = 5

 

Step (3.25): Initial condition for u

 

u(x, y, 0) = x+2*y

 

Step (3.26): Initial condition for v

 

v(x, y, 0) = -2*y

 

Step (3.27): Initial condition for w

 

w(x, y, 0) = -x+2*y

 

Step (3.28): Laplace transform of u(x, y, t)

 

laplace(u(x, y, t), t, s)

 

Step (3.29): Laplace transform of v(x, y, t)

 

laplace(v(x, y, t), t, s)

 

Step (3.30): Laplace transform of w(x, y, t)

 

laplace(w(x, y, t), t, s)

 

L[u*v+1]

 

L[u*w+5]

 

L[u*v+5]

 

Step (3.31): Equation for su with initial conditions applied

 

laplace(u(x, y, t), t, s)-x-2*y = L[u*v+1]/s

 

Step (3.32): Equation for sv with initial conditions applied

 

laplace(v(x, y, t), t, s)+2*y = 5*L[u*w+5]/s

 

Step (3.33): Equation for sw with initial conditions applied

 

laplace(w(x, y, t), t, s)-x+2*y = 5*L[u*v+5]/s

 

Step (3.34): Solution for u in Laplace domain

 

1/s^2+(x+2*y)/s+L[v*w]/s

 

Step (3.35): Solution for v in Laplace domain

 

5/s^2+(x-2*y)/s+L[w*u]/s

 

Step (3.36): Solution for w in Laplace domain

 

5/s^2+(-x+2*y)/s+L[u*v]/s

 

Step (3.37): Time domain solution for u

 

t+x+2*y+L[v*w]

 

Step (3.38): Time domain solution for v

 

5*t+x-2*y+L[w*u]

 

Step (3.39): Time domain solution for w

 

5*t-x+2*y+L[u*v]

 

Step (3.40): Define recursive term u_n

 

proc (t) options operator, arrow; u_sol end proc

 

Step (3.41): Define next recursive term u_n1

 

proc (t) options operator, arrow; invlaplace(L[v*w], s, t) end proc

 

Step (3.42): Define recursive term v_n

 

proc (t) options operator, arrow; v_sol end proc

 

Step (3.43): Define next recursive term v_n1

 

proc (t) options operator, arrow; invlaplace(L[w*u], s, t) end proc

 

Step (3.44): Define recursive term w_n

 

proc (t) options operator, arrow; w_sol end proc

 

Step (3.45): Define next recursive term w_n1

 

proc (t) options operator, arrow; invlaplace(L[u*v], s, t) end proc

 

Step (3.46): Polynomial for u*v*w

 

u*v*w

 

Step (3.47): Polynomial involving derivatives

 

v*wx+vx*w

 

Step (3.48): Sum of products for Du

 

sum(u[k]*v[k]*w[k], k = 0 .. n)

 

Step (3.49): Initial term for v

 

v0

 

Step (3.50): Sum involving initial terms of u and v

 

v0+u0+u1

 

Step (3.51): Double sum for Euv

 

sum(u[m]*v[n-m], m = 0 .. n)

 

Step (3.52): Evaluation of u in recursive form

 

diff(u(x, y, t), t)-v(x, y)*w(y, t)

 

Step (3.53): Evaluation of v in recursive form

 

diff(v(x, y, t), t)-w(x, y)*u(x, t)

 

Step (3.54): Evaluation of w in recursive form

 

diff(w(x, y, t), t)-u(x, y)*v(x, t)

 

Step (3.55): Infinite series sum for u

 

signum(t+x+2*y+L[v*w])*infinity

 

Step (3.56): Infinite series sum for v

 

signum(5*t+x-2*y+L[w*u])*infinity

 

Step (3.57): Infinite series sum for w

 

signum(5*t-x+2*y+L[u*v])*infinity

 

Step (3.58): Truncated series for u

 

u[0](x, y, t)+u[1](x, y, t)+u[2](x, y, t)+u[3](x, y, t)+u[4](x, y, t)+u[5](x, y, t)

 

Step (3.59): Truncated series for v

 

v[0](x, y, t)+v[1](x, y, t)+v[2](x, y, t)+v[3](x, y, t)+v[4](x, y, t)+v[5](x, y, t)

 

Step (3.60): Truncated series for w

 

w[0](x, y, t)+w[1](x, y, t)+w[2](x, y, t)+w[3](x, y, t)+w[4](x, y, t)+w[5](x, y, t)

 

Displaying final truncated solutions for u, v, and w:

 

u[0](x, y, t)+u[1](x, y, t)+u[2](x, y, t)+u[3](x, y, t)+u[4](x, y, t)+u[5](x, y, t)

 

v[0](x, y, t)+v[1](x, y, t)+v[2](x, y, t)+v[3](x, y, t)+v[4](x, y, t)+v[5](x, y, t)

 

w[0](x, y, t)+w[1](x, y, t)+w[2](x, y, t)+w[3](x, y, t)+w[4](x, y, t)+w[5](x, y, t)

(1)

 


 

Download example2_pdesystmprime_salim3-11-2024Variant1.mw

 

To get about the same results .it is not finished yet, i like to have the same notation(almost possible) for pdes 
I followed the pdf numbering, but other way is to ask for a procedure what i don't do for now

 

restart;
with(inttrans):       # Load the integral transforms package
with(PDEtools):       # Load the partial differential equations tools
with(LinearAlgebra):  # Load the linear algebra package

# Define the system of nonlinear PDEs with detailed notation
PDE1 := diff(u(x, y, t), t) - v(x, y) * w(y, t) = 1;   # (3.22) Define PDE for u(x,y,t)
PDE2 := diff(v(x, y, t), t) - w(x, y) * u(x, t) = 5;   # (3.23) Define PDE for v(x,y,t)
PDE3 := diff(w(x, y, t), t) - u(x, y) * v(x, t) = 5;   # (3.24) Define PDE for w(x,y,t)

# Initial conditions for each function at t=0
IC1 := u(x, y, 0) = x + 2 * y;     # (3.25) Initial condition for u
IC2 := v(x, y, 0) = -2 * y;        # (3.26) Initial condition for v
IC3 := w(x, y, 0) = -x + 2 * y;    # (3.27) Initial condition for w

# Laplace transforms for each function
su := laplace(u(x, y, t), t, s);    # Laplace transform of u(x, y, t)
sv := laplace(v(x, y, t), t, s);    # Laplace transform of v(x, y, t)
sw := laplace(w(x, y, t), t, s);    # Laplace transform of w(x, y, t)

# Define placeholders for the transforms of nonlinear terms
L_uv1 := L[1 + u*v];    # Placeholder for Laplace transform of 1 + u*v
L_uw5 := L[5 + w*u];    # Placeholder for Laplace transform of 5 + w*u
L_uv5 := L[5 + u*v];    # Placeholder for Laplace transform of 5 + u*v

# Applying the initial conditions in the Laplace domain with placeholders
eq_su := su - (x + 2 * y) = 1 / s * L_uv1;    # (3.28) Equation for su
eq_sv := sv + 2 * y = 5 / s * L_uw5;          # (3.29) Equation for sv
eq_sw := sw - (x - 2 * y) = 5 / s * L_uv5;    # (3.30) Equation for sw

# Express solutions in Laplace domain (adding explicit forms)
u_sol_s := 1 / s^2 + (x + 2 * y) / s + 1 / s * L[v * w]; # (3.31) Solution for u in Laplace domain
v_sol_s := 5 / s^2 + (x - 2 * y) / s + 1 / s * L[u * w]; # (3.32) Solution for v in Laplace domain
w_sol_s := 5 / s^2 + (-x + 2 * y) / s + 1 / s * L[u * v]; # (3.33) Solution for w in Laplace domain

# Applying the inverse Laplace transform to return to time domain
u_sol := invlaplace(u_sol_s, s, t);  # (3.34) Time domain solution for u
v_sol := invlaplace(v_sol_s, s, t);  # (3.35) Time domain solution for v
w_sol := invlaplace(w_sol_s, s, t);  # (3.36) Time domain solution for w

# Define recursive relations for each function (3.37)-(3.42)
u_n := (t -> u_sol);                       # Define nth term for u(x,y,t)
u_n1 := (t -> invlaplace(L[v * w], s, t));  # Next recursive term for u
v_n := (t -> v_sol);                       # Define nth term for v(x,y,t)
v_n1 := (t -> invlaplace(L[w * u], s, t));  # Next recursive term for v
w_n := (t -> w_sol);                       # Define nth term for w(x,y,t)
w_n1 := (t -> invlaplace(L[u * v], s, t));  # Next recursive term for w

# Adomian polynomials for nonlinear terms (3.43)-(3.47)
Cuvw := u * v * w;           # (3.43) Polynomial for u*v*w
Cuv := w * vx + v * wx;      # (3.44) Polynomial involving derivatives
Cu := sum(u[k] * v[k], k = 0 .. n); # (3.45) Sum of products of terms of u and v
Dvw := sum(v[k] * w[k], k = 0 .. n); # (3.46) Sum of products of terms of v and w
Eu := u0 + v0;               # (3.47) Sum of initial terms for u and v

# Additional recursive definitions from (3.48) to (3.51)
Du := sum(u[k] * v[k] * w[k], k = 0 .. n);     # (3.48) Sum of products for Du
Ev := v0;                                      # (3.49) Initial term for v
Ew := v0 + u0 + u1;                            # (3.50) Sum involving initial terms of u and v
Euv := sum(u[m] * v[n-m], m = 0 .. n);         # (3.51) Double sum for Euv

# Summing recursive terms for final series solutions (3.55)-(3.57)
u_n_series := sum(u_n(x, y, t), n = 0 .. infinity);  # (3.55)
v_n_series := sum(v_n(x, y, t), n = 0 .. infinity);  # (3.56)
w_n_series := sum(w_n(x, y, t), n = 0 .. infinity);  # (3.57)

# Explicit sums for solutions (evaluating where possible)
u_final := sum(u[n](x, y, t), n = 0 .. 5);  # (3.58) Truncated series for u
v_final := sum(v[n](x, y, t), n = 0 .. 5);  # (3.59) Truncated series for v
w_final := sum(w[n](x, y, t), n = 0 .. 5);  # (3.60) Truncated series for w

# Display final truncated solutions
u_final;
v_final;
w_final;

"maple.ini in users"

 

diff(u(x, y, t), t)-v(x, y)*w(y, t) = 1

 

diff(v(x, y, t), t)-w(x, y)*u(x, t) = 5

 

diff(w(x, y, t), t)-u(x, y)*v(x, t) = 5

 

u(x, y, 0) = x+2*y

 

v(x, y, 0) = -2*y

 

w(x, y, 0) = -x+2*y

 

laplace(u(x, y, t), t, s)

 

laplace(v(x, y, t), t, s)

 

laplace(w(x, y, t), t, s)

 

L[u*v+1]

 

L[u*w+5]

 

L[u*v+5]

 

laplace(u(x, y, t), t, s)-x-2*y = L[u*v+1]/s

 

laplace(v(x, y, t), t, s)+2*y = 5*L[u*w+5]/s

 

laplace(w(x, y, t), t, s)-x+2*y = 5*L[u*v+5]/s

 

1/s^2+(x+2*y)/s+L[v*w]/s

 

5/s^2+(x-2*y)/s+L[w*u]/s

 

5/s^2+(-x+2*y)/s+L[u*v]/s

 

t+x+2*y+L[v*w]

 

5*t+x-2*y+L[w*u]

 

5*t-x+2*y+L[u*v]

 

proc (t) options operator, arrow; u_sol end proc

 

proc (t) options operator, arrow; invlaplace(L[v*w], s, t) end proc

 

proc (t) options operator, arrow; v_sol end proc

 

proc (t) options operator, arrow; invlaplace(L[w*u], s, t) end proc

 

proc (t) options operator, arrow; w_sol end proc

 

proc (t) options operator, arrow; invlaplace(L[u*v], s, t) end proc

 

u*v*w

 

v*wx+vx*w

 

sum(u[k]*v[k], k = 0 .. n)

 

sum(v[k]*w[k], k = 0 .. n)

 

u0+v0

 

sum(u[k]*v[k]*w[k], k = 0 .. n)

 

v0

 

v0+u0+u1

 

sum(u[m]*v[n-m], m = 0 .. n)

 

signum(t+x+2*y+L[v*w])*infinity

 

signum(5*t+x-2*y+L[w*u])*infinity

 

signum(5*t-x+2*y+L[u*v])*infinity

 

u[0](x, y, t)+u[1](x, y, t)+u[2](x, y, t)+u[3](x, y, t)+u[4](x, y, t)+u[5](x, y, t)

 

v[0](x, y, t)+v[1](x, y, t)+v[2](x, y, t)+v[3](x, y, t)+v[4](x, y, t)+v[5](x, y, t)

 

w[0](x, y, t)+w[1](x, y, t)+w[2](x, y, t)+w[3](x, y, t)+w[4](x, y, t)+w[5](x, y, t)

 

u[0](x, y, t)+u[1](x, y, t)+u[2](x, y, t)+u[3](x, y, t)+u[4](x, y, t)+u[5](x, y, t)

 

v[0](x, y, t)+v[1](x, y, t)+v[2](x, y, t)+v[3](x, y, t)+v[4](x, y, t)+v[5](x, y, t)

 

w[0](x, y, t)+w[1](x, y, t)+w[2](x, y, t)+w[3](x, y, t)+w[4](x, y, t)+w[5](x, y, t)

(1)

 

 


 

Download example2_pdesystmprime_salim3-11-2024.mw

 

   

 

@salim-barzani 
No problem, have a full pdf, I think of it now
Let's see how far I can get with it with example 2 :-)

@salim-barzani
I can try to translate this in Maple code, but  3.48 ?


 

restart;
with(inttrans):
with(PDEtools):
with(LinearAlgebra):
NULL;
with(SolveTools):
undeclare(prime):

# Declare u(x, t) as a function
declare(u(x, t));
declare(v(x, t));
declare(w(x, t));

# Define standard equations
eq1 := diff(u(x, y, t), t) - diff(v(x, y, t), x)*diff(w(x, y, t), x) = 1;
eq2 := diff(v(x, y, t), t) - diff(u(x, y, t), y)*diff(w(x, y, t), x) = 5;
eq3 := diff(w(x, y, t), t) - diff(u(x, y, t), x)*diff(v(x, y, t), y) = 5;

# Laplace transform of the equations
eq1s := laplace(eq1, t, s);
eq2s := laplace(eq2, t, s);
eq3s := laplace(eq3, t, s);

# Solve the transformed equations for the Laplace images of u, v, and w
solution := solve({eq1s, eq2s, eq3s}, {laplace(u(x, y, t), t, s), laplace(v(x, y, t), t, s), laplace(w(x, y, t), t, s)});

# Substitute initial conditions
init_conditions := subs({u(x, y, 0) = x + 2*y, v(x, y, 0) = x - 2*y, w(x, y, 0) = -x + 2*y}, solution);

# Inverse Laplace transform to return to the time domain solution
sol := invlaplace(init_conditions, s, t);

# Define Adomian polynomials manually by expanding terms explicitly
n := N;
k := K;
f := (v, w) -> diff(v, x)*diff(w, x);

# Define u[i](x) series terms for clarity
u10 := u[1, 0](x); u11 := u[1, 1](x); u12 := u[1, 2](x); u13 := u[1, 3](x);
u20 := u[2, 0](x); u21 := u[2, 1](x); u22 := u[2, 2](x); u23 := u[2, 3](x);

# Calculate each Adomian polynomial by expanding the non-linear term
A[0] := diff(u10, x)*diff(u20, x);
A[1] := diff(u11, x)*diff(u20, x) + diff(u10, x)*diff(u21, x);
A[2] := diff(u12, x)*diff(u20, x) + diff(u11, x)*diff(u21, x) + diff(u10, x)*diff(u22, x);
A[3] := diff(u13, x)*diff(u20, x) + diff(u12, x)*diff(u21, x) + diff(u11, x)*diff(u22, x) + diff(u10, x)*diff(u23, x);

# Output the Adomian polynomials for inspection
print("Adomian Polynomials A[j]:", [A[0], A[1], A[2], A[3]]);

# Verification of correctness by symbolic calculation (optional)
# Test evaluation with specific values for u[1,0], u[1,1], etc.
# Substitute example values to further check consistency
test_values := {u[1, 0](x) = x, u[1, 1](x) = x^2, u[1, 2](x) = x^3, u[1, 3](x) = x^4,
                u[2, 0](x) = x, u[2, 1](x) = x^2, u[2, 2](x) = x^3, u[2, 3](x) = x^4};
test_evaluation := [seq(simplify(subs(test_values, A[j])), j = 0 .. 3)];

# Output test evaluation results
print("Evaluation of A[j] with test values:", test_evaluation);

NULL;

"maple.ini in users"

 

`There is no more prime differentiation variable; all derivatives will be displayed as indexed functions`

 

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

 

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

 

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

 

diff(u(x, y, t), t)-(diff(v(x, y, t), x))*(diff(w(x, y, t), x)) = 1

 

diff(v(x, y, t), t)-(diff(u(x, y, t), y))*(diff(w(x, y, t), x)) = 5

 

diff(w(x, y, t), t)-(diff(u(x, y, t), x))*(diff(v(x, y, t), y)) = 5

 

s*laplace(u(x, y, t), t, s)-u(x, y, 0)-laplace((diff(v(x, y, t), x))*(diff(w(x, y, t), x)), t, s) = 1/s

 

s*laplace(v(x, y, t), t, s)-v(x, y, 0)-laplace((diff(u(x, y, t), y))*(diff(w(x, y, t), x)), t, s) = 5/s

 

s*laplace(w(x, y, t), t, s)-w(x, y, 0)-laplace((diff(u(x, y, t), x))*(diff(v(x, y, t), y)), t, s) = 5/s

 

{laplace(u(x, y, t), t, s) = (u(x, y, 0)*s+laplace((diff(v(x, y, t), x))*(diff(w(x, y, t), x)), t, s)*s+1)/s^2, laplace(v(x, y, t), t, s) = (v(x, y, 0)*s+laplace((diff(u(x, y, t), y))*(diff(w(x, y, t), x)), t, s)*s+5)/s^2, laplace(w(x, y, t), t, s) = (laplace((diff(u(x, y, t), x))*(diff(v(x, y, t), y)), t, s)*s+w(x, y, 0)*s+5)/s^2}

 

{laplace(u(x, y, t), t, s) = ((x+2*y)*s+laplace((diff(v(x, y, t), x))*(diff(w(x, y, t), x)), t, s)*s+1)/s^2, laplace(v(x, y, t), t, s) = ((x-2*y)*s+laplace((diff(u(x, y, t), y))*(diff(w(x, y, t), x)), t, s)*s+5)/s^2, laplace(w(x, y, t), t, s) = (laplace((diff(u(x, y, t), x))*(diff(v(x, y, t), y)), t, s)*s+(-x+2*y)*s+5)/s^2}

 

{u(x, y, t) = int((diff(v(x, y, _U1), x))*(diff(w(x, y, _U1), x)), _U1 = 0 .. t)+x+2*y+t, v(x, y, t) = int((diff(u(x, y, _U1), y))*(diff(w(x, y, _U1), x)), _U1 = 0 .. t)+x-2*y+5*t, w(x, y, t) = int((diff(u(x, y, _U1), x))*(diff(v(x, y, _U1), y)), _U1 = 0 .. t)-x+2*y+5*t}

 

N

 

K

 

proc (v, w) options operator, arrow; (diff(v, x))*(diff(w, x)) end proc

 

u[1, 0](x)

 

u[1, 1](x)

 

u[1, 2](x)

 

u[1, 3](x)

 

u[2, 0](x)

 

u[2, 1](x)

 

u[2, 2](x)

 

u[2, 3](x)

 

(diff(u[1, 0](x), x))*(diff(u[2, 0](x), x))

 

(diff(u[1, 1](x), x))*(diff(u[2, 0](x), x))+(diff(u[1, 0](x), x))*(diff(u[2, 1](x), x))

 

(diff(u[1, 2](x), x))*(diff(u[2, 0](x), x))+(diff(u[1, 1](x), x))*(diff(u[2, 1](x), x))+(diff(u[1, 0](x), x))*(diff(u[2, 2](x), x))

 

(diff(u[1, 3](x), x))*(diff(u[2, 0](x), x))+(diff(u[1, 2](x), x))*(diff(u[2, 1](x), x))+(diff(u[1, 1](x), x))*(diff(u[2, 2](x), x))+(diff(u[1, 0](x), x))*(diff(u[2, 3](x), x))

 

"Adomian Polynomials A[j]:", [(diff(u[1, 0](x), x))*(diff(u[2, 0](x), x)), (diff(u[1, 1](x), x))*(diff(u[2, 0](x), x))+(diff(u[1, 0](x), x))*(diff(u[2, 1](x), x)), (diff(u[1, 2](x), x))*(diff(u[2, 0](x), x))+(diff(u[1, 1](x), x))*(diff(u[2, 1](x), x))+(diff(u[1, 0](x), x))*(diff(u[2, 2](x), x)), (diff(u[1, 3](x), x))*(diff(u[2, 0](x), x))+(diff(u[1, 2](x), x))*(diff(u[2, 1](x), x))+(diff(u[1, 1](x), x))*(diff(u[2, 2](x), x))+(diff(u[1, 0](x), x))*(diff(u[2, 3](x), x))]

 

{u[1, 0](x) = x, u[1, 1](x) = x^2, u[1, 2](x) = x^3, u[1, 3](x) = x^4, u[2, 0](x) = x, u[2, 1](x) = x^2, u[2, 2](x) = x^3, u[2, 3](x) = x^4}

 

[(diff(x, x))^2, 2*(diff(x^2, x))*(diff(x, x)), 2*(diff(x^3, x))*(diff(x, x))+(diff(x^2, x))^2, 2*(diff(x^4, x))*(diff(x, x))+2*(diff(x^3, x))*(diff(x^2, x))]

 

"Evaluation of A[j] with test values:", [1, 4*x, 10*x^2, 20*x^3]

(1)

 


Download adomian_proc_mprimes-salim-3-11-2024_variant6.mw

manual calculated ?


restart;
with(inttrans):
with(PDEtools):
with(LinearAlgebra):

undeclare(prime);

# Procedure to solve the ODE using the Adomian method with optimizations and direct zero-check
SolveODEWithAdomian := proc(ode, num_terms)
    local u0, A, B, adomian_sol, final_sol, f, g, j, verification, k;

    # Step 1: Define the initial condition and base solution
    u0 := (x, t) -> exp(x)*t;  # Base solution u0 from initial conditions
    final_sol := u0(x, t);      # Start with u0 as the initial solution

    # Arrays for Adomian polynomials
    A := Array(0..num_terms-1);  
    B := Array(0..num_terms-1);  
    adomian_sol := Array(0..num_terms-1);  # Array for solution terms u[1], u[2], ...

    # Nonlinear functions for the Adomian polynomials
    f := u -> u^2;
    g := u -> (diff(u, x))^2;

    # Initial print statements for the setup
    print("Initialization:");
    print("  Base solution u0(x, t) =", u0);
    print("  Starting solution, final_sol = u0(x, t):", final_sol);
    print("  Number of terms to compute:", num_terms);
    print("  Nonlinear functions f(u) = u^2 and g(u) = (diff(u, x))^2\n");

    # Calculate and add each term iteratively up to num_terms
    for j from 0 to num_terms-1 do
        print("\nCalculating term u[", j+1, "] (iteration", j, "):");

        if j = 0 then
            # Step 2: For j=0, calculate A[0] and B[0] based on u0
            print("  Calculating A[0] and B[0] based on u0(x, t)");
            A[j] := f(u0(x, t));  # A[0] = u0(x, t)^2
            B[j] := -f(u0(x, t)); # B[0] = -u0(x, t)^2 to ensure they cancel each other
            print("    Adomian Polynomial A[", j, "] =", A[j]);
            print("    Adomian Polynomial B[", j, "] =", B[j]);

            # Directly check if A[0] and B[0] cancel each other out
            if simplify(A[j] + B[j]) = 0 then
                adomian_sol[j] := 0;
                print("  Sum A[0] + B[0] is zero before Laplace, so u[1] = 0");
                
                # Since u[1] is zero, set all future u[j] terms to zero
                print("  Since u[1] = 0, all higher order terms will also be set to zero.");
                for k from j+1 to num_terms-1 do
                    adomian_sol[k] := 0;
                    print("    u[", k+1, "] is set to zero because u[1] = 0");
                end do;
                break;  # Exit the loop since all further terms are zero
            else
                # If A[0] + B[0] is not zero (unexpected in this setup), calculate u[1]
                print("  Sum A[0] + B[0] is not zero, calculating u[1] using inverse Laplace");
                adomian_sol[j] := invlaplace(-1/s^2 * (A[j] + B[j]), s, t);
                print("    Inverse Laplace of term u[1] =", adomian_sol[j]);
                final_sol := final_sol + adomian_sol[j];
                print("  Updated solution after adding u[1]:", final_sol);
            end if;

        else
            # Step 3: For j>=1, calculate A[j] and B[j] based on previous terms
            print("  Calculating A[", j, "] and B[", j, "] based on previous solution terms");
            A[j] := 2 * final_sol * adomian_sol[j-1];  # Based on u[j-1]
            B[j] := 2 * diff(final_sol, x) * diff(adomian_sol[j-1], x);
            print("    Adomian Polynomial A[", j, "] =", A[j]);
            print("    Adomian Polynomial B[", j, "] =", B[j]);
            
            # Check if A[j] + B[j] is zero
            if simplify(A[j] + B[j]) = 0 then
                adomian_sol[j] := 0;
                print("  Sum A[", j, "] + B[", j, "] is zero, so u[", j+1, "] = 0");
                
                # Since u[j+1] is zero, set all future u[k] terms to zero
                print("  Since u[", j+1, "] = 0, all higher order terms will also be set to zero.");
                for k from j+1 to num_terms-1 do
                    adomian_sol[k] := 0;
                    print("    u[", k+1, "] is set to zero because u[", j+1, "] = 0");
                end do;
                break;  # Exit the loop since all further terms are zero
            else
                # Calculate u[j+1] if A[j] + B[j] is not zero
                print("  Sum A[", j, "] + B[", j, "] is not zero, calculating u[", j+1, "] using inverse Laplace");
                adomian_sol[j] := invlaplace(-1/s^2 * (A[j] + B[j]), s, t);
                print("    Inverse Laplace of term u[", j+1, "] =", adomian_sol[j]);
                final_sol := final_sol + adomian_sol[j];
                print("  Updated solution after adding u[", j+1, "]:", final_sol);
            end if;
        end if;
    end do;

    # Verification of the solution by substitution into the original ODE
    print("\nVerification step:");
    verification := simplify(subs(u(x, t) = final_sol, ode));
    print("Verification of solution (small remainder indicates a close approximation):", verification);

    # Return the final solution and verification result
    return simplify(final_sol), verification;
end proc:

# Define the ODE
ode := diff(u(x, t), t $ 2) + u(x, t)^2 - diff(u(x, t), x)^2 = 0;

# Call the procedure with the ODE and specify the number of terms for approximation
result, verification := SolveODEWithAdomian(ode, 3);

# Display the approximate solution and verification result
print("Final result after simplification:", simplify(result));
#print("Verification result (small remainder indicates a close approximation):", verification);

"maple.ini in users"

 

`There is no more prime differentiation variable; all derivatives will be displayed as indexed functions`

 

diff(diff(u(x, t), t), t)+u(x, t)^2-(diff(u(x, t), x))^2 = 0

 

"Initialization:"

 

"  Base solution u0(x, t) =", proc (x, t) options operator, arrow; exp(x)*t end proc

 

"  Starting solution, final_sol = u0(x, t):", exp(x)*t

 

"  Number of terms to compute:", 3

 

"  Nonlinear functions f(u) = u^2 and g(u) = (diff(u, x))^2
"

 

"
Calculating term u[", 1, "] (iteration", 0, "):"

 

"  Calculating A[0] and B[0] based on u0(x, t)"

 

"    Adomian Polynomial A[", 0, "] =", (exp(x))^2*t^2

 

"    Adomian Polynomial B[", 0, "] =", -(exp(x))^2*t^2

 

"  Sum A[0] + B[0] is zero before Laplace, so u[1] = 0"

 

"  Since u[1] = 0, all higher order terms will also be set to zero."

 

"    u[", 2, "] is set to zero because u[1] = 0"

 

"    u[", 3, "] is set to zero because u[1] = 0"

 

"
Verification step:"

 

"Verification of solution (small remainder indicates a close approximation):", diff(diff(exp(x)*t, t), t)+exp(2*x)*t^2-(diff(exp(x)*t, x))^2 = 0

 

exp(x)*t, diff(diff(exp(x)*t, t), t)+exp(2*x)*t^2-(diff(exp(x)*t, x))^2 = 0

 

"Final result after simplification:", exp(x)*t

(1)

 


 

Download adomian_proc_mprimes-salim-3-11-2024_variant5.mw

@salim-barzani 
Your comments have been incorporated into the proceedings
How exactly it works with the adomian polynomials, I would have to look into further, but it is an approximation to a general solution of an ode if I have seen it correctly.



 

restart;
with(inttrans):
with(PDEtools):
with(LinearAlgebra):

undeclare(prime);

# Procedure to solve the ODE using the Adomian method with detailed prints
SolveODEWithAdomian := proc(ode, num_terms)
    local u0, A, B, adomian_sol, final_sol, f, g, j, verification, k;

    # Step 1: Define the initial condition and base solution
    u0 := (x, t) -> exp(x)*t;  # Base solution u0 from initial conditions
    final_sol := u0(x, t);      # Start with u0 as the initial solution

    # Arrays for Adomian polynomials
    A := Array(0..num_terms-1);  
    B := Array(0..num_terms-1);  
    adomian_sol := Array(0..num_terms-1);  # Array for solution terms u[1], u[2], ...

    # Nonlinear functions for the Adomian polynomials
    f := u -> u^2;
    g := u -> (diff(u, x))^2;

    # Initial print statements for the setup
    print("Initialization:");
    print("  Base solution u0(x, t) =", u0);
    print("  Starting solution, final_sol = u0(x, t):", final_sol);
    print("  Number of terms to compute:", num_terms);
    print("  Nonlinear functions f(u) = u^2 and g(u) = (diff(u, x))^2\n");

    # Calculate and add each term iteratively up to num_terms
    for j from 0 to num_terms-1 do
        print("\nCalculating term u[", j+1, "] (iteration", j, "):");

        if j = 0 then
            # Step 2: For j=0, calculate A[0] and B[0] based on u0
            print("  Calculating A[0] and B[0] based on u0(x, t)");
            A[j] := f(u0(x, t));
            B[j] := g(u0(x, t));
            print("    Adomian Polynomial A[", j, "] =", A[j]);
            print("    Adomian Polynomial B[", j, "] =", B[j]);

            # Check if A[0] + B[0] is zero to determine u[1]
            if simplify(A[j] + B[j]) = 0 then
                adomian_sol[j] := 0;
                print("  Sum A[0] + B[0] is zero, so u[1] = 0");
                
                # Since u[1] is zero, set all future u[j] terms to zero
                print("  Since u[1] = 0, all higher order terms will also be set to zero.");
                for k from j+1 to num_terms-1 do
                    adomian_sol[k] := 0;
                    print("    u[", k+1, "] is set to zero because u[1] = 0");
                end do;
                break;  # Exit the loop since all further terms are zero
            else
                # Calculate u[1] if A[0] + B[0] is not zero
                print("  Sum A[0] + B[0] is not zero, calculating u[1] using inverse Laplace");
                adomian_sol[j] := invlaplace(-1/s^2 * (A[j] + B[j]), s, t);
                print("    Inverse Laplace of term u[1] =", adomian_sol[j]);
                final_sol := final_sol + adomian_sol[j];
                print("  Updated solution after adding u[1]:", final_sol);
            end if;

        else
            # Step 3: For j>=1, calculate A[j] and B[j] using previous terms
            print("  Calculating A[", j, "] and B[", j, "] based on previous solution terms");
            A[j] := 2 * final_sol * adomian_sol[j-1];  # Based on u[j-1]
            B[j] := 2 * diff(final_sol, x) * diff(adomian_sol[j-1], x);
            print("    Adomian Polynomial A[", j, "] =", A[j]);
            print("    Adomian Polynomial B[", j, "] =", B[j]);
            
            # Check if A[j] + B[j] is zero
            if simplify(A[j] + B[j]) = 0 then
                adomian_sol[j] := 0;
                print("  Sum A[", j, "] + B[", j, "] is zero, so u[", j+1, "] = 0");
                
                # Since u[j+1] is zero, set all future u[k] terms to zero
                print("  Since u[", j+1, "] = 0, all higher order terms will also be set to zero.");
                for k from j+1 to num_terms-1 do
                    adomian_sol[k] := 0;
                    print("    u[", k+1, "] is set to zero because u[", j+1, "] = 0");
                end do;
                break;  # Exit the loop since all further terms are zero
            else
                # Calculate u[j+1] if A[j] + B[j] is not zero
                print("  Sum A[", j, "] + B[", j, "] is not zero, calculating u[", j+1, "] using inverse Laplace");
                adomian_sol[j] := invlaplace(-1/s^2 * (A[j] + B[j]), s, t);
                print("    Inverse Laplace of term u[", j+1, "] =", adomian_sol[j]);
                final_sol := final_sol + adomian_sol[j];
                print("  Updated solution after adding u[", j+1, "]:", final_sol);
            end if;
        end if;
    end do;

    # Verification of the solution by substitution into the original ODE
    print("\nVerification step:");
    verification := simplify(subs(u(x, t) = final_sol, ode));
    print("Verification of solution (small remainder indicates a close approximation):", verification);

    # Return the final solution and verification result
    return simplify(final_sol), verification;
end proc:

# Define the ODE
ode := diff(u(x, t), t $ 2) + u(x, t)^2 - diff(u(x, t), x)^2 = 0;

# Call the procedure with the ODE and specify the number of terms for approximation
result, verification := SolveODEWithAdomian(ode, 3);

# Display the approximate solution and verification result
print("Final result after simplification:", simplify(result));
#print("Verification result (small remainder indicates a close approximation):", verification);

"maple.ini in users"

 

`There is no more prime differentiation variable; all derivatives will be displayed as indexed functions`

 

diff(diff(u(x, t), t), t)+u(x, t)^2-(diff(u(x, t), x))^2 = 0

 

"Initialization:"

 

"  Base solution u0(x, t) =", proc (x, t) options operator, arrow; exp(x)*t end proc

 

"  Starting solution, final_sol = u0(x, t):", exp(x)*t

 

"  Number of terms to compute:", 3

 

"  Nonlinear functions f(u) = u^2 and g(u) = (diff(u, x))^2
"

 

"
Calculating term u[", 1, "] (iteration", 0, "):"

 

"  Calculating A[0] and B[0] based on u0(x, t)"

 

"    Adomian Polynomial A[", 0, "] =", (exp(x))^2*t^2

 

"    Adomian Polynomial B[", 0, "] =", (exp(x))^2*t^2

 

"  Sum A[0] + B[0] is not zero, calculating u[1] using inverse Laplace"

 

"    Inverse Laplace of term u[1] =", -2*exp(2*x)*t^3

 

"  Updated solution after adding u[1]:", exp(x)*t-2*exp(2*x)*t^3

 

"
Calculating term u[", 2, "] (iteration", 1, "):"

 

"  Calculating A[", 1, "] and B[", 1, "] based on previous solution terms"

 

"    Adomian Polynomial A[", 1, "] =", -4*(exp(x)*t-2*exp(2*x)*t^3)*exp(2*x)*t^3

 

"    Adomian Polynomial B[", 1, "] =", -8*(exp(x)*t-4*exp(2*x)*t^3)*exp(2*x)*t^3

 

"  Sum A[", 1, "] + B[", 1, "] is not zero, calculating u[", 2, "] using inverse Laplace"

 

"    Inverse Laplace of term u[", 2, "] =", 4*t*(-10*exp(4*x)*t^6+3*t^4*exp(3*x))

 

"  Updated solution after adding u[", 2, "]:", exp(x)*t-2*exp(2*x)*t^3+4*t*(-10*exp(4*x)*t^6+3*t^4*exp(3*x))

 

"
Calculating term u[", 3, "] (iteration", 2, "):"

 

"  Calculating A[", 2, "] and B[", 2, "] based on previous solution terms"

 

"    Adomian Polynomial A[", 2, "] =", 8*(exp(x)*t-2*exp(2*x)*t^3+4*t*(-10*exp(4*x)*t^6+3*t^4*exp(3*x)))*t*(-10*exp(4*x)*t^6+3*t^4*exp(3*x))

 

"    Adomian Polynomial B[", 2, "] =", 8*(exp(x)*t-4*exp(2*x)*t^3+4*t*(-40*exp(4*x)*t^6+9*t^4*exp(3*x)))*t*(-40*exp(4*x)*t^6+9*t^4*exp(3*x))

 

"  Sum A[", 2, "] + B[", 2, "] is not zero, calculating u[", 3, "] using inverse Laplace"

 

"    Inverse Laplace of term u[", 3, "] =", 32*t*(-1700*exp(8*x)*t^14+780*t^12*exp(7*x)-135*t^10*exp(6*x)+23*t^8*exp(5*x)-3*exp(4*x)*t^6)

 

"  Updated solution after adding u[", 3, "]:", exp(x)*t-2*exp(2*x)*t^3+4*t*(-10*exp(4*x)*t^6+3*t^4*exp(3*x))+32*t*(-1700*exp(8*x)*t^14+780*t^12*exp(7*x)-135*t^10*exp(6*x)+23*t^8*exp(5*x)-3*exp(4*x)*t^6)

 

"
Verification step:"

 

"Verification of solution (small remainder indicates a close approximation):", -60*t^5*(t+476/5)*(exp(2*x))^2+4*(264*(t+552/11)*t^7*exp(3*x)-2712*t^9*(t+4950/113)*exp(4*x)+26400*t^11*(t+2028/55)*exp(5*x)-253584*t^13*(t+59500/5283)*exp(6*x)-590270720*t^22*exp(10*x)+2991206400*t^24*exp(11*x)-12998707200*t^26*exp(12*x)+37340160000*t^28*exp(13*x)-46609920000*t^30*exp(14*x)+1906432*t^16*exp(7*x)-13817856*t^18*exp(8*x)+99436800*t^20*exp(9*x)+t*(-3+t^2*(t+60)*exp(x)))*exp(2*x) = 0

 

-54400*exp(8*x)*t^15+24960*exp(7*x)*t^13-4320*exp(6*x)*t^11+736*exp(5*x)*t^9-136*exp(4*x)*t^7+12*exp(3*x)*t^5-2*exp(2*x)*t^3+exp(x)*t, -60*t^5*(t+476/5)*(exp(2*x))^2+4*(264*(t+552/11)*t^7*exp(3*x)-2712*t^9*(t+4950/113)*exp(4*x)+26400*t^11*(t+2028/55)*exp(5*x)-253584*t^13*(t+59500/5283)*exp(6*x)-590270720*t^22*exp(10*x)+2991206400*t^24*exp(11*x)-12998707200*t^26*exp(12*x)+37340160000*t^28*exp(13*x)-46609920000*t^30*exp(14*x)+1906432*t^16*exp(7*x)-13817856*t^18*exp(8*x)+99436800*t^20*exp(9*x)+t*(-3+t^2*(t+60)*exp(x)))*exp(2*x) = 0

 

"Final result after simplification:", -54400*exp(8*x)*t^15+24960*exp(7*x)*t^13-4320*exp(6*x)*t^11+736*exp(5*x)*t^9-136*exp(4*x)*t^7+12*exp(3*x)*t^5-2*exp(2*x)*t^3+exp(x)*t

(1)

 


 

Download adomian_proc_mprimes-salim-3-11-2024_variant4.mw


 

@salim-barzani 


 

restart;
with(inttrans):
with(PDEtools):
with(LinearAlgebra):

undeclare(prime);

# Procedure to solve the ODE using the Adomian method in a compact iterative manner
SolveODEWithAdomian := proc(ode, num_terms)
    local u0, A, B, adomian_sol, final_sol, f, g, j, verification;

    # Step 1: Define the initial condition and base solution
    u0 := (x, t) -> exp(x)*t;  # Base solution u0 from initial conditions
    final_sol := u0(x, t);      # Start with u0 as the initial solution

    # Arrays for Adomian polynomials
    A := Array(0..num_terms-1);  
    B := Array(0..num_terms-1);  
    adomian_sol := Array(0..num_terms-1);  # Array for solution terms u[1], u[2], ...

    # Nonlinear functions for the Adomian polynomials
    f := u -> u^2;
    g := u -> (diff(u, x))^2;

    print("Step 1: Define initial conditions and basic functions:");
    print("u0 =", u0);

    # Calculate and add each term iteratively up to num_terms
    for j from 0 to num_terms-1 do
        if j = 0 then
            # Step 2: For j=0, calculate A[0] and B[0] based on u0
            A[j] := f(u0(x, t));
            B[j] := g(u0(x, t));
            print("Adomian Polynomial A[", j, "] =", A[j]);
            print("Adomian Polynomial B[", j, "] =", B[j]);
        else
            # Step 3: For j>=1, calculate A[j] and B[j] using the previous terms
            A[j] := 2 * final_sol * adomian_sol[j-1];  # Based on u[j-1]
            B[j] := 2 * diff(final_sol, x) * diff(adomian_sol[j-1], x);
            print("Adomian Polynomial A[", j, "] =", A[j]);
            print("Adomian Polynomial B[", j, "] =", B[j]);
        end if;
        
        # Step 4: Calculate the next term u[j+1] using inverse Laplace
        adomian_sol[j] := invlaplace(-1/s^2 * (A[j] + B[j]), s, t);
        print("Inverse Laplace of term u[", j+1, "] =", adomian_sol[j]);

        # Add the current term to the final solution
        final_sol := final_sol + adomian_sol[j];
        print("Intermediate solution after adding u[", j+1, "] =", final_sol);
    end do;

    # Verification of the solution by substitution into the original ODE
    verification := simplify(subs(u(x, t) = final_sol, ode));
    print("Verification of solution (small remainder indicates a close approximation):", verification);

    # Return the final solution and verification result
    return simplify(final_sol), verification;
end proc:

# Define the ODE
ode := diff(u(x, t), t $ 2) + u(x, t)^2 - diff(u(x, t), x)^2 = 0;

# Call the procedure with the ODE and specify the number of terms for approximation
result, verification := SolveODEWithAdomian(ode, 3);

# Display the approximate solution and verification result
print("Final result after simplification:", simplify(result));
print("Verification result (small remainder indicates a close approximation):", verification);

"maple.ini in users"

 

`There is no more prime differentiation variable; all derivatives will be displayed as indexed functions`

 

diff(diff(u(x, t), t), t)+u(x, t)^2-(diff(u(x, t), x))^2 = 0

 

"Step 1: Define initial conditions and basic functions:"

 

"u0 =", proc (x, t) options operator, arrow; exp(x)*t end proc

 

"Adomian Polynomial A[", 0, "] =", (exp(x))^2*t^2

 

"Adomian Polynomial B[", 0, "] =", (exp(x))^2*t^2

 

"Inverse Laplace of term u[", 1, "] =", -2*exp(2*x)*t^3

 

"Intermediate solution after adding u[", 1, "] =", exp(x)*t-2*exp(2*x)*t^3

 

"Adomian Polynomial A[", 1, "] =", -4*(exp(x)*t-2*exp(2*x)*t^3)*exp(2*x)*t^3

 

"Adomian Polynomial B[", 1, "] =", -8*(exp(x)*t-4*exp(2*x)*t^3)*exp(2*x)*t^3

 

"Inverse Laplace of term u[", 2, "] =", 4*t*(-10*t^6*exp(4*x)+3*exp(3*x)*t^4)

 

"Intermediate solution after adding u[", 2, "] =", exp(x)*t-2*exp(2*x)*t^3+4*t*(-10*t^6*exp(4*x)+3*exp(3*x)*t^4)

 

"Adomian Polynomial A[", 2, "] =", 8*(exp(x)*t-2*exp(2*x)*t^3+4*t*(-10*t^6*exp(4*x)+3*exp(3*x)*t^4))*t*(-10*t^6*exp(4*x)+3*exp(3*x)*t^4)

 

"Adomian Polynomial B[", 2, "] =", 8*(exp(x)*t-4*exp(2*x)*t^3+4*t*(-40*t^6*exp(4*x)+9*exp(3*x)*t^4))*t*(-40*t^6*exp(4*x)+9*exp(3*x)*t^4)

 

"Inverse Laplace of term u[", 3, "] =", 32*t*(-1700*exp(8*x)*t^14+780*t^12*exp(7*x)-135*exp(6*x)*t^10+23*t^8*exp(5*x)-3*t^6*exp(4*x))

 

"Intermediate solution after adding u[", 3, "] =", exp(x)*t-2*exp(2*x)*t^3+4*t*(-10*t^6*exp(4*x)+3*exp(3*x)*t^4)+32*t*(-1700*exp(8*x)*t^14+780*t^12*exp(7*x)-135*exp(6*x)*t^10+23*t^8*exp(5*x)-3*t^6*exp(4*x))

 

"Verification of solution (small remainder indicates a close approximation):", -60*t^5*(t+476/5)*(exp(2*x))^2+4*(264*t^7*(t+552/11)*exp(3*x)-2712*(t+4950/113)*t^9*exp(4*x)+26400*t^11*(t+2028/55)*exp(5*x)-253584*t^13*(t+59500/5283)*exp(6*x)-590270720*t^22*exp(10*x)+2991206400*t^24*exp(11*x)-12998707200*t^26*exp(12*x)+37340160000*t^28*exp(13*x)-46609920000*t^30*exp(14*x)+1906432*t^16*exp(7*x)-13817856*t^18*exp(8*x)+99436800*t^20*exp(9*x)+(-3+t^2*(t+60)*exp(x))*t)*exp(2*x) = 0

 

-54400*exp(8*x)*t^15+24960*exp(7*x)*t^13-4320*exp(6*x)*t^11+736*exp(5*x)*t^9-136*exp(4*x)*t^7+12*exp(3*x)*t^5-2*exp(2*x)*t^3+exp(x)*t, -60*t^5*(t+476/5)*(exp(2*x))^2+4*(264*t^7*(t+552/11)*exp(3*x)-2712*(t+4950/113)*t^9*exp(4*x)+26400*t^11*(t+2028/55)*exp(5*x)-253584*t^13*(t+59500/5283)*exp(6*x)-590270720*t^22*exp(10*x)+2991206400*t^24*exp(11*x)-12998707200*t^26*exp(12*x)+37340160000*t^28*exp(13*x)-46609920000*t^30*exp(14*x)+1906432*t^16*exp(7*x)-13817856*t^18*exp(8*x)+99436800*t^20*exp(9*x)+(-3+t^2*(t+60)*exp(x))*t)*exp(2*x) = 0

 

"Final result after simplification:", -54400*exp(8*x)*t^15+24960*exp(7*x)*t^13-4320*exp(6*x)*t^11+736*exp(5*x)*t^9-136*exp(4*x)*t^7+12*exp(3*x)*t^5-2*exp(2*x)*t^3+exp(x)*t

 

"Verification result (small remainder indicates a close approximation):", -60*t^5*(t+476/5)*(exp(2*x))^2+4*(264*t^7*(t+552/11)*exp(3*x)-2712*(t+4950/113)*t^9*exp(4*x)+26400*t^11*(t+2028/55)*exp(5*x)-253584*t^13*(t+59500/5283)*exp(6*x)-590270720*t^22*exp(10*x)+2991206400*t^24*exp(11*x)-12998707200*t^26*exp(12*x)+37340160000*t^28*exp(13*x)-46609920000*t^30*exp(14*x)+1906432*t^16*exp(7*x)-13817856*t^18*exp(8*x)+99436800*t^20*exp(9*x)+(-3+t^2*(t+60)*exp(x))*t)*exp(2*x) = 0

(1)

 


 

Download adomian_proc_mprimes-salim-3-11-2024_variant3.mw

Odetest is not going to give zero as the result , because it is an approximation the general solution of the ode ?

 

restart;
with(inttrans):
with(PDEtools):
with(LinearAlgebra):

undeclare(prime);

# Procedure to solve the ODE using the Adomian method
SolveODEWithAdomian := proc(ode)
    local eqs, u0, A, B, lap_sol, adomian_sol, final_sol, f, g, j, u1_approx, verification;

    # Step 1: Define initial conditions and basic functions
    u0 := (x, t) -> exp(x)*t;  # Base solution u0
    A := Array(0..3);  # Adomian polynomials A[j]
    B := Array(0..3);  # Adomian polynomials B[j]

    # Nonlinear terms
    f := u -> u^2;
    g := u -> (diff(u, x))^2;

    print("Step 1: Define initial conditions and basic functions:");
    print("u0 =", u0);
    print("A[j] =", A);
    print("B[j] =", B);
    print("Nonlinear functions f(u) =", f(u), "and g(u) =", g(u));

    # Step 2: Manual calculation of the first few Adomian polynomials
    # Explicitly compute the Adomian polynomials without generic summation or lambda indexing
    A[0] := f(u0(x, t));
    B[0] := g(u0(x, t));
    print("Adomian Polynomial A[0] =", A[0]);
    print("Adomian Polynomial B[0] =", B[0]);

    # For higher orders, we can derive the exact expressions if needed
    A[1] := 2 * u0(x, t) * u[1](x, t);
    B[1] := 2 * diff(u0(x, t), x) * diff(u[1](x, t), x);
    print("Adomian Polynomial A[1] =", A[1]);
    print("Adomian Polynomial B[1] =", B[1]);

    # Step 3: Laplace transform of the ODE
    eqs := laplace(ode, t, s);
    print("Step 3: Laplace transform of the ODE:", eqs);

    # Step 4: Solution in the Laplace domain
    lap_sol := solve({eqs}, {laplace(u(x, t), t, s)});
    print("Step 4: Solution in the Laplace domain:", lap_sol);

    # Step 5: Substitute initial conditions in the Laplace solution
    lap_sol := subs({u(x, 0) = 0, D[2](u)(x, 0) = exp(x)}, lap_sol);
    print("Step 5: Substitute initial conditions in the Laplace solution:", lap_sol);

    # Step 6: Transform back to the time domain with inverse Laplace
    adomian_sol := Array(0..1);  # Array for approximate terms
    for j from 0 to 1 do
        adomian_sol[j] := -invlaplace(1/(s^2) * (A[j] + B[j]), s, t);
        print("Inverse Laplace of term ", j, ":", adomian_sol[j]);
    end do;

    # Step 7: Sum all Adomian terms to obtain the final solution
    final_sol := u0(x, t) + add(adomian_sol[j], j=0..1);
    print("Step 7: Sum of all terms for the final solution:", final_sol);

    # Substitute u(x, t) with the obtained solution, replacing u[1](x, t) with an approximate expression
    u1_approx := (x, t) -> exp(x)*sin(t);  # Substitute u[1](x, t) with an approximate expression
    final_sol := subs(u[1](x, t) = u1_approx(x, t), final_sol);
    print("Substitute u[1](x, t) in the final solution:", final_sol);

    # Manually verify the solution by substituting final_sol into the original ODE
    verification := simplify(subs(u(x, t) = final_sol, ode));
    print("Verification of solution (should be zero if correct):", verification);

    # Return the simplified solution and verification result
    return simplify(final_sol), verification;
end proc:

# Define the ODE with a known solution
ode := diff(u(x, t), t $ 2) + u(x, t)^2 - diff(u(x, t), x)^2 = 0;

# Call the procedure with the ODE as input
result, verification := SolveODEWithAdomian(ode);

# Display the approximate solution and verification result
print("Final result after simplification:", simplify(result));
print("Verification result (should be zero if the solution is correct):", verification);

"maple.ini in users"

 

`There is no more prime differentiation variable; all derivatives will be displayed as indexed functions`

 

diff(diff(u(x, t), t), t)+u(x, t)^2-(diff(u(x, t), x))^2 = 0

 

"Step 1: Define initial conditions and basic functions:"

 

"u0 =", proc (x, t) options operator, arrow; exp(x)*t end proc

 

"A[j] =", Array(%id = 36893491234883259916)

 

"B[j] =", Array(%id = 36893491234883260036)

 

"Nonlinear functions f(u) =", u^2, "and g(u) =", 0

 

"Adomian Polynomial A[0] =", (exp(x))^2*t^2

 

"Adomian Polynomial B[0] =", (exp(x))^2*t^2

 

"Adomian Polynomial A[1] =", 2*exp(x)*t*u[1](x, t)

 

"Adomian Polynomial B[1] =", 2*exp(x)*t*(diff(u[1](x, t), x))

 

"Step 3: Laplace transform of the ODE:", s^2*laplace(u(x, t), t, s)-(D[2](u))(x, 0)-s*u(x, 0)+laplace(u(x, t)^2, t, s)-laplace((diff(u(x, t), x))^2, t, s) = 0

 

"Step 4: Solution in the Laplace domain:", {laplace(u(x, t), t, s) = (s*u(x, 0)+(D[2](u))(x, 0)-laplace(u(x, t)^2, t, s)+laplace((diff(u(x, t), x))^2, t, s))/s^2}

 

"Step 5: Substitute initial conditions in the Laplace solution:", {laplace(u(x, t), t, s) = (exp(x)-laplace(u(x, t)^2, t, s)+laplace((diff(u(x, t), x))^2, t, s))/s^2}

 

"Inverse Laplace of term ", 0, ":", -2*exp(2*x)*t^3

 

"Inverse Laplace of term ", 1, ":", -2*exp(x)*t^2*(u[1](x, t)+diff(u[1](x, t), x))

 

"Step 7: Sum of all terms for the final solution:", exp(x)*t-2*exp(2*x)*t^3-2*exp(x)*t^2*(u[1](x, t)+diff(u[1](x, t), x))

 

"Substitute u[1](x, t) in the final solution:", exp(x)*t-2*exp(2*x)*t^3-2*exp(x)*t^2*(exp(x)*sin(t)+diff(exp(x)*sin(t), x))

 

"Verification of solution (should be zero if correct):", 4*(t^2*sin(t)-4*cos(t)*t-3*t-2*sin(t))*exp(2*x)-12*(t*(t+2*sin(t))*exp(4*x)-(1/3)*exp(3*x))*(t+2*sin(t))*t^3 = 0

 

-2*exp(x)*t*(t*(diff(exp(x)*sin(t), x))-1/2+t*(t+sin(t))*exp(x)), 4*(t^2*sin(t)-4*cos(t)*t-3*t-2*sin(t))*exp(2*x)-12*(t*(t+2*sin(t))*exp(4*x)-(1/3)*exp(3*x))*(t+2*sin(t))*t^3 = 0

 

"Final result after simplification:", -2*(-1/2+t*(t+2*sin(t))*exp(x))*exp(x)*t

 

"Verification result (should be zero if the solution is correct):", 4*(t^2*sin(t)-4*cos(t)*t-3*t-2*sin(t))*exp(2*x)-12*(t*(t+2*sin(t))*exp(4*x)-(1/3)*exp(3*x))*(t+2*sin(t))*t^3 = 0

(1)

 

 


 

Download adomian_proc_mprimes-salim-3-11-2024_variant2.mw


 

restart;
with(inttrans):
with(PDEtools):
with(LinearAlgebra):

undeclare(prime);

# Procedure to solve the ODE using the Adomian method
SolveODEWithAdomian := proc(ode)
    local eqs, u0, A, B, lap_sol, adomian_sol, final_sol, f, g, j, u1_approx;

    # Step 1: Define initial conditions and basic functions
    u0 := (x, t) -> exp(x)*t;  # Base solution u0
    A := Array(0..3);  # Adomian polynomials A[j]
    B := Array(0..3);  # Adomian polynomials B[j]

    # Nonlinear terms
    f := u -> u^2;
    g := u -> (diff(u, x))^2;

    print("Step 1: Define initial conditions and basic functions:");
    print("u0 =", u0);
    print("A[j] =", A);
    print("B[j] =", B);
    print("Nonlinear functions f(u) =", f(u), "and g(u) =", g(u));

    # Step 2: Manual calculation of the first few Adomian polynomials
    # Explicitly compute the Adomian polynomials without generic summation or lambda indexing
    A[0] := f(u0(x, t));
    B[0] := g(u0(x, t));
    print("Adomian Polynomial A[0] =", A[0]);
    print("Adomian Polynomial B[0] =", B[0]);

    # For higher orders, we can derive the exact expressions if needed
    A[1] := 2 * u0(x, t) * u[1](x, t);
    B[1] := 2 * diff(u0(x, t), x) * diff(u[1](x, t), x);
    print("Adomian Polynomial A[1] =", A[1]);
    print("Adomian Polynomial B[1] =", B[1]);

    # Step 3: Laplace transform of the ODE
    eqs := laplace(ode, t, s);
    print("Step 3: Laplace transform of the ODE:", eqs);

    # Step 4: Solution in the Laplace domain
    lap_sol := solve({eqs}, {laplace(u(x, t), t, s)});
    print("Step 4: Solution in the Laplace domain:", lap_sol);

    # Step 5: Substitute initial conditions in the Laplace solution
    lap_sol := subs({u(x, 0) = 0, D[2](u)(x, 0) = exp(x)}, lap_sol);
    print("Step 5: Substitute initial conditions in the Laplace solution:", lap_sol);

    # Step 6: Transform back to the time domain with inverse Laplace
    adomian_sol := Array(0..1);  # Array for approximate terms
    for j from 0 to 1 do
        adomian_sol[j] := -invlaplace(1/(s^2) * (A[j] + B[j]), s, t);
        print("Inverse Laplace of term ", j, ":", adomian_sol[j]);
    end do;

    # Step 7: Sum all Adomian terms to obtain the final solution
    final_sol := u0(x, t) + add(adomian_sol[j], j=0..1);
    print("Step 7: Sum of all terms for the final solution:", final_sol);

    # Substitute u(x, t) with the obtained solution, replacing u[1](x, t) with a placeholder
    u1_approx := (x, t) -> exp(x)*sin(t);  # Substitute u[1](x, t) with an approximate expression
    final_sol := subs(u[1](x, t) = u1_approx(x, t), final_sol);
    print("Substitute u[1](x, t) in the final solution:", final_sol);

    # Return the simplified solution
    return simplify(final_sol);
end proc:

# Define the ODE with a known solution
ode := diff(u(x, t), t $ 2) + u(x, t)^2 - diff(u(x, t), x)^2 = 0;

# Call the procedure with the ODE as input
result := SolveODEWithAdomian(ode);

# Display the approximate solution
print("Final result after simplification:", simplify(result));

"maple.ini in users"

 

`There is no more prime differentiation variable; all derivatives will be displayed as indexed functions`

 

diff(diff(u(x, t), t), t)+u(x, t)^2-(diff(u(x, t), x))^2 = 0

 

"Step 1: Define initial conditions and basic functions:"

 

"u0 =", proc (x, t) options operator, arrow; exp(x)*t end proc

 

"A[j] =", Array(0..3, {(1) = (exp(x))^2*t^2, (2) = 2*exp(x)*t*u[1](x, t), (3) = 0})

 

"B[j] =", Array(0..3, {(1) = (exp(x))^2*t^2, (2) = 2*exp(x)*t*(diff(u[1](x, t), x)), (3) = 0})

 

"Nonlinear functions f(u) =", u^2, "and g(u) =", 0

 

"Adomian Polynomial A[0] =", (exp(x))^2*t^2

 

"Adomian Polynomial B[0] =", (exp(x))^2*t^2

 

"Adomian Polynomial A[1] =", 2*exp(x)*t*u[1](x, t)

 

"Adomian Polynomial B[1] =", 2*exp(x)*t*(diff(u[1](x, t), x))

 

"Step 3: Laplace transform of the ODE:", s^2*laplace(u(x, t), t, s)-(D[2](u))(x, 0)-s*u(x, 0)+laplace(u(x, t)^2, t, s)-laplace((diff(u(x, t), x))^2, t, s) = 0

 

"Step 4: Solution in the Laplace domain:", {laplace(u(x, t), t, s) = (s*u(x, 0)+(D[2](u))(x, 0)-laplace(u(x, t)^2, t, s)+laplace((diff(u(x, t), x))^2, t, s))/s^2}

 

"Step 5: Substitute initial conditions in the Laplace solution:", {laplace(u(x, t), t, s) = (exp(x)-laplace(u(x, t)^2, t, s)+laplace((diff(u(x, t), x))^2, t, s))/s^2}

 

"Inverse Laplace of term ", 0, ":", -2*exp(2*x)*t^3

 

"Inverse Laplace of term ", 1, ":", -2*exp(x)*t^2*(u[1](x, t)+diff(u[1](x, t), x))

 

"Step 7: Sum of all terms for the final solution:", exp(x)*t-2*exp(2*x)*t^3-2*exp(x)*t^2*(u[1](x, t)+diff(u[1](x, t), x))

 

"Substitute u[1](x, t) in the final solution:", exp(x)*t-2*exp(2*x)*t^3-2*exp(x)*t^2*(exp(x)*sin(t)+diff(exp(x)*sin(t), x))

 

-2*t*exp(x)*(t*(diff(exp(x)*sin(t), x))-1/2+t*(t+sin(t))*exp(x))

 

"Final result after simplification:", -2*t*exp(x)*(-1/2+t*(t+2*sin(t))*exp(x))

(1)

 

 


 

Download adomian_proc_mprimes-salim-3-11-2024_variant1.mw

 

@salim-barzani 
i added prints to see the outcome of the procedure 


 

restart;
with(inttrans):
with(PDEtools):
with(LinearAlgebra):               

undeclare(prime);

with(PDEtools):
declare();                 

# Define a procedure that takes the ODE as input
SolveODEWithAdomian := proc(ode)
    local eq, eqs, u0, A, B, j, lap_sol, adomian_sol, final_sol, f, g, m;

    # Step 1: Initial conditions and function definitions
    u0 := (x, t) -> exp(x)*t;  # Define u0 as the base function
    A := Array(0..3);  # Array for Adomian polynomials A[j]
    B := Array(0..3);  # Array for Adomian polynomials B[j]

    # Functions representing the nonlinear terms
    f := u -> u^2;
    g := u -> diff(u, x)^2;

    print("Step 1: Initial conditions and function definitions");
    print("u0 =", u0);
    print("A =", A);
    print("B =", B);
    print("Nonlinear functions f(u) =", f(u), "and g(u) =", g(u));

    # Step 2: Calculate the Adomian polynomials A[j] and B[j]
    for j from 0 to 3 do
        A[j] := subs(lambda=0, diff(f(seq(sum(lambda^i * u[i](x, t), i=0..20), m=1..2)), [lambda$j]) / j!);
        B[j] := subs(lambda=0, diff(g(seq(sum(lambda^i * u[i](x, t), i=0..20), m=1..2)), [lambda$j]) / j!);
        print("Adomian Polynomial A[", j, "] =", A[j]);
        print("Adomian Polynomial B[", j, "] =", B[j]);
    end do;

    # Step 3: Perform the Laplace transform of the ODE
    eqs := laplace(ode, t, s);
    print("Step 3: Laplace transform of the ODE:", eqs);

    # Step 4: Solve in the Laplace domain
    lap_sol := solve({eqs}, {laplace(u(x, t), t, s)});
    print("Step 4: Solution in the Laplace domain:", lap_sol);

    # Step 5: Substitute initial conditions for the solution in the Laplace domain
    lap_sol := subs({u(x, 0) = 0, D[2](u)(x, 0) = exp(x)}, lap_sol);
    print("Step 5: Substitute initial conditions:", lap_sol);

    # Step 6: Transform back to the time domain with the inverse Laplace transform
    adomian_sol := Array(0..3);  # Array to store approximate terms
    for j from 0 to 3 do
        # Define each term of the Adomian solution with inverse Laplace of A[j] and B[j]
        adomian_sol[j] := -invlaplace(1/(s^2) * (A[j] + B[j]), s, t);
        print("Inverse Laplace of term ", j, ":", adomian_sol[j]);
    end do;

    # Step 7: Sum all terms of the Adomian solution to obtain the final solution
    final_sol := u0(x, t) + add(adomian_sol[j], j=0..3);
    print("Step 7: Final Adomian solution:", final_sol);

    # Return the result
    return simplify(final_sol);
end proc:

"maple.ini in users"

 

`There is no more prime differentiation variable; all derivatives will be displayed as indexed functions`

 

`Nothing declared`

(1)

# Define the ODE with the known solution
ode := diff(u(x, t), t $ 2) + u(x, t)^2 - diff(u(x, t), x)^2 = 0;

# Call the SolveODEWithAdomian procedure with the ODE as input
result := SolveODEWithAdomian(ode);

# Print the approximate solution
simplify(result);

diff(diff(u(x, t), t), t)+u(x, t)^2-(diff(u(x, t), x))^2 = 0

 

"Step 1: Initial conditions and function definitions"

 

"u0 =", proc (x, t) options operator, arrow; exp(x)*t end proc

 

"A =", Array(0..3, {(1) = u[0](x, t)^2, (2) = 2*u[0](x, t)*u[1](x, t), (3) = u[1](x, t)^2+2*u[0](x, t)*u[2](x, t)})

 

"B =", Array(0..3, {(1) = (diff(u[0](x, t), x))^2, (2) = 2*(diff(u[0](x, t), x))*(diff(u[1](x, t), x)), (3) = (diff(u[1](x, t), x))^2+2*(diff(u[0](x, t), x))*(diff(u[2](x, t), x))})

 

"Nonlinear functions f(u) =", u^2, "and g(u) =", 0

 

"Adomian Polynomial A[", 0, "] =", u[0](x, t)^2

 

"Adomian Polynomial B[", 0, "] =", (diff(u[0](x, t), x))^2

 

"Adomian Polynomial A[", 1, "] =", 2*u[0](x, t)*u[1](x, t)

 

"Adomian Polynomial B[", 1, "] =", 2*(diff(u[0](x, t), x))*(diff(u[1](x, t), x))

 

"Adomian Polynomial A[", 2, "] =", u[1](x, t)^2+2*u[0](x, t)*u[2](x, t)

 

"Adomian Polynomial B[", 2, "] =", (diff(u[1](x, t), x))^2+2*(diff(u[0](x, t), x))*(diff(u[2](x, t), x))

 

"Adomian Polynomial A[", 3, "] =", 2*u[1](x, t)*u[2](x, t)+2*u[0](x, t)*u[3](x, t)

 

"Adomian Polynomial B[", 3, "] =", 2*(diff(u[1](x, t), x))*(diff(u[2](x, t), x))+2*(diff(u[0](x, t), x))*(diff(u[3](x, t), x))

 

"Step 3: Laplace transform of the ODE:", s^2*laplace(u(x, t), t, s)-(D[2](u))(x, 0)-s*u(x, 0)+laplace(u(x, t)^2, t, s)-laplace((diff(u(x, t), x))^2, t, s) = 0

 

"Step 4: Solution in the Laplace domain:", {laplace(u(x, t), t, s) = -(-s*u(x, 0)+laplace(u(x, t)^2, t, s)-laplace((diff(u(x, t), x))^2, t, s)-(D[2](u))(x, 0))/s^2}

 

"Step 5: Substitute initial conditions:", {laplace(u(x, t), t, s) = -(laplace(u(x, t)^2, t, s)-laplace((diff(u(x, t), x))^2, t, s)-exp(x))/s^2}

 

"Inverse Laplace of term ", 0, ":", -(u[0](x, t)^2+(diff(u[0](x, t), x))^2)*t

 

"Inverse Laplace of term ", 1, ":", -2*(u[0](x, t)*u[1](x, t)+(diff(u[0](x, t), x))*(diff(u[1](x, t), x)))*t

 

"Inverse Laplace of term ", 2, ":", -(u[1](x, t)^2+2*u[0](x, t)*u[2](x, t)+(diff(u[1](x, t), x))^2+2*(diff(u[0](x, t), x))*(diff(u[2](x, t), x)))*t

 

"Inverse Laplace of term ", 3, ":", -2*(u[0](x, t)*u[3](x, t)+(diff(u[0](x, t), x))*(diff(u[3](x, t), x))+u[1](x, t)*u[2](x, t)+(diff(u[1](x, t), x))*(diff(u[2](x, t), x)))*t

 

"Step 7: Final Adomian solution:", exp(x)*t-(u[0](x, t)^2+(diff(u[0](x, t), x))^2)*t-2*(u[0](x, t)*u[1](x, t)+(diff(u[0](x, t), x))*(diff(u[1](x, t), x)))*t-(u[1](x, t)^2+2*u[0](x, t)*u[2](x, t)+(diff(u[1](x, t), x))^2+2*(diff(u[0](x, t), x))*(diff(u[2](x, t), x)))*t-2*(u[0](x, t)*u[3](x, t)+(diff(u[0](x, t), x))*(diff(u[3](x, t), x))+u[1](x, t)*u[2](x, t)+(diff(u[1](x, t), x))*(diff(u[2](x, t), x)))*t

 

-2*((1/2)*(diff(u[0](x, t), x))^2+(diff(u[2](x, t), x)+diff(u[3](x, t), x)+diff(u[1](x, t), x))*(diff(u[0](x, t), x))+(1/2)*(diff(u[1](x, t), x))^2+(diff(u[1](x, t), x))*(diff(u[2](x, t), x))+(1/2)*u[0](x, t)^2+(u[1](x, t)+u[2](x, t)+u[3](x, t))*u[0](x, t)+(1/2)*u[1](x, t)^2+u[1](x, t)*u[2](x, t)-(1/2)*exp(x))*t

 

-2*((1/2)*(diff(u[0](x, t), x))^2+(diff(u[2](x, t), x)+diff(u[3](x, t), x)+diff(u[1](x, t), x))*(diff(u[0](x, t), x))+(1/2)*(diff(u[1](x, t), x))^2+(diff(u[1](x, t), x))*(diff(u[2](x, t), x))+(1/2)*u[0](x, t)^2+(u[1](x, t)+u[2](x, t)+u[3](x, t))*u[0](x, t)+(1/2)*u[1](x, t)^2+u[1](x, t)*u[2](x, t)-(1/2)*exp(x))*t

(2)

 


 

Download adomian_proc_mprimes-salim-3-11-2024.mw

Sometimes i deleted a answer, because thinking that it makes no sense 
That's not wrong , or is it ?


Make this sense or not,  reasoned by ai ?

@Aixleft math 
It is true that the ChatGPt standard is not compatible with Maple , but the paid version Maple coding expert is much better
Unfortunately Maple coding expert is no longer online? 
So I don't know of a replacement for this yet ?
I do not use standard chatGPT for really good maple code

How do I use Maple and AI ? : I already have some basic knowledge of Maple so do have an idea of a code structure when you start with a question and get an answer
As you use it I do it also, but can e.g. add a debugging in the code to see where it goes wrong
 You also have your question solved manually without code first and then ask the ai to do it for you in Maple code now
You can use print and printf to get an overview of your code
You can also have existing code on the forum analyzed for how it works and learn from that
You can ask everything to the ai how you want it, but the ai can also lose track if the maple code is extensive and complicated, then step by step.  

If you are more familiar with the ai, then at some point you know that a piece of code is going to lead to nothing because the AI can't figure it out
Ask for a different approach to the AI and do not ask to repeat with error corrections :-)

Possibly ( for sure: correction)  a good combination with Maple and AI , that you as a user know well the maple language 

First 21 22 23 24 25 26 27 Last Page 23 of 73