janhardo

425 Reputation

8 Badges

10 years, 166 days

MaplePrimes Activity


These are replies submitted by janhardo

@scallopedpancake 
Setup screen ? in Physics package 


 

As a system of odes via  ODEsteps : lambda and mu  , for symbolic solving  there are no solutionsteps , but for lambda and mu = 1 there is a solution
Note : output odesteps not correct ?


 

"maple.ini in users"

(1)

restart;

"maple.ini in users"

(2)

with(Student:-ODEs):

 

"maple.ini in users"

(3)

# Definieer de nieuwe vector-matrix notatie
macro(Y = <y[1](eta), y[2](eta)>);
sys := diff(Y, eta) = Matrix([[0, lambda], [mu, 0]]).Y;

Y

 

Vector[column](%id = 36893490960308788268) = Vector[column](%id = 36893490960308788628)

(4)

ODESteps(sys);

Error, (in Student:-ODEs:-SolveSystem) unsupported system of ODEs

 

restart;

"maple.ini in users"

(5)

with(Student:-ODEs):

 

"maple.ini in users"

(6)

# Definieer de nieuwe vector-matrix notatie
macro(Y = <y[1](eta), y[2](eta)>);
sys := diff(Y, eta) = Matrix([[0, 1], [1, 0]]).Y;

Y

 

Vector[column](%id = 36893490861197088396) = Vector[column](%id = 36893490861197088756)

(7)

ODESteps(sys);

"[[,,"Let's solve"],[,,[?]=[?]],["&bullet;",,"Define vector"],[,,y(eta)=[?]],["&bullet;",,"System to solve"],[,,(&DifferentialD;)/(&DifferentialD;eta) y(eta)=[?]*y(eta)],["&bullet;",,"Define the coefficient matrix"],[,,A=[?]],["&bullet;",,"Rewrite the system as"],[,,(&DifferentialD;)/(&DifferentialD;eta) y(eta)=A*y(eta)],["&bullet;",,"To solve the system, find the eigenvalues and eigenvectors of" A],["&bullet;",,"Eigenpairs of" A],[,,[[-1,[?]],[1,[?]]]],["&bullet;",,"Consider eigenpair"],[,,[-1,RTABLE(18446744074197349982,MATRIX([[-1], [1]]),Vector[column])]],["&bullet;",,"Solution to homogeneous system from eigenpair"],[,,(y)[1]=[]],["&bullet;",,"Consider eigenpair"],[,,[1,RTABLE(18446744074198477606,MATRIX([[1], [1]]),Vector[column])]],["&bullet;",,"Solution to homogeneous system from eigenpair"],[,,(y)[2]=[]],["&bullet;",,"General solution to the system of ODEs"],[,,y=`c__1` (y)[1]+`c__2` (y)[2]],["&bullet;",,"Substitute solutions into the general solution"],[,,y=[]+[]],["&bullet;",,"Solution to the system of ODEs"],[,,[?]=[?]]]"

(8)

 


 

Download Find_ODE_solution_with_condition_parameter_als_syteem_via_odesteps_26-11-2024.mw

@dharr  "avoids square roots of negative numbers in practice" . This is calculated in the complex number system.
 

restart;

# Define the coupled differential equations
de1 := diff(F(eta), eta) = lambda * G(eta):
de2 := diff(G(eta), eta) = mu * F(eta):

# Solve the differential equations (general solution)
sol := dsolve({de1, de2}, {F(eta), G(eta)}):
sol_hyperbolic := convert(sol, trigh):  # Hyperbolic form

# General solution (hyperbolic, valid for all lambda and mu)
print("=== General Solution (valid for all lambda and mu) ==="):
print(sol_hyperbolic);

# Alternative solution for lambda * mu < 0 (explicit complex root)
assume(lambda < 0, mu > 0):  # Assume lambda * mu < 0
complexRoot := simplify(sqrt(lambda * mu)):  # Explicitly compute complex root
complexRoot_imag := I * sqrt(-lambda * mu):  # Write root in imaginary form

# Replace hyperbolic functions with trigonometric functions
sol_trig := subs(sqrt(lambda * mu) = complexRoot_imag, sol_hyperbolic):
sol_trig_converted := simplify(sol_trig):
print("=== Alternative Solution (Trigonometric Form for lambda * mu < 0) ==="):
print(sol_trig_converted);

# Add information from the image: interpretation and cases
print("=== Interpretation of Cases ==="):
print("Case (I): Covers all combinations of lambda and mu signs using hyperbolic functions.");
print("Case (II): If lambda * mu < 0, the solution can be rewritten in trigonometric form.");
print("Note: Hyperbolic functions naturally handle both positive and negative values of lambda * mu.");

# Validate both solutions with odetest
validation_hyperbolic := odetest(sol_hyperbolic, [de1, de2]):
validation_trig := odetest(sol_trig_converted, [de1, de2]):

print("=== Validation of Solutions ==="):
print("Validation of the hyperbolic solution:"):
print(validation_hyperbolic):  # Result must be 0
print("Validation of the trigonometric solution (lambda * mu < 0):"):
print(validation_trig);  # Result must be 0

 

No complex numbers anymore or do you mean something else ?

@Carl Love 

Yes, some explanation of the code can never hurt in my opinion.

But to really understand maple code better, the AI is also a good helper, but paid via ChatGPTplus
Unfortunately the Maple coding expert does not seem to be around anymore, so it will be Wolfram or yet other chats .

@Aung 

Then you should rewrite a general expression of the current integral expression into a general form of an integral by parts ?
 =   ( with partiele integration )

Both expressions i let check this  with  parameters and they seem to be numeric equal 


 

@Aung 

This is another methode from acer of solving your expression than dharr did for your expression.

acer methode :
"Do you need a fully programmatic way to transform the integral of a sum into the sum of integrals? For example, programmatically extracting and re-using not just the integrand but also the ranges of integration and summation".

Suppose you take the first term of the sum and solve this integral by parts : what to do with this expression?

@dharr 

I'm not a fan of your code, which only shows maple commands.
Keep in mind , that someone is asking for your help and needs some more explanation. 

Make "free" a variable 

x := 5;  # Assigning a value to x
x := 'x';# Releasing the variable by resetting it to a symbol


                             x := 5

                             x := x

 

@janhardo 

# Definieer lijst van polynomen
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]]:

# Maak een lege tabel met kolommen voor de naam van het polynoom en zijn waarde
the_table := Array(1..0):
the_table ,= ["Polynoom", "Waarde"]:

# Toewijs elk polynoom aan een naam en voeg toe aan de tabel
for i from 1 to nops(L) do
    naam := cat("polynoom_", i-1);
    waarde := eval(L[i]);
    the_table ,= [naam, waarde]:
end do:

# Converteer de tabel naar lijstformaat voor presentatie
the_table := convert(the_table, listlist):
DocumentTools:-Tabulate(the_table, width=60):

 

# Definieer lijst van polynomen
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]]:

# Print de tabelkop met een vaste breedte
printf("%-12s %-60s\n", "Polynoom", "Waarde"):

# Print elke rij met polynoomnaam en corresponderende waarde
for i from 1 to nops(L) do
    naam := cat("polynoom_", i-1);
    waarde := eval(L[i]);
    printf("%-12s %-60s\n", naam, convert(waarde, string)):
end do:

Polynoom     Waarde                                                      
polynoom_0   u[0]*ux[0]*uxx[0]                                           
polynoom_1   u[0]*ux[0]*uxx[1]+u[0]*ux[1]*uxx[0]+u[1]*ux[0]*uxx[0]       
polynoom_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]

 
 

 

Download polynoom_adomian_uitvoerprocedure_2_variabelen_in_tabel_7-11-2024.mw

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);
1 2 3 4 5 6 7 Last Page 1 of 53