janhardo

745 Reputation

12 Badges

11 years, 135 days

MaplePrimes Activity


These are replies submitted by janhardo

seems that output:
[u[0]*ux[0]*uxx[0], u[0]*ux[0]*uxx[1] + u[0]*ux[1]*uxx[0] + u[1]*ux[0]*uxx[0], u[0]*ux[0]*uxx[2] + u[0]*ux[1]*uxx[1] + u[0]*ux[2]*uxx[0] + u[1]*ux[0]*uxx[1] + u[1]*ux[1]*uxx[0] + u[2]*ux[0]*uxx[0]]
could be correct in a different notation only 
to check...

L := [u[0]*ux[0]*uxx[0], 
      u[0]*ux[0]*uxx[1] + u[0]*ux[1]*uxx[0] + u[1]*ux[0]*uxx[0], 
      u[0]*ux[0]*uxx[2] + u[0]*ux[1]*uxx[1] + u[0]*ux[2]*uxx[0] + 
      u[1]*ux[0]*uxx[1] + u[1]*ux[1]*uxx[0] + u[2]*ux[0]*uxx[0]]:

# Toewijzen van elk element aan een dynamische naam L1, L2, ...
for i from 1 to nops(L) do
    assign(cat(L, i), L[i]);
end do:

# Weergeven van de variabelen en hun waarden
for i from 1 to nops(L) do
    print( polynome(i-1)= eval(cat(L, i)));
end do:

                polynome(0) = u[0] ux[0] uxx[0]

      polynome(1) = u[0] ux[0] uxx[1] + u[0] ux[1] uxx[0]

         + u[1] ux[0] uxx[0]

 polynome(2) = u[0] ux[0] uxx[2] + u[0] ux[1] uxx[1]

    + u[0] ux[2] uxx[0] + u[1] ux[0] uxx[1] + u[1] ux[1] uxx[0]

    + u[2] ux[0] uxx[0]

@salim-barzani 
If a algorithm is complet as info then i can try this 
Book notation is probably not  the same to get as in Maple example : 
Maybe to get this kind of notattion with the physics package in Maple ?

There is a polynome package in  Maple.
I do have here a book from André Heck ( a dutchman like me)  : introduction to Maple ..old, but maybe useful.

Mathematical computing: a introduktion  to programming in Maple ( +CD) 
This a really good book for basic learning programming in Maple ( but old) 
Partial Differential equation for comutional science ( with Maple and vectoranalyse (+CD)(non-lineair PDEs? , in general types of pdes in this book : heat, fluid mechanics, etc that's all  )
both books from author David Betounes

# Definieer de functie F(u, ux, uxx, uxxx) = u * ux * uxx
F := (u, ux, uxx, uxxx) -> u * ux * uxx;

@salim-barzani 
I am looking at your info , but it is not working yet

AdomianPolynomials := proc(F, n)
    local A, i, lam, term, expr, u_lam, ux_lam, uxx_lam, uxxx_lam, u, ux, uxx, uxxx, F_lam;

    # Definieer u, ux, uxx en uxxx als arrays met indexen van 0 tot n
    u := Array(0 .. n, [seq(u[i], i = 0 .. n)]);
    ux := Array(0 .. n, [seq(ux[i], i = 0 .. n)]);
    uxx := Array(0 .. n, [seq(uxx[i], i = 0 .. n)]);
    uxxx := Array(0 .. n, [seq(uxxx[i], i = 0 .. n)]);

    # Definieer de serie-expansies voor u(lam), ux(lam), uxx(lam), en uxxx(lam)
    u_lam := 0;
    ux_lam := 0;
    uxx_lam := 0;
    uxxx_lam := 0;

    for i from 0 to n do
        u_lam := u_lam + lam^i * u[i];
        ux_lam := ux_lam + lam^i * ux[i];
        uxx_lam := uxx_lam + lam^i * uxx[i];
        uxxx_lam := uxxx_lam + lam^i * uxxx[i];
    end do;

    # Bereken F(u, ux, uxx, uxxx) als functie van lam
    F_lam := F(u_lam, ux_lam, uxx_lam, uxxx_lam);

    # Initialiseer lijst A voor de Adomian polynomen
    A := [];

    # Bereken A0 door lam = 0 in te vullen
    term := subs(lam = 0, F_lam);
    A := [term];

    # Bereken hogere orde Ai termen
    for i from 1 to n do
        # Neem de i-de afgeleide naar lam
        expr := diff(F_lam, lam$i);
        term := subs(lam = 0, expr);
        A := [op(A), term / factorial(i)];
    end do;

    return A;
end proc:

# Definieer de functie F(u, ux, uxx, uxxx) = u * ux * uxx
F := (u, ux, uxx, uxxx) -> u * ux * uxx;

# Roep de procedure aan voor n = 2
AdomianPolynomials(F, 2);

AdomianPolynomials := proc(F, n)
    local A, i, lam, term, expr, u_lam, u;

    # Definieer u als een array met indexen van 0 tot n
    u := Array(0 .. n, [seq(u[i], i = 0 .. n)]);

    # Definieer de serie-expansie voor u(lam) als som van u[i] * lam^i termen
    u_lam := 0;
    for i from 0 to n do
        u_lam := u_lam + lam^i * u[i];
    end do;

    # Initialiseer lijst A voor de Adomian polynomen
    A := [];

    # Bereken A0 door lam = 0 in te vullen
    term := F(u[0]);
    A := [term];

    # Bereken hogere orde Ai termen
    for i from 1 to n do
        # Neem de i-de afgeleide naar lam
        expr := diff(F(u_lam), lam$i);
        term := subs(lam = 0, expr);
        A := [op(A), term / factorial(i)];
    end do;

    return A;
end proc:

# Definieer de functie F(u) = u^2
F := u -> u^2;

# Roep de procedure aan en geef de gewenste waarde van n door
AdomianPolynomials(F, 2);

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

 

[u[0]^2, 2*u[0]*u[1], 2*u[0]*u[2]+u[1]^2]

(1)

[u0^2, 2*u0*u1, 2*u0*u2 + u1^2];# comparing

[u0^2, 2*u0*u1, 2*u0*u2+u1^2]

(2)

AdomianPolynomials := proc(F, n)
    local A, i, j, lam, term, expr, u_lam, v_lam, u, v;

    # Definieer u en v als arrays met indexen van 0 tot n
    u := Array(0 .. n, [seq(u[i], i = 0 .. n)]);
    v := Array(0 .. n, [seq(v[i], i = 0 .. n)]);

    # Definieer de serie-expansies voor u(lam) en v(lam)
    u_lam := 0;
    v_lam := 0;
    for i from 0 to n do
        u_lam := u_lam + lam^i * u[i];
        v_lam := v_lam + lam^i * v[i];
    end do;

    # Initialiseer lijst A voor de Adomian polynomen
    A := [];

    # Bereken A0 door lam = 0 in te vullen
    term := F(u[0], v[0]);
    A := [term];

    # Bereken hogere orde Ai termen
    for i from 1 to n do
        # Neem de i-de afgeleide naar lam
        expr := diff(F(u_lam, v_lam), lam$i);
        term := subs(lam = 0, expr);
        A := [op(A), term / factorial(i)];
    end do;

    return A;
end proc:

# Definieer de functie F(u, v) = u^2 + v^2
F := (u, v) -> u^2 + v^2;

# Roep de procedure aan voor n = 2
AdomianPolynomials(F, 2);

proc (u, v) options operator, arrow; v^2+u^2 end proc

 

[u[0]^2+v[0]^2, 2*u[0]*u[1]+2*v[0]*v[1], 2*u[0]*u[2]+u[1]^2+2*v[0]*v[2]+v[1]^2]

(3)
 

 

Download adomian_proc_mprimes_via_pdfv7-11-2024.mw

2 procedures for two variables adomian polynome geives the same result 

restart;

# Define the nonlinear function N(u) = u^2
N := u -> u^2;

# AdomianPolynomen Procedure (zoals beschreven in jouw code)
AdomianPolynomen := proc(N, u_series, n)
   local A, lambda, k, u_expansion, derivTerm;

   # Step 1: Set up the full series expansion for u(x, y) in terms of lambda
   u_expansion := add(lambda^k * u_series[k+1], k = 0 .. n);

   # Step 2: Compute N(u) applied to the series expansion
   derivTerm := N(u_expansion);

   # Step 3: Compute the n-th derivative with respect to lambda and evaluate at lambda = 0
   if n = 0 then
       A := eval(derivTerm, lambda = 0);
   else
       A := (1/factorial(n)) * diff(derivTerm, lambda$n);
       A := eval(A, lambda = 0);
   end if;

   return A;
end proc:

# Define the terms in the series expansion u_series
u_series := [x + y, x^2 + y^2, x*y, 0, 0, 0];

# Define the number of polynomials we want to compute
maxOrder := 2;  # Up to A_2 for testing

# Calculate Adomian polynomials up to maxOrder
for i from 0 to maxOrder do
    AdomianPoly := AdomianPolynomen(N, u_series, i);
    print(cat("Adomian polynomial A_", i, " is:"), AdomianPoly);
od;

"maple.ini in users"

 

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

 

[x+y, x^2+y^2, x*y, 0, 0, 0]

 

2

 

(x+y)^2

 

"Adomian polynomial A_0 is:", (x+y)^2

 

2*(x+y)*(x^2+y^2)

 

"Adomian polynomial A_1 is:", 2*(x+y)*(x^2+y^2)

 

(x^2+y^2)^2+2*(x+y)*x*y

 

"Adomian polynomial A_2 is:", (x^2+y^2)^2+2*(x+y)*x*y

(1)

restart;

# Define the nonlinear function F(u) = u^2
F := u -> u^2;

# AdomianPolynomial Procedure (zoals beschreven in jouw code)
AdomianPolynomial := proc(F, n, x, y)
    local lambdaSeries, A_n, k, lambda, u, diffExpr;

    # Step 1: Define the symbolic terms u[k](x, y) for the series expansion
    u := (k, x, y) -> cat(u, k)(x, y);

    # Step 2: Build the helper series with lambda and symbolic terms u[k](x, y)
    lambdaSeries := add(lambda^k * u(k, x, y), k = 0 .. n);

    # Step 3: Compute the non-linear expression F applied to the helper series
    diffExpr := F(lambdaSeries);

    # Step 4: Compute the n-th derivative of diffExpr with respect to lambda
    if n = 0 then
        A_n := diffExpr;  # A0 is simply F(u0(x, y))
    else
        A_n := (1/factorial(n)) * diff(diffExpr, lambda $ n);
    end if;

    # Step 5: Evaluate the result at lambda = 0
    if n > 0 then
        A_n := subs(lambda = 0, A_n);
    end if;

    # Step 6: Simplify the result and return it
    A_n := simplify(A_n);
    return A_n;
end proc:

# Define the symbolic terms for the series expansion u(k, x, y)
# Equivalent to [x + y, x^2 + y^2, x*y, 0, 0, 0] from procedure 1
u0 := (x, y) -> x + y;
u1 := (x, y) -> x^2 + y^2;
u2 := (x, y) -> x*y;

# Calculate Adomian polynomials up to A_2 for comparison
A0 := AdomianPolynomial(F, 0, x, y);
A1 := AdomianPolynomial(F, 1, x, y);
A2 := AdomianPolynomial(F, 2, x, y);

# Display results
print("Adomian polynomial A_0 is:", A0);
print("Adomian polynomial A_1 is:", A1);
print("Adomian polynomial A_2 is:", A2);

"maple.ini in users"

 

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

 

proc (x, y) options operator, arrow; x+y end proc

 

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

 

proc (x, y) options operator, arrow; y*x end proc

 

(x+y)^2

 

2*(x+y)*(x^2+y^2)

 

(x^2+y^2)^2+2*(x+y)*y*x

 

"Adomian polynomial A_0 is:", (x+y)^2

 

"Adomian polynomial A_1 is:", 2*(x+y)*(x^2+y^2)

 

"Adomian polynomial A_2 is:", (x^2+y^2)^2+2*(x+y)*y*x

(2)
 

 

Download adomian_proc_2vriabelen_2_proceduresdezelfde_uitkomst_7-11-2024.mw

more abstract procedure for adomian 2 variable polynome , not subscripted, general use

abstracte_adomian_polynoom_2_variable_mapleprocedure_engels_.mw

Adomian polynomes for two variables

adoniam_polynoom_voor_2_variabelen_6-11-2024.mw

@salim-barzani 
There are two procedures for calculating adomian procedures for one variable here in this thread
- you can use code after using : AP1 := proc(f, M) or AP2 := proc(f, M)
- or built in the code by yourself as exercise into the two procedures code

Note: why would you want to destroy it..seems to be not useful for you?

# Define the list L
L := [%][]: # Adjust this list as desired
# Display the entire list
#print("The list L is:", L);
# Display each element individually with the name A[i]
for i from 1 to nops(L) do
    A[i-1] := L[i];
    #print(A[i-1]);
end do;

You can use this at the end of the procedures after calculation  or built it in. 

adomian_polynomenvia_mathematica_-boek_ode_zwillingr_info_A.mw

@salim-barzani 
Getting a procedure for 2 variables adomian polynoms ?
Seems to be in Mathematica no problem ( must test this), but a translation to maple code is unsure

# Define the list L
L := [%][]: # Adjust this list as desired
# Display the entire list
#print("The list L is:", L);
# Display each element individually with the name A[i]
for i from 1 to nops(L) do
    A[i-1] := L[i];
    #print(A[i-1]);
end do;

You can use this at the end of the procedures after calculation  or built it in. 

@salim-barzani 
This must be added in the two procedures , in the right way, because the list  is different 

# Define the list L
L := [a, b, c, d, e]; # Adjust this list as desired

# Display the entire list
#print("The list L is:", L);

# Display each element individually with the name A[i]
for i from 1 to nops(L) do
    A[i-1] := L[i];
    #print(A[i-1]);
end do;

Here are two procedures different programmed  to calculate a adomian polynome for one variable 

AP1 := proc(f, M)
    local F, i, A, u, s, expr, k;
    
    # Initialize F[0]
    F[0] := f(add(u[k] * s^k, k = 0 .. M));
    
    # Loop to define A[i] and update F[i+1]
    for i from 0 to M do
        A[i] := expand((1/factorial(i)) * subs(s = 0, F[i]));
        F[i+1] := diff(F[i], s);
    end do;
    
    # Return the list of A[i]
    [seq(A[i], i = 0 .. M)]
end proc:
 

# Define f as an anonymous function (Maple uses arrow syntax for functions)
f := x -> x^2;

# Execute the procedure with f and M = 3
result := AP1(f, 3);

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

 

[u[0]^2, 2*u[0]*u[1], 2*u[0]*u[2]+u[1]^2, 2*u[0]*u[3]+2*u[1]*u[2]]

(1)

# Define the function f(x) = exp(x^2)
f1 := x -> exp(x^2);

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

(2)

# Execute the procedure with f1 and M = 3
result := AP1(f1, 3);

[exp(u[0]^2), 2*u[0]*u[1]*exp(u[0]^2), u[1]^2*exp(u[0]^2)+2*u[0]*u[2]*exp(u[0]^2)+2*u[0]^2*u[1]^2*exp(u[0]^2), 2*u[1]*exp(u[0]^2)*u[2]+2*u[1]^3*u[0]*exp(u[0]^2)+2*u[0]*u[3]*exp(u[0]^2)+4*u[0]^2*u[2]*u[1]*exp(u[0]^2)+(4/3)*u[0]^3*u[1]^3*exp(u[0]^2)]

(3)

 

 

restart;

"maple.ini in users"

(4)

AP2 := proc(f, M)
    local c, n, k, j, der, A;

    # Initialize c[n, k] for the tables we need
    c := array(1..M, 1..M):
    A := array(0..M):

    # Create a list of the derivatives of f with respect to u[0]
    der := [seq(diff(f(u[0]), u[0]$k), k = 1 .. M)];

    # Set the initial value of A[0]
    A[0] := f(u[0]);

    # Outer loop for n from 1 to M
    for n from 1 to M do
        c[n, 1] := u[n];

        # Inner loop for k from 2 to n
        for k from 2 to n do
            c[n, k] := expand((1/n) * add((j + 1) * u[j + 1] * c[n - 1 - j, k - 1], j = 0 .. n - k));
        end do;

        # Calculate A[n] by taking the first n derivatives and multiplying by c[n, k]
        A[n] := add(der[k] * c[n, k], k = 1 .. n);
    end do;

    # Return the result as a list of A[n] for n from 0 to M
    [seq(A[n], n = 0 .. M)]
end proc:

# Define f as an anonymous function (Maple uses arrow syntax for functions)
f := x -> x^2;

# Execute the procedure with f and M = 3
result := AP2(f, 3);

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

 

[u[0]^2, 2*u[0]*u[1], 2*u[0]*u[2]+u[1]^2, 2*u[0]*u[3]+2*u[1]*u[2]]

(5)
 

 

Download adomian_polynomenvia_mathematica_-boek_ode_zwillingr_info.mw

That moderator has already taken care of it that you don't dare to post it again for the 2nd time from the adomian polynomials.
This is absurd and curtails your freedom of movement.
Do understand that you still want to stay connected to these mapleprimes to get to know Maple better and need help
Well, I think it's just a pathetic display like this

You sit and do your best to move forward with the adoniam polynomials and add a worksheet and information.
Asks for help and then comes some half-assed moderator who just removes your work from the maple primes forum
This is really all wrong, sick

@salim-barzani , I was willing to put my teeth into it to get this procedure working, after all I am B ed math

I was also studying that other deleted post from today about the adomian polynomials with a worksheet attached which also showed a lot of information for me .
That one is much more valuable then this post.
Just get removed from the forum, this is just really very wrong and this way you deserve no respect and you can get the hell out too.
Sitting maples primes dead with these actions ,goofball.

That moderator is just stirring things up, jerk
Indeed different questions are asked all the time 
Now if you're a man respond to this,sneaky
 

First 25 26 27 28 29 30 31 Last Page 27 of 78