janhardo

870 Reputation

12 Badges

11 years, 280 days
B. Ed math

MaplePrimes Activity


These are replies submitted by janhardo

It seems that the array notation is not suited for pattern matching in Maple ?

@jalal 
More intuiative with complex numbers ...

corrected code

restart;
with(DEtools);
with(plots);
with(LinearAlgebra);
f := y -> y^2*(1 - y^2);
sys := [diff(x(t), t) = -x(t), diff(y(t), t) = f(y(t))];
trajectories := [[x(0) = 1, y(0) = 1.5], [x(0) = -1, y(0) = 0.5], [x(0) = 0.5, y(0) = -1.5]];
phase_plot := DEplot(sys, [x(t), y(t)], t = 0 .. 10, trajectories, x = -2 .. 2, y = -2 .. 2, arrows = medium, dirfield = [20, 20], linecolor = blue, title = "Phase Portrait with Equilibrium Points");
equilibrium_points := pointplot([[0, 0], [0, 1], [0, -1]], symbol = solidcircle, color = black, symbolsize = 15);
display([phase_plot, equilibrium_points], scaling = constrained);
print("\n### DETAILED STABILITY ANALYSIS ###");
F := [-x, -y^4 + y^2];
J := Matrix([[diff(F[1], x), diff(F[1], y)], [diff(F[2], x), diff(F[2], y)]]);
print("\n1. Analysis for (0,0):");
J0 := eval(J, {x = 0, y = 0});
print("Jacobian:", J0);
print("Eigenvalues:", Eigenvalues(J0));
print("Conclusion:");
print("   - Eigenvalues: -1 and 0");
print("   - Non-hyperbolic point");
print("   - dy/dt ≈ y^2 > 0 for y ≈ 0");
print("   - ⇒ (0,0) is UNSTABLE");
print("\n2. Analysis for (0,1):");
J1 := eval(J, {x = 0, y = 1});
print("Jacobian:", J1);
print("Eigenvalues:", Eigenvalues(J1));
print("Conclusion:");
print("   - Eigenvalues: -1 and -2");
print("   - Both negative ⇒ STABLE NODE");
print("   - All nearby trajectories converge to this point");
print("\n3. Analysis for (0,-1):");
Jm1 := eval(J, {x = 0, y = -1});
print("Jacobian:", Jm1);
print("Eigenvalues:", Eigenvalues(Jm1));
print("Conclusion:");
print("   - Eigenvalues: -1 and +2");
print("   - Mixed eigenvalues ⇒ SADDLE POINT");
print("   - Stable in x-direction, unstable in y-direction");
print("   - ⇒ (0,-1) is UNSTABLE");
print("\n### VISUAL INTERPRETATION ###");
print("1. (0,0): Arrows point away in y-direction - unstable");
print("2. (0,1): All arrows point toward this point - stable");
print("3. (0,-1): Arrows approach in x-direction but diverge in y-direction - saddle point");
print("\n### SYSTEM BEHAVIOR SUMMARY ###");
print("The system exhibits:");
print("- One stable equilibrium at (0,1)");
print("- One unstable equilibrium at (0,0)");
print("- One saddle point at (0,-1)");
print("- Bistability between y=1 and y=-1 states");
print("- All x-values decay to 0 over time");
print("- y-direction determines long-term behavior");

Never trust ai , because node ( 0,-1) is not stable , when i examine it 

@salim-barzani 
You need help from a specialist , i don't know what you are after for.? 

@salim-barzani 

 

restart;
expr := abs(U[i](x, t))^n*diff(U[i](x, t), x);
expr_rewritten := subs(abs(U[i](x, t))^n = (U[i](x, t)*conjugate(U[i](x, t)))^(n/2), expr);
print(expr_rewritten);

"in here i want to seperate abs(U[i](x,t))^n=U[i](x,t)^n/2*conjugate(U[i](x,t))"   
I am guessing here, no direction where you are after for?

 


=======================================================================






 

 

 

 

@salim-barzani 

It is not yet a definitive code that can handle all non-linear pdes .
The procedure code must be modified for certain types of pde 
So specify the pde ...

restart; with(PDEtools); with(Physics); declare(u(x, t), complex)

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

(1)

NULL

NULL

SplitPDE := proc (pde_expr) local expr, terms, term, linear_terms, nonlinear_terms, i, u_count, conj_u_count, total_count; expr := lhs(pde_expr)-rhs(pde_expr); printf("Original PDE: %a = 0\n\n", expr); terms := [op(expand(expr))]; printf("Terms in PDE:\n"); print(terms); printf("\n"); printf("Analyzing terms:\n"); linear_terms := []; nonlinear_terms := []; for i to nops(terms) do term := op(i, terms); u_count := numboccur(term, u(x, t)); conj_u_count := numboccur(term, conjugate(u(x, t))); total_count := u_count+conj_u_count; printf("Term %d: %a\n", i, term); printf("   u count: %d, conjugate(u) count: %d\n", u_count, conj_u_count); if total_count = 1 and conj_u_count = 0 then linear_terms := [op(linear_terms), term] else nonlinear_terms := [op(nonlinear_terms), term] end if end do; printf("\nLinear terms:\n"); print(`+`(op(linear_terms))); printf("\nNonlinear terms:\n"); print(`+`(op(nonlinear_terms))); printf("\nVerification:\n"); if simplify(expr-(`+`(op(linear_terms)))-(`+`(op(nonlinear_terms)))) = 0 then printf("Verification passed!\n") else printf("Verification failed! Difference:\n"); print(simplify(expr-(`+`(op(linear_terms)))-(`+`(op(nonlinear_terms))))) end if; return `+`(op(linear_terms)), `+`(op(nonlinear_terms)) end proc

pde := u(x, t)+I*(diff(u(x, t), `$`(x, 2)))+2*(diff(u(x, t)*conjugate(u(x, t)), x))*u(x, t)+u(x, t)^2*conjugate(u(x, t))^2*u(x, t) = 0

u(x, t)+I*(diff(diff(u(x, t), x), x))+(2*(diff(u(x, t), x))*conjugate(u(x, t))+2*u(x, t)*(diff(conjugate(u(x, t)), x)))*u(x, t)+u(x, t)^3*conjugate(u(x, t))^2 = 0

(2)

linear_part, nonlinear_part := SplitPDE(pde)

Original PDE: u(x,t)+I*diff(diff(u(x,t),x),x)+(2*diff(u(x,t),x)*conjugate(u(x,t))+2*u(x,t)*diff(conjugate(u(x,t)),x))*u(x,t)+u(x,t)^3*conjugate(u(x,t))^2 = 0

Terms in PDE:

 

[u(x, t), I*(diff(diff(u(x, t), x), x)), 2*u(x, t)*(diff(u(x, t), x))*conjugate(u(x, t)), 2*u(x, t)^2*(diff(conjugate(u(x, t)), x)), u(x, t)^3*conjugate(u(x, t))^2]

 


Analyzing terms:
Term 1: u(x,t)
   u count: 1, conjugate(u) count: 0
Term 2: I*diff(diff(u(x,t),x),x)
   u count: 1, conjugate(u) count: 0
Term 3: 2*u(x,t)*diff(u(x,t),x)*conjugate(u(x,t))
   u count: 3, conjugate(u) count: 1
Term 4: 2*u(x,t)^2*diff(conjugate(u(x,t)),x)
   u count: 2, conjugate(u) count: 1
Term 5: u(x,t)^3*conjugate(u(x,t))^2
   u count: 2, conjugate(u) count: 1

Linear terms:

 

u(x, t)+I*(diff(diff(u(x, t), x), x))

 


Nonlinear terms:

 

2*u(x, t)*(diff(u(x, t), x))*conjugate(u(x, t))+2*u(x, t)^2*(diff(conjugate(u(x, t)), x))+u(x, t)^3*conjugate(u(x, t))^2

 


Verification:
Verification passed!

 

u(x, t)+I*(diff(diff(u(x, t), x), x)), 2*u(x, t)*(diff(u(x, t), x))*conjugate(u(x, t))+2*u(x, t)^2*(diff(conjugate(u(x, t)), x))+u(x, t)^3*conjugate(u(x, t))^2

(3)

pde := I*(diff(u(x, t), t))+diff(u(x, t), x, x)+alpha*abs(u(x, t))^2*u(x, t)+beta*u(x, t)^2*(diff(conjugate(u(x, t)), x))+delta*abs(u(x, t))^4*u(x, t) = 0

I*(diff(u(x, t), t))+diff(diff(u(x, t), x), x)+alpha*abs(u(x, t))^2*u(x, t)+beta*u(x, t)^2*(diff(conjugate(u(x, t)), x))+delta*abs(u(x, t))^4*u(x, t) = 0

(4)

linear_part, nonlinear_part := SplitPDE(pde)

Original PDE: I*diff(u(x,t),t)+diff(diff(u(x,t),x),x)+alpha*abs(u(x,t))^2*u(x,t)+beta*u(x,t)^2*diff(conjugate(u(x,t)),x)+delta*abs(u(x,t))^4*u(x,t) = 0

Terms in PDE:

 

[I*(diff(u(x, t), t)), diff(diff(u(x, t), x), x), alpha*abs(u(x, t))^2*u(x, t), beta*u(x, t)^2*(diff(conjugate(u(x, t)), x)), delta*abs(u(x, t))^4*u(x, t)]

 


Analyzing terms:
Term 1: I*diff(u(x,t),t)
   u count: 1, conjugate(u) count: 0
Term 2: diff(diff(u(x,t),x),x)
   u count: 1, conjugate(u) count: 0
Term 3: alpha*abs(u(x,t))^2*u(x,t)
   u count: 2, conjugate(u) count: 0
Term 4: beta*u(x,t)^2*diff(conjugate(u(x,t)),x)
   u count: 2, conjugate(u) count: 1
Term 5: delta*abs(u(x,t))^4*u(x,t)
   u count: 2, conjugate(u) count: 0

Linear terms:

 

I*(diff(u(x, t), t))+diff(diff(u(x, t), x), x)

 


Nonlinear terms:

 

alpha*abs(u(x, t))^2*u(x, t)+beta*u(x, t)^2*(diff(conjugate(u(x, t)), x))+delta*abs(u(x, t))^4*u(x, t)

 


Verification:
Verification passed!

 

I*(diff(u(x, t), t))+diff(diff(u(x, t), x), x), alpha*abs(u(x, t))^2*u(x, t)+beta*u(x, t)^2*(diff(conjugate(u(x, t)), x))+delta*abs(u(x, t))^4*u(x, t)

(5)
 

NULL

Download onderzoek_termen_in_niet_linear_pde5-6-2025mprimes.mw

Checked the procedure with the classical  non -lineair schrodinger eq 
Do you have a idea what are the lineair and non linear parts of your pde

splitsing_pde_conjugate_vorm_4-6-2025mprimes_A.mw

"Ai is trash in 100 time just one time work , when i am stuck i will post here and my work is rare i cant find it any where i have to do step by step,  many thanks for you"

You can't use ai , so this is not a good  attitude , rather simplistic 

@salim-barzani 

assume(A < 0, 0 < C); printf("Original ODE before rewriting (with B = -2AC):\n"); ode_orig := (diff(G(xi), xi))^2 = A^2+(2*A*(-2*A*C))*G(xi)+2*A*C*G(xi)^2+(2*(-2*A*C))*C*G(xi)^3+C^2*G(xi)^4; ode_orig; printf("\nRewritten ODE (after completing the square):\n"); ode := diff(G(xi), xi) = A+C*G(xi)^2-2*A*C*G(xi); ode; sol_general := dsolve(ode, G(xi)); printf("\nExplicit solution (after simplification):\n"); explicit_sol := `assuming`([simplify(sol_general)], [A < 0, 0 < C]); explicit_sol; printf("\nVerification using odetest:\n"); odetest_result := odetest(explicit_sol, ode); `assuming`([simplify(odetest_result)], [A < 0, 0 < C]); G1 := proc (xi) options operator, arrow; -((1/2)*sqrt(-2*A*C)+(1/2)*sqrt(-6*A*C)*tanh((1/2)*sqrt(-6*A*C)*xi))/C end proc; G2 := rhs(explicit_sol); G2fun := unapply(G2, xi); printf("\nDifference between both solutions (should be 0):\n"); diffG := `assuming`([simplify(G1(xi)-G2fun(xi))], [A < 0, 0 < C]); diffG

Original ODE before rewriting (with B = -2AC):

 

(diff(G(xi), xi))^2 = A^2-4*A^2*C*G(xi)+2*A*C*G(xi)^2-4*A*C^2*G(xi)^3+C^2*G(xi)^4

 


Rewritten ODE (after completing the square):

 

diff(G(xi), xi) = A+C*G(xi)^2-2*A*C*G(xi)

 


Explicit solution (after simplification):

 

G(xi) = (A*C-tanh(C^(1/2)*(-A*C+1)^(1/2)*(-A)^(1/2)*(c__1+xi))*C^(1/2)*(-A*C+1)^(1/2)*(-A)^(1/2))/C

 


Verification using odetest:

 

0

 


Difference between both solutions (should be 0):

 

(1/2)*(2*tanh(C^(1/2)*(-A*C+1)^(1/2)*(-A)^(1/2)*(c__1+xi))*C^(1/2)*(-A*C+1)^(1/2)*(-A)^(1/2)-2*A*C-2^(1/2)*C^(1/2)*(-A)^(1/2)-2^(1/2)*3^(1/2)*C^(1/2)*(-A)^(1/2)*tanh((1/2)*6^(1/2)*C^(1/2)*(-A)^(1/2)*xi))/C

(1)

no simplification ..  doing by maple xperts ..
 

another proofmethod that both solutions functions are the same at G1,2(0)

G1 := proc (xi) options operator, arrow; -(1/2)*(sqrt(-2*A*C)+sqrt(-6*A*C)*tanh((1/2)*sqrt(-6*A*C)*xi))/C end proc; G2 := proc (xi) options operator, arrow; (A*C-sqrt(A^2*C^2-A*C)*tanh(sqrt(A^2*C^2-A*C)*xi+_C1))/C end proc; eq := `assuming`([simplify(G1(0) = G2(0))], [A < 0, C > 0]); C1sol := solve(eq, _C1); C1sol

proc (xi) options operator, arrow; -(1/2)*(sqrt(-2*A*C)+sqrt(-6*A*C)*tanh((1/2)*sqrt(-6*A*C)*xi))/C end proc

 

proc (xi) options operator, arrow; (A*C-sqrt(A^2*C^2-A*C)*tanh(sqrt(A^2*C^2-A*C)*xi+_C1))/C end proc

 

-(1/2)*2^(1/2)*(-A)^(1/2)/C^(1/2) = (A*C-C^(1/2)*(-A*C+1)^(1/2)*(-A)^(1/2)*tanh(_C1))/C

 

arctanh((1/2)*(2*A*C^(3/2)+2^(1/2)*(-A)^(1/2)*C)/(C*(-A*C+1)^(1/2)*(-A)^(1/2)))

(2)

``

Download G25_via_maple_nu_-wel_in_mathematica_mprimes3-6-2025.mw

First 12 13 14 15 16 17 18 Last Page 14 of 84