janhardo

695 Reputation

12 Badges

11 years, 39 days

MaplePrimes Activity


These are answers submitted by janhardo


Angular Motion Over Time

restart;
grid := proc(M::Matrix) local i, j, Ms, m, n, wks; m, n := op(1, M); Ms := map(convert, M, string); wks := XMLTools:-ToString(_XML_Worksheet(DocumentTools:-Layout:-Table(':-alignment' = ':-center', ':-width' = 20, seq(DocumentTools:-Layout:-Column(':-weight' = 3 + max(map(length, Ms[() .. (), j]))), j = 1 .. n), seq(DocumentTools:-Layout:-Row(seq(DocumentTools:-Layout:-Cell(`_XML_Text-field`("alignment" = "centred", "style" = "Text", Ms[i, j])), j = 1 .. n)), i = 1 .. m)))); streamcall(INTERFACE_TASKTEMPLATE(':-insertdirect', ':-content' = wks)); NULL; end proc;
data := [["Case", "Optimal Pc"], ["μ₁ = 0, μ₂ = 0", "Pc₁"], ["μ₁ = 0, μ₂ > 0", "Pc₂"], ["μ₁ > 0, μ₂ = 0", "Pc₃"]];
grid(Matrix(data));

Is this correct ?


 

restart; with(PDEtools); with(plots); declare(w(r, z)); eta := 1; lambda := 1; A1 := 1; A2 := 1; A3 := 1; Da := 1; M := 1; m := 1; UHS := 1; Phi := (1/4)*Pi; dpdz := -1; N := 1; w[0] := proc (r, z) options operator, arrow; (1/2)*r^2-(1/2)*eta^2 end proc; w_total := proc (r, z) options operator, arrow; sum(p^n*w[n](r, z), n = 0 .. N) end proc; HPMEq := (1-p)*(diff(w[0](r, z), r, r))+p*(diff(w_total(r, z), r, r)+(diff(w_total(r, z), r))/r-(1+lambda)*(dpdz+A2*M^2*w_total(r, z)+A1*w_total(r, z)/Da-m^2*UHS*BesselI(0, m*r)/BesselI(0, m*eta)+A3*sin(Phi))/A1); for i from 0 to N do equ[i] := coeff(expand(HPMEq), p, i) = 0 end do; bc[0] := (D[1](w[0]))(0, z) = 0, w[0](eta, z) = 0; for j to N do bc[j] := (D[1](w[j]))(0, z) = 0, w[j](eta, z) = 0 end do; for i from 0 to N do if i = 0 then w[i] := unapply((-eta^2+r^2)*(1/2), r, z) else try dsol := dsolve({equ[i], w[i](eta, z) = 0, (D(w[i]))(0, z) = 0}, w[i](r, z)); w[i] := unapply(rhs(dsol), r, z) catch: print(`No analytic solution found for order`, i); w[i] := proc (r, z) options operator, arrow; 0 end proc end try end if end do; W_final := eval(sum(w[n](r, z), n = 0 .. N), p = 1); W_final := simplify(W_final); if has(W_final, w[1]) then print("Warning: Solution contains unresolved w[1] terms - using numerical approach"); W_plot := eval(W_final, w[1](r, z) = 0) else W_plot := W_final end if; plot(eval(W_plot, z = 0), r = 0 .. eta, title = "Velocity Profile w(r,0)", labels = ["r", "w(r,0)"], labeldirections = [horizontal, vertical], color = blue, thickness = 2, gridlines = true); plot3d(W_plot, r = 0 .. eta, z = 0 .. 1, title = "Velocity Distribution w(r,z)", labels = ["r", "z", "w(r,z)"], style = surfacecontour, shading = zhue, axes = boxed)

w(r, z)*`will now be displayed as`*w

 

1

 

proc (r, z) options operator, arrow; (1/2)*r^2-(1/2)*eta^2 end proc

 

proc (r, z) options operator, arrow; sum(p^n*w[n](r, z), n = 0 .. N) end proc

 

1-p+p*(5+p*(diff(diff(w[1](r, z), r), r))+(r+p*(diff(w[1](r, z), r)))/r-2*r^2-4*p*w[1](r, z)+2*BesselI(0, r)/BesselI(0, 1)-2^(1/2))

 

1 = 0

 

5-2*r^2+2*BesselI(0, r)/BesselI(0, 1)-2^(1/2) = 0

 

0 = 0, 0 = 0

 

(D[1](w[1]))(0, z) = 0, w[1](1, z) = 0

 

`No analytic solution found for order`, 1

 

(1/2)*r^2-1/2

 

(1/2)*r^2-1/2

 

(1/2)*r^2-1/2

 

 

 

NULL


 

Download perbiutation_pde_mprimes_21-7-2025.mw

@Alfred_F 
prove by induction ....


restart;
with(DEtools);
with(plots);
f := (x, y) -> 2*(x - 1)*sin(Pi*y) + (x - 1)^2;
g := (x, y) -> y^2 - y;
lin_sys1 := [diff(u(t), t) = 0, diff(v(t), t) = -v(t)];
lin_sys2 := [diff(u(t), t) = 0, diff(v(t), t) = v(t)];
orig_sys := [diff(x(t), t) = f(x(t), y(t)), diff(y(t), t) = g(x(t), y(t))];
plot_orig1 := DEplot(orig_sys, [x(t), y(t)], t = 0 .. 5, x = 0.5 .. 1.5, y = -0.5 .. 0.5, arrows = SLIM, dirfield = [20, 20], title = "Nonlinear system near (1, 0)", axes = boxed);
plot_orig2 := DEplot(orig_sys, [x(t), y(t)], t = 0 .. 5, x = 0.5 .. 1.5, y = 0.5 .. 1.5, arrows = SLIM, dirfield = [20, 20], title = "Nonlinear system near (1, 1)", axes = boxed);
plot_lin1 := DEplot(lin_sys1, [u(t), v(t)], t = 0 .. 5, u = -0.5 .. 0.5, v = -0.5 .. 0.5, arrows = SLIM, dirfield = [20, 20], title = "Linearized system at (1, 0) → origin (u,v)", axes = boxed);
plot_lin2 := DEplot(lin_sys2, [u(t), v(t)], t = 0 .. 5, u = -0.5 .. 0.5, v = -0.5 .. 0.5, arrows = SLIM, dirfield = [20, 20], title = "Linearized system at (1, 1) → origin (u,v)", axes = boxed);
display([plot_orig1, plot_lin1, plot_orig2, plot_lin2], title = "Comparison: Nonlinear vs. Linearized Systems at Critical Points", insequence = false, layout = [[1, 2], [3, 4]]);


with(LinearAlgebra);
with(DEtools);
with(plots);
fx := (x, y) -> 2*(x - 1)*sin(Pi*y) + (x - 1)^2;
fy := (x, y) -> y^2 - y;
solve({fx(x, y) = 0, fy(x, y) = 0}, {x, y});
J := Matrix(2, 2, [diff(fx(x, y), x), diff(fx(x, y), y), diff(fy(x, y), x), diff(fy(x, y), y)]);
J10 := eval(J, [x = 1, y = 0]);
J11 := eval(J, [x = 1, y = 1]);
print("Jacobiaan bij (1,0):", J10);
print("Jacobiaan bij (1,1):", J11);
sys_uv_10 := {diff(u(t), t) = Pi*v(t), diff(v(t), t) = -v(t)};
sys_uv_11 := {diff(u(t), t) = -Pi*v(t), diff(v(t), t) = v(t)};
field_orig_10 := DEplot([diff(x(t), t) = fx(x(t), y(t)), diff(y(t), t) = fy(x(t), y(t))], [x(t), y(t)], t = 0 .. 5, x = 0.5 .. 1.5, y = -0.5 .. 0.5, dirfield = [20, 20], arrows = SLIM, title = "Niet-lineair systeem rond (1,0)");
field_orig_11 := DEplot([diff(x(t), t) = fx(x(t), y(t)), diff(y(t), t) = fy(x(t), y(t))], [x(t), y(t)], t = 0 .. 5, x = 0.5 .. 1.5, y = 0.5 .. 1.5, dirfield = [20, 20], arrows = SLIM, title = "Niet-lineair systeem rond (1,1)");
field_lin_10 := DEplot([op(sys_uv_10)], [u(t), v(t)], t = 0 .. 5, u = -0.5 .. 0.5, v = -0.5 .. 0.5, dirfield = [20, 20], arrows = SLIM, title = "Linearisatie rond (1,0): u' = πv, v' = -v");
field_lin_11 := DEplot([op(sys_uv_11)], [u(t), v(t)], t = 0 .. 5, u = -0.5 .. 0.5, v = -0.5 .. 0.5, dirfield = [20, 20], arrows = SLIM, title = "Linearisatie rond (1,1): u' = -πv, v' = v");
display([field_orig_10, field_lin_10, field_orig_11, field_lin_11], title = "Origineel versus lineair systeem rond kritieke punten");

Drag to resize the screen and maybe you will see this in de right upper corner?

restart;
with(plots):
f := x -> cos(Pi*sqrt(x^2 + x + 1));
points := [seq([n, f(n)], n = 1 .. 100)]:
continuousPlot := plot(f(x), x = 1 .. 100, color = red, thickness = 2):
discretePlot := pointplot(points, symbol = solidcircle, color = blue):
linePlot := plottools[curve](points, color = green, linestyle = dot, thickness = 3):
display([continuousPlot, discretePlot, linePlot], title = "Gedrag van cos(Pi*sqrt(x^2 + x + 1)) versus f(n)", labels = ["x", "f(x)"], axes = boxed);

I think you can calculate with "polar" vectors in the Vector Calculus package , by setting up the appropriate coordinate system for this through the package.

But graphically you need to calculate the vectors back to Cartesian coordinates to plot them.

Create a small procedure for this then

There is a polar plot command, but that is for functions in polar coordinates.


from example 1 , as a start 

is almost identical with the LAD_complex procedure , see also plot comparison 

i changed the procedure, must be corrected manual

 procedure_complexe_pde_mprimesVERSIONA_11-6-2025.mw

Hopefully you are satisfied,because it is slightly different, but it can be made the same

 

with(plots); with(DEtools); with(LinearAlgebra); classify_critical_point := proc (A) local tr_A, det_A, Delta, lambda1, lambda2, eigenvals, classification, is_diagonal; tr_A := Trace(A); det_A := Determinant(A); Delta := tr_A^2-4*det_A; eigenvals := Eigenvalues(A); lambda1 := eigenvals[1]; lambda2 := eigenvals[2]; is_diagonal := A[1, 2] = 0 and A[2, 1] = 0; if 0 < Delta then if 0 < Re(lambda1) and 0 < Re(lambda2) then classification := "Unstable Node" elif Re(lambda1) < 0 and Re(lambda2) < 0 then classification := "Stable Node" else classification := "Saddle Point" end if elif Delta = 0 then if is_diagonal then if 0 < Re(lambda1) then classification := "Unstable Star" elif Re(lambda1) < 0 then classification := "Stable Star" else classification := "Centre" end if else if 0 < Re(lambda1) then classification := "Unstable Improper Node" elif Re(lambda1) < 0 then classification := "Stable Improper Node" else classification := "Centre" end if end if else if Re(lambda1) = 0 then classification := "Centre" elif 0 < Re(lambda1) then classification := "Unstable Focus" else classification := "Stable Focus" end if end if; return tr_A, det_A, Delta, eigenvals, classification end proc; create_phase_portrait := proc (A, title_text) local sys, x, y, t; sys := [diff(x(t), t) = A[1, 1]*x(t)+A[1, 2]*y(t), diff(y(t), t) = A[2, 1]*x(t)+A[2, 2]*y(t)]; DEplot(sys, [x(t), y(t)], t = 0 .. 5, [[x(0) = 1, y(0) = 0], [x(0) = -1, y(0) = 0], [x(0) = 0, y(0) = 1], [x(0) = 0, y(0) = -1], [x(0) = 1, y(0) = 1], [x(0) = -1, y(0) = -1], [x(0) = 1, y(0) = -1], [x(0) = -1, y(0) = 1], [x(0) = .5, y(0) = .5], [x(0) = -.5, y(0) = -.5]], x = -3 .. 3, y = -3 .. 3, arrows = medium, title = title_text, titlefont = [TIMES, BOLD, 14], linecolor = [blue, green, red, magenta, cyan, yellow, black, gray, navy, coral], size = [400, 400]) end proc; matrices := [Matrix([[1, 0], [0, 2]]), Matrix([[-1, 0], [0, 2]]), Matrix([[1, 0], [0, 1/2]]), Matrix([[-2, 1], [0, -3]]), Matrix([[2, 1], [0, 2]]), Matrix([[-3, 0], [0, -3]]), Matrix([[-1, 1], [0, -1]]), Matrix([[1/3, 0], [0, 1/3]]), Matrix([[3, 1], [-1, 3]]), Matrix([[0, -2], [-2, 0]]), Matrix([[0, -2], [2, 0]]), Matrix([[-3, -1], [1, -3]])]; plots_container := []; for i to 12 do tr_A, det_A, Delta, eigenvals, classification := classify_critical_point(matrices[i]); printf("Matrix %2d: %-20s Trace=%-5.2f Det=%-5.2f &Delta;=%-5.2f Eigenvals=%a\n", i, classification, evalf(tr_A), evalf(det_A), evalf(Delta), eigenvals); plot_title := sprintf("M%d: %s", i, classification); plots_container := [op(plots_container), create_phase_portrait(matrices[i], plot_title)] end do; printf("\n=== SUMMARY TABLE ===\n"); printf("Matrix | Trace | Det | &Delta; | Classification\n"); printf("-------|-------|-----|----|------------------------\n"); for i to 12 do tr_A, det_A, Delta, _, classification := classify_critical_point(matrices[i]); printf("  %2d   | %5.2f | %3.0f | %3.0f | %s\n", i, evalf(tr_A), evalf(det_A), evalf(Delta), classification) end do; display(Matrix(3, 4, plots_container), scaling = constrained); printf("\nAnalysis completed!\n")

 

 

 

 


Analysis completed!

 

Download Can_plot_the_matrix_instead_of_linear_system_of_odemprimes10-6-2025.mw

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 Plane with Equilibrium Points and Trajectories");
equilibrium_points := pointplot([[0, 0], [0, 1], [0, -1]], symbol = solidcircle, color = black, symbolsize = 15);
display([phase_plot, equilibrium_points], axes = normal, scaling = constrained, title = "Phase Plane with Equilibrium Points and Trajectories");
print("\n### STABILITY ANALYSIS ###");
F := [-x, y^2*(-y^2 + 1)];
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 at (0,0):");
print(J0);
eig0 := Eigenvalues(J0);
print("Eigenvalues:", eig0);
print("Conclusion:");
print("   - Eigenvalues: &lambda;1 = -1, &lambda;2 = 0");
print("   - One zero eigenvalue &rarr; linearization incomplete");
print("   - From original equation dy/dt = y^2(1-y^2):");
print("     * For y &approx; 0: dy/dt &approx; y^2 > 0 &rarr; y moves AWAY from 0");
print("   - Conclusion: (0,0) is UNSTABLE (non-attracting)");
print("\n2. Analysis for (0,1):");
J1 := eval(J, {x = 0, y = 1});
print("Jacobian at (0,1):");
print(J1);
eig1 := Eigenvalues(J1);
print("Eigenvalues:", eig1);
print("Conclusion:");
print("   - Eigenvalues: &lambda;1 = -1, &lambda;2 = -2");
print("   - Both eigenvalues negative &rarr; stable node");
print("   - All nearby trajectories converge to this point");
print("   - Conclusion: (0,1) is STABLE and ATTRACTING");
print("\n3. Analysis for (0,-1):");
Jm1 := eval(J, {x = 0, y = -1});
print("Jacobian at (0,-1):");
print(Jm1);
eigm1 := Eigenvalues(Jm1);
print("Eigenvalues:", eigm1);
print("Conclusion:");
print("   - Eigenvalues: &lambda;1 = -1, &lambda;2 = -2");
print("   - Both eigenvalues negative &rarr; stable node");
print("   - All nearby trajectories converge to this point");
print("   - Conclusion: (0,-1) is STABLE and ATTRACTING");
print("\n### SUMMARY OF EQUILIBRIUM POINTS ###");
print("1. (0,0): Unstable (non-hyperbolic point)");
print("2. (0,1): Stable and attracting node");
print("3. (0,-1): Stable and attracting node");
print("\nNote: The system shows bistability with two stable equilibria at (0,1) and (0,-1)");
1 2 3 4 5 6 Page 1 of 6