janhardo

890 Reputation

13 Badges

11 years, 300 days
B. Ed math

MaplePrimes Activity


These are answers submitted by janhardo

restart;

 

 

# Functional
J := y -> int(x*y(x), x = a..b);

 

proc (y) options operator, arrow; int(x*y(x), x = a .. b) end proc

(1.1)

# Constraint (length of fence)
L := y -> int(sqrt(1 + diff(y(x),x)^2), x = a..b);

proc (y) options operator, arrow; int(sqrt(1+(diff(y(x), x))^2), x = a .. b) end proc

(1.2)

with(PDEtools):
with(VariationalCalculus):

# Setup(mathematicalnotation = true):
declare(y(x), prime = x):

L := x*y(x) + lambda*sqrt(1 + (diff(y(x),x))^2);

EL := EulerLagrange(L, x, y(x));

EL:= simplify(EL);

y(x)*`will now be displayed as`*y

 

`derivatives with respect to`*x*`of functions of one variable will now be displayed with '`

 

x*y(x)+lambda*(1+(diff(y(x), x))^2)^(1/2)

 

{x+lambda*(diff(y(x), x))^2*(diff(diff(y(x), x), x))/(1+(diff(y(x), x))^2)^(3/2)-lambda*(diff(diff(y(x), x), x))/(1+(diff(y(x), x))^2)^(1/2)}

 

{(x*(1+(diff(y(x), x))^2)^(3/2)-lambda*(diff(diff(y(x), x), x)))/(1+(diff(y(x), x))^2)^(3/2)}

(1.3)

#solve first integral # reduce order of EL
eq := lambda*diff(y(x),x)/sqrt(1 + diff(y(x),x)^2) = x^2/2 + C;
# Solve for derivative
solve(eq, diff(y(x),x));

lambda*(diff(y(x), x))/(1+(diff(y(x), x))^2)^(1/2) = (1/2)*x^2+C

 

-(x^2+2*C)/(-x^4-4*C*x^2-4*C^2+4*lambda^2)^(1/2), (x^2+2*C)/(-x^4-4*C*x^2-4*C^2+4*lambda^2)^(1/2)

(1.4)
 

 

 

with(VariationalCalculus):

# 1. Define Lagrangian
L := (x, y, Dy) -> x*y + lambda*sqrt(1 + Dy^2);

# 2. Euler-Lagrange equation (returns a set!)
EL := EulerLagrange(L(x, y(x), diff(y(x), x)), x, y(x));

# 3. Convert set → expression
EL_eq := op(EL);

# 4. Rewrite into clean equation
eq := simplify(EL_eq = 0):

# 5. Solve for x explicitly (move terms)
eq2 := isolate(eq, x);

# 6. Now integrate both sides
left_int  := int(lhs(eq2), x);
right_int := int(rhs(eq2), x);

# 7. First integral
FI := left_int = right_int + C;

simplify(FI);

proc (x, y, Dy) options operator, arrow; y*x+lambda*sqrt(Dy^2+1) end proc

 

{x+lambda*(diff(y(x), x))^2*(diff(diff(y(x), x), x))/(1+(diff(y(x), x))^2)^(3/2)-lambda*(diff(diff(y(x), x), x))/(1+(diff(y(x), x))^2)^(1/2)}

 

x+lambda*(diff(y(x), x))^2*(diff(diff(y(x), x), x))/(1+(diff(y(x), x))^2)^(3/2)-lambda*(diff(diff(y(x), x), x))/(1+(diff(y(x), x))^2)^(1/2)

 

(x*(1+(diff(y(x), x))^2)^(3/2)-lambda*(diff(diff(y(x), x), x)))/(1+(diff(y(x), x))^2)^(3/2) = 0

 

(1/2)*x^2-lambda*(diff(y(x), x))/(1+(diff(y(x), x))^2)^(1/2)

 

0

 

(1/2)*x^2-lambda*(diff(y(x), x))/(1+(diff(y(x), x))^2)^(1/2) = C

 

(1/2)*x^2-lambda*(diff(y(x), x))/(1+(diff(y(x), x))^2)^(1/2) = C

(2.1)

A := x^2/2 - C:

p := [solve(lambda*p/sqrt(1+p^2) = A, p)];

[(-x^2+2*C)/(-x^4+4*C*x^2-4*C^2+4*lambda^2)^(1/2), -(-x^2+2*C)/(-x^4+4*C*x^2-4*C^2+4*lambda^2)^(1/2)]

(2.2)

p1 := op(1, p);   # eerste oplossing

(-x^2+2*C)/(-x^4+4*C*x^2-4*C^2+4*lambda^2)^(1/2)

(2.3)

 

y := int(p1, x);

(1/2)*C*2^(1/2)*(4-2*x^2/(C+lambda))^(1/2)*(4-2*x^2/(C-lambda))^(1/2)*EllipticF((1/2)*x*2^(1/2)*(1/(C+lambda))^(1/2), (-1+2*C/(C-lambda))^(1/2))/((1/(C+lambda))^(1/2)*(-x^4+4*C*x^2-4*C^2+4*lambda^2)^(1/2))+(1/2)*(-4*C^2+4*lambda^2)*2^(1/2)*(4-2*x^2/(C+lambda))^(1/2)*(4-2*x^2/(C-lambda))^(1/2)*(EllipticF((1/2)*x*2^(1/2)*(1/(C+lambda))^(1/2), (-1+2*C/(C-lambda))^(1/2))-EllipticE((1/2)*x*2^(1/2)*(1/(C+lambda))^(1/2), (-1+2*C/(C-lambda))^(1/2)))/((1/(C+lambda))^(1/2)*(-x^4+4*C*x^2-4*C^2+4*lambda^2)^(1/2)*(4*C+4*lambda))

(2.4)

difficult to solve  this first integral ?, two integals for mirror curves?

Download weideproblee_nu_voor_mpromesDEF_13-4-2026.mw


 

 

 

 

 

restart;
with(plots):

# ============================================================================
# EDUCATIONAL MAPLE CODE: RITZ METHOD FOR A NONLINEAR OSCILLATOR
# INCLUDING VISUALIZATION (CORRECTED)
# ============================================================================
#
# PROBLEM DESCRIPTION:
# Lagrangian: f = 1/2 (dx/dt)^2 + u^2 cos(x) + x v sin(t)
# Parameters: u = 0.3, v = -0.1
# Action: J = ∫_0^{2π} f dt   (equation (16))
# Goal: Minimize J using trial function x(t) = a0 + b1 sin(t)  (Ritz method)
#
# This code reproduces the optimal coefficients analytically and visualizes the result.
#
# ============================================================================

# Step 1: Define parameters numerically from the start
u := 0.3:
v := -0.1:
u2 := u^2:   # 0.09

# Trial function
x_trial := t -> A + B*sin(t):

printf("========================================\n");
printf("EDUCATIONAL OUTPUT\n");
printf("========================================\n\n");
printf("Step 1: Trial function x(t) = A + B sin(t)\n");
printf("Parameters: u = %.1f, v = %.1f\n", u, v);
printf("\n");

# Step 2: Lagrangian
dxdt := diff(x_trial(t), t);
f := 1/2 * dxdt^2 + u2*cos(x_trial(t)) + x_trial(t)*v*sin(t);
printf("Step 2: Lagrangian f = %a\n\n", f);

# Step 3: Action integral using orthogonality and Bessel identity
J1 := 1/2 * B^2 * Pi;
J2 := B * v * Pi;
J3 := u2 * 2*Pi * cos(A) * BesselJ(0, B);
J := J1 + J2 + J3;
printf("Step 3: Action J = ∫_0^{2π} f dt\n");
printf("      J = %a\n\n", J);

# Step 4: Minimize over A
# The only Adependent term is cos(A) with a positive coefficient → minimum at cos(A) = -1
A_opt := Pi;
printf("Step 4: Minimization over A → A_opt = π\n");
printf("      (because cos(A) minimal = -1)\n\n");

J_Aopt := eval(J, A = A_opt);
printf("      J after fixing A = π: %a\n\n", J_Aopt);

# Step 5: Minimize over B using derivative condition
# dJ/dB = π ( B + v + 2 u2 J1(B) ) = 0 → B + 0.18 J1(B) = -v = 0.1
eq := B + 2*u2*BesselJ(1, B) = -v;
printf("Step 5: Minimization over B\n");
printf("      Derivative condition: %a\n", eq);
printf("      Solving numerically...\n");
B_opt := fsolve(eq, B = 0.09);
printf("      Optimal B = %.10f\n\n", B_opt);

# Step 6: Minimal action
J_min := evalf(eval(J_Aopt, B = B_opt));
printf("Step 6: Minimal action J_min = %.10f\n\n", J_min);

# Step 7: Output coefficients
printf("========================================\n");
printf("OPTIMAL COEFFICIENTS (RITZ METHOD)\n");
printf("========================================\n");
printf("a0 = %.10f   (constant term)\n", A_opt);
printf("b1 = %.10f   (coefficient of sin(t))\n", B_opt);
printf("Minimal action J = %.10f\n", J_min);
printf("\nAll other Fourier coefficients (a1, a2, a3, b2, b3) are zero.\n");
printf("========================================\n\n");

# ============================================================================
# Step 8: Educational Plots
# ============================================================================

# Plot 1: Compare the optimal approximation with the numerical solution
# of the Euler–Lagrange equation (using the same numerical parameters)
Euler_eq := diff(x(t), t, t) + u^2*sin(x(t)) - v*sin(t) = 0;
ics := x(0)=0.3, D(x)(0)=0.1:
# Solve numerically over one period
sol_num := dsolve({Euler_eq, ics}, numeric, range=0..2*Pi);

# Optimal approximation function
x_opt := t -> A_opt + B_opt*sin(t);

# Generate the plots
p_num := odeplot(sol_num, [t, x(t)], t=0..2*Pi, color=blue, thickness=2, legend="Numerical solution (Euler-Lagrange)");
p_ritz := plot(x_opt(t), t=0..2*Pi, color=red, thickness=2, linestyle=dash, legend="Optimal approximation: π + b1·sin(t)");
p_compare := display(p_num, p_ritz,
                     title="Comparison: Optimal Ritz Approximation vs. Numerical Solution",
                     labels=["t", "x(t)"],
                     labeldirections=[horizontal, vertical],
                     legendstyle=[location=right],
                     size=[800,400]);

# Plot 2: Action J as a function of B (with A = π)
J_B := B -> evalf(1/2*B^2*Pi + B*v*Pi - 2*Pi*u2*BesselJ(0, B));
p_J := plot(J_B(B), B=0..0.2, color=green, thickness=2,
            title="Action J(B) for fixed A = π",
            labels=["B (amplitude of sin(t))", "J(B)"],
            labeldirections=[horizontal, vertical]);
p_min := pointplot([[B_opt, J_min]], color=red, symbol=solidcircle, symbolsize=12);
p_J_with_min := display(p_J, p_min,
                        textplot([B_opt+0.01, J_min+0.02, sprintf("Minimum at B=%.4f\nJ=%.4f", B_opt, J_min)], align=left),
                        size=[800,400]);

# Display both plots
printf("Generating educational plots...\n");
print(p_compare);
print(p_J_with_min);

# ============================================================================
# Step 9: Educational summary (printed in the output)
# ============================================================================
printf("\n========================================\n");
printf("EDUCATIONAL SUMMARY\n");
printf("========================================\n");
printf("1. Why are higher harmonics zero?\n");
printf("   The trial function x(t)=A+B sin(t) already gives a very low action.\n");
printf("   Adding cos(t), cos(2t), etc., would increase the action because the\n");
printf("   system is not strongly nonlinear (u is small) and forcing is at frequency 1.\n\n");
printf("2. What is the physical meaning of A = π?\n");
printf("   The cosine term u^2 cos(x) has a minimum at x = π (since cos(π) = -1).\n");
printf("   The system prefers to stay near the bottom of the cosine well, centered at π.\n\n");
printf("3. Why does the action become negative?\n");
printf("   J is not an energy; it can be negative because the Lagrangian includes\n");
printf("   the term x v sin(t) which can lower the value. The negative value indicates\n");
printf("   that the forcing does work on the system.\n\n");
printf("4. What do the plots show?\n");
printf("   - The comparison plot shows that the simple approximation π + b1 sin(t)\n");
printf("     matches the numerical solution very well over one period.\n");
printf("   - The J(B) plot confirms that the found B_opt indeed gives the minimum\n");
printf("     of the action functional.\n");
printf("========================================\n");

========================================
EDUCATIONAL OUTPUT
========================================

Step 1: Trial function x(t) = A + B sin(t)
Parameters: u = 0.3, v = -0.1

 

 

B*cos(t)

 

(1/2)*B^2*cos(t)^2+0.9e-1*cos(A+B*sin(t))-.1*(A+B*sin(t))*sin(t)

 

Step 2: Lagrangian f = 1/2*B^2*cos(t)^2+.9e-1*cos(A+B*sin(t))-.1*(A+B*sin(t))*sin(t)
 

 

(1/2)*B^2*Pi

 

-.3141592654*B

 

.5654866778*cos(A)*BesselJ(0, B)

 

(1/2)*B^2*Pi-.3141592654*B+.5654866778*cos(A)*BesselJ(0, B)

 

Step 3: Action J = ∫_0^{2π} f dt
      J = 1/2*B^2*Pi-.3141592654*B+.5654866778*cos(A)*BesselJ(0,B)

 

 

Pi

 

Step 4: Minimization over A → A_opt = π
      (because cos(A) minimal = -1)

 

 

(1/2)*B^2*Pi-.3141592654*B-.5654866778*BesselJ(0, B)

 

      J after fixing A = π: 1/2*B^2*Pi-.3141592654*B-.5654866778*BesselJ(0,B)
 

 

B+.18*BesselJ(1, B) = .1

 

Step 5: Minimization over B
      Derivative condition: B+.18*BesselJ(1,B) = .1
      Solving numerically...

 

0.9175108833e-1

 

      Optimal B = 0.0917510883
 

 

-.5798982792

 

Step 6: Minimal action J_min = -0.5798982792

========================================
OPTIMAL COEFFICIENTS (RITZ METHOD)
========================================
a0 = 3.1415926540   (constant term)
b1 = 0.0917510883   (coefficient of sin(t))
Minimal action J = -0.5798982792

All other Fourier coefficients (a1, a2, a3, b2, b3) are zero.
========================================

 

 

diff(diff(x(t), t), t)+0.9e-1*sin(x(t))+.1*sin(t) = 0

 

proc (x_rkf45) local _res, _dat, _vars, _solnproc, _xout, _ndsol, _pars, _n, _i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; if 1 < nargs then error "invalid input: too many arguments" end if; _EnvDSNumericSaveDigits := Digits; Digits := 15; if _EnvInFsolve = true then _xout := evalf[_EnvDSNumericSaveDigits](x_rkf45) else _xout := evalf(x_rkf45) end if; _dat := Array(1..4, {(1) = proc (_x_in) local _x_out, _dtbl, _dat, _vmap, _x0, _y0, _val, _digits, _neq, _nevar, _ndisc, _nevt, _pars, _ini, _par, _i, _j, _k, _src, _t1; option `Copyright (c) 2002 by Waterloo Maple Inc. All rights reserved.`; table( [( "left" ) = 0., ( "right" ) = 6.28318530717958, ( "complex" ) = false ] ) _x_out := _x_in; _pars := []; _dtbl := array( 1 .. 4, [( 1 ) = (array( 1 .. 28, [( 1 ) = (datatype = float[8], order = C_order, storage = rectangular), ( 2 ) = (datatype = float[8], order = C_order, storage = rectangular), ( 3 ) = ([0, 0, 0, Array(1..0, 1..2, {}, datatype = float[8], order = C_order)]), ( 4 ) = (Array(1..65, {(1) = 2, (2) = 2, (3) = 0, (4) = 0, (5) = 0, (6) = 0, (7) = 1, (8) = 0, (9) = 0, (10) = 1, (11) = 0, (12) = 0, (13) = 0, (14) = 0, (15) = 0, (16) = 0, (17) = 0, (18) = 1, (19) = 30000, (20) = 0, (21) = 0, (22) = 1, (23) = 4, (24) = 0, (25) = 1, (26) = 15, (27) = 1, (28) = 0, (29) = 1, (30) = 3, (31) = 3, (32) = 0, (33) = 1, (34) = 0, (35) = 0, (36) = 0, (37) = 0, (38) = 0, (39) = 0, (40) = 0, (41) = 0, (42) = 0, (43) = 1, (44) = 0, (45) = 0, (46) = 0, (47) = 0, (48) = 0, (49) = 0, (50) = 50, (51) = 1, (52) = 0, (53) = 0, (54) = 0, (55) = 0, (56) = 0, (57) = 0, (58) = 0, (59) = 10000, (60) = 0, (61) = 1000, (62) = 0, (63) = 0, (64) = -1, (65) = 0}, datatype = integer[8])), ( 5 ) = (Array(1..28, {(1) = 6.28318530717958, (2) = 0.10e-5, (3) = .0, (4) = 0.500001e-14, (5) = .0, (6) = .20190635023366182, (7) = .0, (8) = 0.10e-5, (9) = .0, (10) = .0, (11) = .0, (12) = .0, (13) = 1.0, (14) = .0, (15) = .49999999999999, (16) = .0, (17) = 1.0, (18) = 1.0, (19) = .0, (20) = .0, (21) = 1.0, (22) = 1.0, (23) = .0, (24) = .0, (25) = 0.10e-14, (26) = .0, (27) = .0, (28) = .0}, datatype = float[8], order = C_order)), ( 6 ) = (Array(1..2, {(1) = .3, (2) = .1}, datatype = float[8], order = C_order)), ( 7 ) = ([Array(1..4, 1..7, {(1, 1) = .0, (1, 2) = .203125, (1, 3) = .3046875, (1, 4) = .75, (1, 5) = .8125, (1, 6) = .40625, (1, 7) = .8125, (2, 1) = 0.6378173828125e-1, (2, 2) = .0, (2, 3) = .279296875, (2, 4) = .27237892150878906, (2, 5) = -0.9686851501464844e-1, (2, 6) = 0.1956939697265625e-1, (2, 7) = .5381584167480469, (3, 1) = 0.31890869140625e-1, (3, 2) = .0, (3, 3) = -.34375, (3, 4) = -.335235595703125, (3, 5) = .2296142578125, (3, 6) = .41748046875, (3, 7) = 11.480712890625, (4, 1) = 0.9710520505905151e-1, (4, 2) = .0, (4, 3) = .40350341796875, (4, 4) = 0.20297467708587646e-1, (4, 5) = -0.6054282188415527e-2, (4, 6) = -0.4770040512084961e-1, (4, 7) = .77858567237854}, datatype = float[8], order = C_order), Array(1..6, 1..6, {(1, 1) = .0, (1, 2) = .0, (1, 3) = .0, (1, 4) = .0, (1, 5) = .0, (1, 6) = 1.0, (2, 1) = .25, (2, 2) = .0, (2, 3) = .0, (2, 4) = .0, (2, 5) = .0, (2, 6) = 1.0, (3, 1) = .1875, (3, 2) = .5625, (3, 3) = .0, (3, 4) = .0, (3, 5) = .0, (3, 6) = 2.0, (4, 1) = .23583984375, (4, 2) = -.87890625, (4, 3) = .890625, (4, 4) = .0, (4, 5) = .0, (4, 6) = .2681884765625, (5, 1) = .1272735595703125, (5, 2) = -.5009765625, (5, 3) = .44921875, (5, 4) = -0.128936767578125e-1, (5, 5) = .0, (5, 6) = 0.626220703125e-1, (6, 1) = -0.927734375e-1, (6, 2) = .626220703125, (6, 3) = -.4326171875, (6, 4) = .1418304443359375, (6, 5) = -0.861053466796875e-1, (6, 6) = .3131103515625}, datatype = float[8], order = C_order), Array(1..6, {(1) = .0, (2) = .386, (3) = .21, (4) = .63, (5) = 1.0, (6) = 1.0}, datatype = float[8], order = C_order), Array(1..6, {(1) = .25, (2) = -.1043, (3) = .1035, (4) = -0.362e-1, (5) = .0, (6) = .0}, datatype = float[8], order = C_order), Array(1..6, 1..5, {(1, 1) = .0, (1, 2) = .0, (1, 3) = .0, (1, 4) = .0, (1, 5) = .0, (2, 1) = 1.544, (2, 2) = .0, (2, 3) = .0, (2, 4) = .0, (2, 5) = .0, (3, 1) = .9466785280815533, (3, 2) = .25570116989825814, (3, 3) = .0, (3, 4) = .0, (3, 5) = .0, (4, 1) = 3.3148251870684886, (4, 2) = 2.896124015972123, (4, 3) = .9986419139977808, (4, 4) = .0, (4, 5) = .0, (5, 1) = 1.2212245092262748, (5, 2) = 6.019134481287752, (5, 3) = 12.537083329320874, (5, 4) = -.687886036105895, (5, 5) = .0, (6, 1) = 1.2212245092262748, (6, 2) = 6.019134481287752, (6, 3) = 12.537083329320874, (6, 4) = -.687886036105895, (6, 5) = 1.0}, datatype = float[8], order = C_order), Array(1..6, 1..5, {(1, 1) = .0, (1, 2) = .0, (1, 3) = .0, (1, 4) = .0, (1, 5) = .0, (2, 1) = -5.6688, (2, 2) = .0, (2, 3) = .0, (2, 4) = .0, (2, 5) = .0, (3, 1) = -2.4300933568337584, (3, 2) = -.20635991570891224, (3, 3) = .0, (3, 4) = .0, (3, 5) = .0, (4, 1) = -.10735290581452621, (4, 2) = -9.594562251021896, (4, 3) = -20.470286148096154, (4, 4) = .0, (4, 5) = .0, (5, 1) = 7.496443313968615, (5, 2) = -10.246804314641219, (5, 3) = -33.99990352819906, (5, 4) = 11.708908932061595, (5, 5) = .0, (6, 1) = 8.083246795922411, (6, 2) = -7.981132988062785, (6, 3) = -31.52159432874373, (6, 4) = 16.319305431231363, (6, 5) = -6.0588182388340535}, datatype = float[8], order = C_order), Array(1..3, 1..5, {(1, 1) = .0, (1, 2) = .0, (1, 3) = .0, (1, 4) = .0, (1, 5) = .0, (2, 1) = 10.126235083446911, (2, 2) = -7.487995877607633, (2, 3) = -34.800918615557414, (2, 4) = -7.9927717075687275, (2, 5) = 1.0251377232956207, (3, 1) = -.6762803392806898, (3, 2) = 6.087714651678606, (3, 3) = 16.43084320892463, (3, 4) = 24.767225114183653, (3, 5) = -6.5943891257167815}, datatype = float[8], order = C_order)]), ( 9 ) = ([Array(1..2, {(1) = .1, (2) = .1}, datatype = float[8], order = C_order), Array(1..2, {(1) = -.11990012555221184, (2) = 0.26956772188392604e-1}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = 0.2798547339590383e-1, (2) = 0.7496702297005199e-3}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, 1..2, {(1, 1) = .0, (1, 2) = .0, (2, 1) = .0, (2, 2) = .0}, datatype = float[8], order = C_order), Array(1..2, 1..2, {(1, 1) = .0, (1, 2) = .0, (2, 1) = .0, (2, 2) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, 1..2, {(1, 1) = .0, (1, 2) = .0, (2, 1) = .0, (2, 2) = .0}, datatype = float[8], order = C_order), Array(1..2, 1..6, {(1, 1) = 0.2798547339590383e-1, (1, 2) = 0.24889277122565744e-1, (1, 3) = 0.25563448714937948e-1, (1, 4) = 0.27903883457214677e-1, (1, 5) = 0.27911631013882394e-1, (1, 6) = 0.26420737096037573e-1, (2, 1) = 0.7496702297005199e-3, (2, 2) = 0.26538729196858193e-1, (2, 3) = 0.22260997608620645e-1, (2, 4) = 0.3429766082058935e-2, (2, 5) = 0.8340304760743461e-3, (2, 6) = 0.17954453510388713e-1}, datatype = float[8], order = C_order), Array(1..2, {(1) = 0, (2) = 0}, datatype = integer[8]), Array(1..2, {(1) = -.11887456676993495, (2) = 0.27431881298329505e-1}, datatype = float[8], order = C_order), Array(1..2, {(1) = -.11617946174292089, (2) = 0.2798547339590383e-1}, datatype = float[8], order = C_order), Array(1..2, {(1) = 0.10125497523771898e-8, (2) = 0.32862245945286528e-8}, datatype = float[8], order = C_order), Array(1..2, {(1) = -.12490918174501053, (2) = 0.2194703086161099e-1}, datatype = float[8], order = C_order), Array(1..2, {(1) = 0.27075481401764558e-1, (2) = 0.13672218408041467e-1}, datatype = float[8], order = C_order), Array(1..4, {(1) = .0, (2) = .0, (3) = .0, (4) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = 0, (2) = 0}, datatype = integer[8])]), ( 8 ) = ([Array(1..2, {(1) = .3, (2) = .1}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = .1, (2) = -0.2659681859952056e-1}, datatype = float[8], order = C_order), 0, 0]), ( 11 ) = (Array(1..6, 0..2, {(1, 1) = .0, (1, 2) = .0, (2, 0) = .0, (2, 1) = .0, (2, 2) = .0, (3, 0) = .0, (3, 1) = .0, (3, 2) = .0, (4, 0) = .0, (4, 1) = .0, (4, 2) = .0, (5, 0) = .0, (5, 1) = .0, (5, 2) = .0, (6, 0) = .0, (6, 1) = .0, (6, 2) = .0}, datatype = float[8], order = C_order)), ( 10 ) = ([proc (N, X, Y, YP) option `[Y[1] = x(t), Y[2] = diff(x(t),t)]`; YP[2] := -0.9e-1*sin(Y[1])-.1*sin(X); YP[1] := Y[2]; 0 end proc, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), ( 13 ) = (), ( 12 ) = (), ( 15 ) = ("rkf45"), ( 14 ) = ([0, 0]), ( 18 ) = ([]), ( 19 ) = (0), ( 16 ) = ([0, 0, 0, 0, 0, 0, []]), ( 17 ) = ([proc (N, X, Y, YP) option `[Y[1] = x(t), Y[2] = diff(x(t),t)]`; YP[2] := -0.9e-1*sin(Y[1])-.1*sin(X); YP[1] := Y[2]; 0 end proc, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), ( 22 ) = (0), ( 23 ) = (0), ( 20 ) = ([]), ( 21 ) = (0), ( 27 ) = (""), ( 26 ) = (Array(1..0, {})), ( 25 ) = (Array(1..0, {})), ( 24 ) = (0), ( 28 ) = (0)  ] )), ( 3 ) = (array( 1 .. 28, [( 1 ) = (datatype = float[8], order = C_order, storage = rectangular), ( 2 ) = (datatype = float[8], order = C_order, storage = rectangular), ( 3 ) = ([0, 0, 0, Array(1..0, 1..2, {}, datatype = float[8], order = C_order)]), ( 4 ) = (Array(1..65, {(1) = 2, (2) = 2, (3) = 0, (4) = 0, (5) = 0, (6) = 0, (7) = 1, (8) = 1, (9) = 0, (10) = 1, (11) = 81, (12) = 81, (13) = 0, (14) = 0, (15) = 0, (16) = 0, (17) = 0, (18) = 141, (19) = 30000, (20) = 5, (21) = 0, (22) = 1, (23) = 4, (24) = 0, (25) = 1, (26) = 15, (27) = 1, (28) = 0, (29) = 1, (30) = 3, (31) = 3, (32) = 0, (33) = 1, (34) = 0, (35) = 0, (36) = 0, (37) = 0, (38) = 0, (39) = 0, (40) = 0, (41) = 0, (42) = 0, (43) = 1, (44) = 0, (45) = 0, (46) = 0, (47) = 0, (48) = 0, (49) = 0, (50) = 50, (51) = 1, (52) = 0, (53) = 0, (54) = 0, (55) = 0, (56) = 0, (57) = 0, (58) = 0, (59) = 10000, (60) = 0, (61) = 1000, (62) = 0, (63) = 0, (64) = -1, (65) = 0}, datatype = integer[8])), ( 5 ) = (Array(1..28, {(1) = 6.28318530717958, (2) = 0.10e-5, (3) = .32624262882989896, (4) = 0.500001e-14, (5) = .0, (6) = .20190635023366182, (7) = .0, (8) = 0.10e-5, (9) = .0, (10) = .0, (11) = .0, (12) = .0, (13) = 1.0, (14) = .0, (15) = .49999999999999, (16) = .0, (17) = 1.0, (18) = 1.0, (19) = .0, (20) = .0, (21) = 1.0, (22) = 1.0, (23) = .0, (24) = .0, (25) = 0.10e-14, (26) = .0, (27) = .0, (28) = .0}, datatype = float[8], order = C_order)), ( 6 ) = (Array(1..2, {(1) = .3, (2) = .1}, datatype = float[8], order = C_order)), ( 7 ) = ([Array(1..4, 1..7, {(1, 1) = .0, (1, 2) = .203125, (1, 3) = .3046875, (1, 4) = .75, (1, 5) = .8125, (1, 6) = .40625, (1, 7) = .8125, (2, 1) = 0.6378173828125e-1, (2, 2) = .0, (2, 3) = .279296875, (2, 4) = .27237892150878906, (2, 5) = -0.9686851501464844e-1, (2, 6) = 0.1956939697265625e-1, (2, 7) = .5381584167480469, (3, 1) = 0.31890869140625e-1, (3, 2) = .0, (3, 3) = -.34375, (3, 4) = -.335235595703125, (3, 5) = .2296142578125, (3, 6) = .41748046875, (3, 7) = 11.480712890625, (4, 1) = 0.9710520505905151e-1, (4, 2) = .0, (4, 3) = .40350341796875, (4, 4) = 0.20297467708587646e-1, (4, 5) = -0.6054282188415527e-2, (4, 6) = -0.4770040512084961e-1, (4, 7) = .77858567237854}, datatype = float[8], order = C_order), Array(1..6, 1..6, {(1, 1) = .0, (1, 2) = .0, (1, 3) = .0, (1, 4) = .0, (1, 5) = .0, (1, 6) = 1.0, (2, 1) = .25, (2, 2) = .0, (2, 3) = .0, (2, 4) = .0, (2, 5) = .0, (2, 6) = 1.0, (3, 1) = .1875, (3, 2) = .5625, (3, 3) = .0, (3, 4) = .0, (3, 5) = .0, (3, 6) = 2.0, (4, 1) = .23583984375, (4, 2) = -.87890625, (4, 3) = .890625, (4, 4) = .0, (4, 5) = .0, (4, 6) = .2681884765625, (5, 1) = .1272735595703125, (5, 2) = -.5009765625, (5, 3) = .44921875, (5, 4) = -0.128936767578125e-1, (5, 5) = .0, (5, 6) = 0.626220703125e-1, (6, 1) = -0.927734375e-1, (6, 2) = .626220703125, (6, 3) = -.4326171875, (6, 4) = .1418304443359375, (6, 5) = -0.861053466796875e-1, (6, 6) = .3131103515625}, datatype = float[8], order = C_order), Array(1..6, {(1) = .0, (2) = .386, (3) = .21, (4) = .63, (5) = 1.0, (6) = 1.0}, datatype = float[8], order = C_order), Array(1..6, {(1) = .25, (2) = -.1043, (3) = .1035, (4) = -0.362e-1, (5) = .0, (6) = .0}, datatype = float[8], order = C_order), Array(1..6, 1..5, {(1, 1) = .0, (1, 2) = .0, (1, 3) = .0, (1, 4) = .0, (1, 5) = .0, (2, 1) = 1.544, (2, 2) = .0, (2, 3) = .0, (2, 4) = .0, (2, 5) = .0, (3, 1) = .9466785280815533, (3, 2) = .25570116989825814, (3, 3) = .0, (3, 4) = .0, (3, 5) = .0, (4, 1) = 3.3148251870684886, (4, 2) = 2.896124015972123, (4, 3) = .9986419139977808, (4, 4) = .0, (4, 5) = .0, (5, 1) = 1.2212245092262748, (5, 2) = 6.019134481287752, (5, 3) = 12.537083329320874, (5, 4) = -.687886036105895, (5, 5) = .0, (6, 1) = 1.2212245092262748, (6, 2) = 6.019134481287752, (6, 3) = 12.537083329320874, (6, 4) = -.687886036105895, (6, 5) = 1.0}, datatype = float[8], order = C_order), Array(1..6, 1..5, {(1, 1) = .0, (1, 2) = .0, (1, 3) = .0, (1, 4) = .0, (1, 5) = .0, (2, 1) = -5.6688, (2, 2) = .0, (2, 3) = .0, (2, 4) = .0, (2, 5) = .0, (3, 1) = -2.4300933568337584, (3, 2) = -.20635991570891224, (3, 3) = .0, (3, 4) = .0, (3, 5) = .0, (4, 1) = -.10735290581452621, (4, 2) = -9.594562251021896, (4, 3) = -20.470286148096154, (4, 4) = .0, (4, 5) = .0, (5, 1) = 7.496443313968615, (5, 2) = -10.246804314641219, (5, 3) = -33.99990352819906, (5, 4) = 11.708908932061595, (5, 5) = .0, (6, 1) = 8.083246795922411, (6, 2) = -7.981132988062785, (6, 3) = -31.52159432874373, (6, 4) = 16.319305431231363, (6, 5) = -6.0588182388340535}, datatype = float[8], order = C_order), Array(1..3, 1..5, {(1, 1) = .0, (1, 2) = .0, (1, 3) = .0, (1, 4) = .0, (1, 5) = .0, (2, 1) = 10.126235083446911, (2, 2) = -7.487995877607633, (2, 3) = -34.800918615557414, (2, 4) = -7.9927717075687275, (2, 5) = 1.0251377232956207, (3, 1) = -.6762803392806898, (3, 2) = 6.087714651678606, (3, 3) = 16.43084320892463, (3, 4) = 24.767225114183653, (3, 5) = -6.5943891257167815}, datatype = float[8], order = C_order)]), ( 9 ) = ([Array(1..2, {(1) = .1, (2) = .1}, datatype = float[8], order = C_order), Array(1..2, {(1) = -.11990012555221184, (2) = 0.26956772188392604e-1}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = 0.2798547339590383e-1, (2) = 0.7496702297005199e-3}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, 1..2, {(1, 1) = .0, (1, 2) = .0, (2, 1) = .0, (2, 2) = .0}, datatype = float[8], order = C_order), Array(1..2, 1..2, {(1, 1) = .0, (1, 2) = .0, (2, 1) = .0, (2, 2) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, 1..2, {(1, 1) = .0, (1, 2) = .0, (2, 1) = .0, (2, 2) = .0}, datatype = float[8], order = C_order), Array(1..2, 1..6, {(1, 1) = 0.2798547339590383e-1, (1, 2) = 0.24889277122565744e-1, (1, 3) = 0.25563448714937948e-1, (1, 4) = 0.27903883457214677e-1, (1, 5) = 0.27911631013882394e-1, (1, 6) = 0.26420737096037573e-1, (2, 1) = 0.7496702297005199e-3, (2, 2) = 0.26538729196858193e-1, (2, 3) = 0.22260997608620645e-1, (2, 4) = 0.3429766082058935e-2, (2, 5) = 0.8340304760743461e-3, (2, 6) = 0.17954453510388713e-1}, datatype = float[8], order = C_order), Array(1..2, {(1) = 0, (2) = 0}, datatype = integer[8]), Array(1..2, {(1) = -.11887456676993495, (2) = 0.27431881298329505e-1}, datatype = float[8], order = C_order), Array(1..2, {(1) = -.11617946174292089, (2) = 0.2798547339590383e-1}, datatype = float[8], order = C_order), Array(1..2, {(1) = 0.10125497523771898e-8, (2) = 0.32862245945286528e-8}, datatype = float[8], order = C_order), Array(1..2, {(1) = -.12490918174501053, (2) = 0.2194703086161099e-1}, datatype = float[8], order = C_order), Array(1..2, {(1) = 0.27075481401764558e-1, (2) = 0.13672218408041467e-1}, datatype = float[8], order = C_order), Array(1..4, {(1) = .0, (2) = .0, (3) = .0, (4) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = 0, (2) = 0}, datatype = integer[8])]), ( 8 ) = ([Array(1..2, {(1) = -.12490918174501053, (2) = 0.2194703086161099e-1}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = 0.2798547339590383e-1, (2) = 0.7496702297005199e-3}, datatype = float[8], order = C_order), 0, 0]), ( 11 ) = (Array(1..6, 0..2, {(1, 1) = 6.043474944541868, (1, 2) = -.12490918174501053, (2, 0) = -.12490918174501053, (2, 1) = 0.2194703086161099e-1, (2, 2) = 6.127647961161466, (3, 0) = 6.127647961161466, (3, 1) = -.12294791999980416, (3, 2) = 0.24535766983493603e-1, (4, 0) = 0.24535766983493603e-1, (4, 1) = 6.211820977781064, (4, 2) = -.12079883393601093, (5, 0) = -.12079883393601093, (5, 1) = 0.26409464399094924e-1, (5, 2) = 6.2959939944006615, (6, 0) = 6.2959939944006615, (6, 1) = -.11852235106488974, (6, 2) = 0.27560190626197974e-1}, datatype = float[8], order = C_order)), ( 10 ) = ([proc (N, X, Y, YP) option `[Y[1] = x(t), Y[2] = diff(x(t),t)]`; YP[2] := -0.9e-1*sin(Y[1])-.1*sin(X); YP[1] := Y[2]; 0 end proc, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), ( 13 ) = (), ( 12 ) = (Array(1..81, 0..2, {(1, 1) = .0, (1, 2) = .3, (2, 0) = .3, (2, 1) = .1, (2, 2) = 0.50476587558415456e-1, (3, 0) = 0.50476587558415456e-1, (3, 1) = .3050114482203818, (3, 2) = 0.9851921935604928e-1, (4, 0) = 0.9851921935604928e-1, (4, 1) = .10095317511683091, (4, 2) = .3099411781975785, (5, 0) = .3099411781975785, (5, 1) = 0.9676248561585811e-1, (5, 2) = .15142976267524638, (6, 0) = .15142976267524638, (6, 1) = .3147753029596875, (6, 2) = 0.9473118844084455e-1, (7, 0) = 0.9473118844084455e-1, (7, 1) = .20190635023366182, (7, 2) = .3195000139167995, (8, 0) = .3195000139167995, (8, 1) = 0.924274205622514e-1, (8, 2) = .29363539419083473, (9, 0) = .29363539419083473, (9, 1) = .3277614390279715, (9, 2) = 0.8755291733770339e-1, (10, 0) = 0.8755291733770339e-1, (10, 1) = .3853644381480076, (10, 2) = .3355356570968603, (11, 0) = .3355356570968603, (11, 1) = 0.8181089376694904e-1, (11, 2) = .4770934821051805, (12, 0) = .4770934821051805, (12, 1) = .34274459312321004, (12, 2) = 0.752312826436502e-1, (13, 0) = 0.752312826436502e-1, (13, 1) = .5688225260623534, (13, 2) = .3493130709412674, (14, 0) = .3493130709412674, (14, 1) = 0.6785108000825477e-1, (14, 2) = .660760983474209, (15, 0) = .660760983474209, (15, 1) = .3551818815449684, (15, 2) = 0.5969473799971197e-1, (16, 0) = 0.5969473799971197e-1, (16, 1) = .7526994408860646, (16, 2) = .3602677228595546, (17, 0) = .3602677228595546, (17, 1) = 0.5082904738569923e-1, (17, 2) = .8446378982979201, (18, 0) = .8446378982979201, (18, 1) = .3645080877533099, (18, 2) = 0.4131077817771062e-1, (19, 0) = 0.4131077817771062e-1, (19, 1) = .9365763557097757, (19, 2) = .36784581272651407, (20, 0) = .36784581272651407, (20, 1) = 0.31202246609057696e-1, (20, 2) = 1.017269498487697, (21, 0) = 1.017269498487697, (21, 1) = .3699907318967812, (21, 2) = 0.2189704579949338e-1, (22, 0) = 0.2189704579949338e-1, (22, 1) = 1.0979626412656183, (22, 2) = .3713701448557083, (23, 0) = .3713701448557083, (23, 1) = 0.12237838770479901e-1, (23, 2) = 1.1786557840435394, (24, 0) = 1.1786557840435394, (24, 1) = .3719575743362944, (24, 2) = 0.2275621960669742e-2, (25, 0) = 0.2275621960669742e-2, (25, 1) = 1.2593489268214608, (25, 2) = .37173069979015416, (26, 0) = .37173069979015416, (26, 1) = -0.7936579746404444e-2, (26, 2) = 1.3334081366632657, (27, 0) = 1.3334081366632657, (27, 1) = .37079033061736805, (27, 2) = -0.17482281593755717e-1, (28, 0) = -0.17482281593755717e-1, (28, 1) = 1.4074673465050704, (28, 2) = .36913826353376844, (29, 0) = .36913826353376844, (29, 1) = -0.2714881951044076e-1, (29, 2) = 1.4815265563468754, (30, 0) = 1.4815265563468754, (30, 1) = .3667671930495605, (30, 2) = -0.36891973941901676e-1, (31, 0) = -0.36891973941901676e-1, (31, 1) = 1.5555857661886803, (31, 2) = .36367309945183196, (32, 0) = .36367309945183196, (32, 1) = -0.4666703333663231e-1, (32, 2) = 1.629410829831442, (33, 0) = 1.629410829831442, (33, 1) = .3598684867538772, (33, 2) = -0.5639813716926602e-1, (34, 0) = -0.5639813716926602e-1, (34, 1) = 1.7032358934742038, (34, 2) = .3553473387520533, (35, 0) = .3553473387520533, (35, 1) = -0.6607139792724324e-1, (35, 2) = 1.7770609571169658, (36, 0) = 1.7770609571169658, (36, 1) = .35011556039332953, (36, 2) = -0.7564231419264185e-1, (37, 0) = -0.7564231419264185e-1, (37, 1) = 1.8508860207597275, (37, 2) = .3441823365276038, (38, 0) = .3441823365276038, (38, 1) = -0.8506684203146951e-1, (38, 2) = 1.9287682027235928, (39, 0) = 1.9287682027235928, (39, 1) = .3371764907580068, (39, 2) = -0.9480268259399298e-1, (40, 0) = -0.9480268259399298e-1, (40, 1) = 2.006650384687458, (40, 2) = .3294222678883278, (41, 0) = .3294222678883278, (41, 1) = -.10427722774771646, (41, 2) = 2.084532566651323, (42, 0) = 2.084532566651323, (42, 1) = .3209418799644042, (42, 2) = -.11344193642496792, (43, 0) = -.11344193642496792, (43, 1) = 2.1624147486151886, (43, 2) = .31176129129571295, (44, 0) = .31176129129571295, (44, 1) = -.12224999306975382, (44, 2) = 2.244933369267561, (45, 0) = 2.244933369267561, (45, 1) = .30130318845046994, (45, 2) = -.1311433190097782, (46, 0) = -.1311433190097782, (46, 1) = 2.327451989919933, (46, 2) = .2901316137516785, (47, 0) = .2901316137516785, (47, 1) = -.13953505307415567, (47, 2) = 2.4099706105723055, (48, 0) = 2.4099706105723055, (48, 1) = .27828985981470705, (48, 2) = -.1473776494412471, (49, 0) = -.1473776494412471, (49, 1) = 2.4924892312246776, (49, 2) = .2658250782797199, (50, 0) = .2658250782797199, (50, 1) = -.15462708008851125, (50, 2) = 2.581232704899503, (51, 0) = 2.581232704899503, (51, 1) = .2517828384615066, (51, 2) = -.1617153362981406, (52, 0) = -.1617153362981406, (52, 1) = 2.669976178574329, (52, 2) = .23714582565808437, (53, 0) = .23714582565808437, (53, 1) = -.16802592081661238, (53, 2) = 2.758719652249154, (54, 0) = 2.758719652249154, (54, 1) = .2219846819827078, (54, 2) = -.17351965134456726, (55, 0) = -.17351965134456726, (55, 1) = 2.8474631259239795, (55, 2) = .2063734025755362, (56, 0) = .2063734025755362, (56, 1) = -.178163456025595, (56, 2) = 2.9378552106484803, (57, 0) = 2.9378552106484803, (57, 1) = .19008887325780605, (57, 2) = -.18199204594806803, (58, 0) = -.18199204594806803, (58, 1) = 3.0282472953729815, (58, 2) = .17350029845097795, (59, 0) = .17350029845097795, (59, 1) = -.1848896302155885, (59, 2) = 3.1186393800974823, (60, 0) = 3.1186393800974823, (60, 1) = .1566923406739759, (60, 2) = -.18684206720794194, (61, 0) = -.18684206720794194, (61, 1) = 3.209031464821983, (61, 2) = .13975078435906652, (62, 0) = .13975078435906652, (62, 1) = -.18784255664113073, (62, 2) = 3.292774661352433, (63, 0) = 3.292774661352433, (63, 1) = .1240113171427658, (63, 2) = -.18792032026222139, (64, 0) = -.18792032026222139, (64, 1) = 3.376517857882883, (64, 2) = .1082993945302594, (65, 0) = .1082993945302594, (65, 1) = -.18718756026300323, (65, 2) = 3.4602610544133334, (66, 0) = 3.4602610544133334, (66, 1) = 0.9268232424226719e-1, (66, 2) = -.1856557715538923, (67, 0) = -.1856557715538923, (67, 1) = 3.5440042509437832, (67, 2) = 0.7722634410466553e-1, (68, 0) = 0.7722634410466553e-1, (68, 1) = -.18334173875536733, (68, 2) = 3.622774239102036, (69, 0) = 3.622774239102036, (69, 1) = 0.628932484716877e-1, (69, 2) = -.18047079327419985, (70, 0) = -.18047079327419985, (70, 1) = 3.701544227260289, (70, 2) = 0.4881210388048465e-1, (71, 0) = 0.4881210388048465e-1, (71, 1) = -.1769495982089581, (71, 2) = 3.7803142154185414, (72, 0) = 3.7803142154185414, (72, 1) = 0.35033045499631474e-1, (72, 2) = -.17280431622338957, (73, 0) = -.17280431622338957, (73, 1) = 3.8590842035767943, (73, 2) = 0.21604077136370962e-1, (74, 0) = 0.21604077136370962e-1, (74, 1) = -.16806470630818982, (74, 2) = 3.9340154427946628, (75, 0) = 3.9340154427946628, (75, 1) = 0.919615606828235e-2, (75, 2) = -.16303479944749624, (76, 0) = -.16303479944749624, (76, 1) = 4.008946682012532, (76, 2) = -0.28167947847693156e-2, (77, 0) = -0.28167947847693156e-2, (77, 1) = -.1575285297209336, (77, 2) = 4.083877921230401, (78, 0) = 4.083877921230401, (78, 1) = -0.1440037826055148e-1, (78, 2) = -.1515796836371908, (79, 0) = -.1515796836371908, (79, 1) = 4.1588091604482695, (79, 2) = -0.25522772166443962e-1, (80, 0) = -0.25522772166443962e-1, (80, 1) = -.1452242826809636, (80, 2) = 4.233887923015492, (81, 0) = 4.233887923015492, (81, 1) = -0.3617530325305417e-1, (81, 2) = -.13848688284409977}, datatype = float[8], order = C_order)), ( 15 ) = ("rkf45"), ( 14 ) = ([0, 0]), ( 19 ) = (0), ( 16 ) = ([0, 0, 0, 0, 0, 0, []]), ( 17 ) = ([proc (N, X, Y, YP) option `[Y[1] = x(t), Y[2] = diff(x(t),t)]`; YP[2] := -0.9e-1*sin(Y[1])-.1*sin(X); YP[1] := Y[2]; 0 end proc, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), ( 22 ) = (0), ( 23 ) = (0), ( 20 ) = ([]), ( 21 ) = (0), ( 27 ) = (""), ( 26 ) = (Array(1..0, {})), ( 25 ) = (Array(1..0, {})), ( 24 ) = (0), ( 28 ) = (0)  ] )), ( 4 ) = (3)  ] ); _y0 := Array(0..2, {(1) = 0., (2) = .3}); _vmap := array( 1 .. 2, [( 1 ) = (1), ( 2 ) = (2)  ] ); _x0 := _dtbl[1][5][5]; _neq := _dtbl[1][4][1]; _nevar := _dtbl[1][4][3]; _ndisc := _dtbl[1][4][4]; _nevt := _dtbl[1][4][16]; if not type(_x_out, 'numeric') then if member(_x_out, ["start", "left", "right"]) then if _Env_smart_dsolve_numeric = true or _dtbl[1][4][10] = 1 then if _x_out = "left" then if type(_dtbl[2], 'array') then return _dtbl[2][5][1] end if elif _x_out = "right" then if type(_dtbl[3], 'array') then return _dtbl[3][5][1] end if end if end if; return _dtbl[1][5][5] elif _x_out = "method" then return _dtbl[1][15] elif _x_out = "storage" then return evalb(_dtbl[1][4][10] = 1) elif _x_out = "leftdata" then if not type(_dtbl[2], 'array') then return NULL else return eval(_dtbl[2]) end if elif _x_out = "rightdata" then if not type(_dtbl[3], 'array') then return NULL else return eval(_dtbl[3]) end if elif _x_out = "enginedata" then return _dtbl[1] elif _x_out = "enginereset" then _dtbl[2] := evaln(_dtbl[2]); _dtbl[3] := evaln(_dtbl[3]); return NULL elif _x_out = "initial" then return procname(_y0[0]) elif _x_out = "laxtol" then return _dtbl[`if`(member(_dtbl[4], {2, 3}), _dtbl[4], 1)][5][18] elif _x_out = "numfun" then return `if`(member(_dtbl[4], {2, 3}), _dtbl[_dtbl[4]][4][18], 0) elif _x_out = "parameters" then return [seq(_y0[_neq+_i], _i = 1 .. nops(_pars))] elif _x_out = "initial_and_parameters" then return procname(_y0[0]), [seq(_y0[_neq+_i], _i = 1 .. nops(_pars))] elif _x_out = "last" then if _dtbl[4] <> 2 and _dtbl[4] <> 3 or _x0-_dtbl[_dtbl[4]][5][1] = 0. then error "no information is available on last computed point" else _x_out := _dtbl[_dtbl[4]][5][1] end if elif _x_out = "function" then if _dtbl[1][4][33]-2. = 0 then return eval(_dtbl[1][10], 1) else return eval(_dtbl[1][10][1], 1) end if elif _x_out = "map" then return copy(_vmap) elif type(_x_in, `=`) and type(rhs(_x_in), 'list') and member(lhs(_x_in), {"initial", "parameters", "initial_and_parameters"}) then _ini, _par := [], []; if lhs(_x_in) = "initial" then _ini := rhs(_x_in) elif lhs(_x_in) = "parameters" then _par := rhs(_x_in) elif select(type, rhs(_x_in), `=`) <> [] then _par, _ini := selectremove(type, rhs(_x_in), `=`) elif nops(rhs(_x_in)) < nops(_pars)+1 then error "insufficient data for specification of initial and parameters" else _par := rhs(_x_in)[-nops(_pars) .. -1]; _ini := rhs(_x_in)[1 .. -nops(_pars)-1] end if; _x_out := lhs(_x_out); _i := false; if _par <> [] then _i := `dsolve/numeric/process_parameters`(_neq, _pars, _par, _y0) end if; if _ini <> [] then _i := `dsolve/numeric/process_initial`(_neq-_nevar, _ini, _y0, _pars, _vmap) or _i end if; if _i then `dsolve/numeric/SC/reinitialize`(_dtbl, _y0, _neq, procname, _pars); if _Env_smart_dsolve_numeric = true and type(_y0[0], 'numeric') and _dtbl[1][4][10] <> 1 then procname("right") := _y0[0]; procname("left") := _y0[0] end if end if; if _x_out = "initial" then return [_y0[0], seq(_y0[_vmap[_i]], _i = 1 .. _neq-_nevar)] elif _x_out = "parameters" then return [seq(_y0[_neq+_i], _i = 1 .. nops(_pars))] else return [_y0[0], seq(_y0[_vmap[_i]], _i = 1 .. _neq-_nevar)], [seq(_y0[_neq+_i], _i = 1 .. nops(_pars))] end if elif _x_in = "eventstop" then if _nevt = 0 then error "this solution has no events" end if; _i := _dtbl[4]; if _i <> 2 and _i <> 3 then return 0 end if; if _dtbl[_i][4][10] = 1 and assigned(_dtbl[5-_i]) and _dtbl[_i][4][9] < 100 and 100 <= _dtbl[5-_i][4][9] then _i := 5-_i; _dtbl[4] := _i; _j := round(_dtbl[_i][4][17]); return round(_dtbl[_i][3][1][_j, 1]) elif 100 <= _dtbl[_i][4][9] then _j := round(_dtbl[_i][4][17]); return round(_dtbl[_i][3][1][_j, 1]) else return 0 end if elif _x_in = "eventstatus" then if _nevt = 0 then error "this solution has no events" end if; _i := [selectremove(proc (a) options operator, arrow; _dtbl[1][3][1][a, 7] = 1 end proc, {seq(_j, _j = 1 .. round(_dtbl[1][3][1][_nevt+1, 1]))})]; return ':-enabled' = _i[1], ':-disabled' = _i[2] elif _x_in = "eventclear" then if _nevt = 0 then error "this solution has no events" end if; _i := _dtbl[4]; if _i <> 2 and _i <> 3 then error "no events to clear" end if; if _dtbl[_i][4][10] = 1 and assigned(_dtbl[5-_i]) and _dtbl[_i][4][9] < 100 and 100 < _dtbl[5-_i][4][9] then _dtbl[4] := 5-_i; _i := 5-_i end if; if _dtbl[_i][4][9] < 100 then error "no events to clear" elif _nevt < _dtbl[_i][4][9]-100 then error "event error condition cannot be cleared" else _j := _dtbl[_i][4][9]-100; if irem(round(_dtbl[_i][3][1][_j, 4]), 2) = 1 then error "retriggerable events cannot be cleared" end if; _j := round(_dtbl[_i][3][1][_j, 1]); for _k to _nevt do if _dtbl[_i][3][1][_k, 1] = _j then if _dtbl[_i][3][1][_k, 2] = 3 then error "range events cannot be cleared" end if; _dtbl[_i][3][1][_k, 8] := _dtbl[_i][3][1][_nevt+1, 8] end if end do; _dtbl[_i][4][17] := 0; _dtbl[_i][4][9] := 0; if _dtbl[1][4][10] = 1 then if _i = 2 then try procname(procname("left")) catch:  end try else try procname(procname("right")) catch:  end try end if end if end if; return  elif type(_x_in, `=`) and member(lhs(_x_in), {"eventdisable", "eventenable"}) then if _nevt = 0 then error "this solution has no events" end if; if type(rhs(_x_in), {('list')('posint'), ('set')('posint')}) then _i := {op(rhs(_x_in))} elif type(rhs(_x_in), 'posint') then _i := {rhs(_x_in)} else error "event identifiers must be integers in the range 1..%1", round(_dtbl[1][3][1][_nevt+1, 1]) end if; if select(proc (a) options operator, arrow; _nevt < a end proc, _i) <> {} then error "event identifiers must be integers in the range 1..%1", round(_dtbl[1][3][1][_nevt+1, 1]) end if; _k := {}; for _j to _nevt do if member(round(_dtbl[1][3][1][_j, 1]), _i) then _k := `union`(_k, {_j}) end if end do; _i := _k; if lhs(_x_in) = "eventdisable" then _dtbl[4] := 0; _j := [evalb(assigned(_dtbl[2]) and member(_dtbl[2][4][17], _i)), evalb(assigned(_dtbl[3]) and member(_dtbl[3][4][17], _i))]; for _k in _i do _dtbl[1][3][1][_k, 7] := 0; if assigned(_dtbl[2]) then _dtbl[2][3][1][_k, 7] := 0 end if; if assigned(_dtbl[3]) then _dtbl[3][3][1][_k, 7] := 0 end if end do; if _j[1] then for _k to _nevt+1 do if _k <= _nevt and not type(_dtbl[2][3][4][_k, 1], 'undefined') then userinfo(3, {'events', 'eventreset'}, `reinit #2, event code `, _k, ` to defined init `, _dtbl[2][3][4][_k, 1]); _dtbl[2][3][1][_k, 8] := _dtbl[2][3][4][_k, 1] elif _dtbl[2][3][1][_k, 2] = 0 and irem(iquo(round(_dtbl[2][3][1][_k, 4]), 32), 2) = 1 then userinfo(3, {'events', 'eventreset'}, `reinit #2, event code `, _k, ` to rate hysteresis init `, _dtbl[2][5][24]); _dtbl[2][3][1][_k, 8] := _dtbl[2][5][24] elif _dtbl[2][3][1][_k, 2] = 0 and irem(iquo(round(_dtbl[2][3][1][_k, 4]), 2), 2) = 0 then userinfo(3, {'events', 'eventreset'}, `reinit #2, event code `, _k, ` to initial init `, _x0); _dtbl[2][3][1][_k, 8] := _x0 else userinfo(3, {'events', 'eventreset'}, `reinit #2, event code `, _k, ` to fireinitial init `, _x0-1); _dtbl[2][3][1][_k, 8] := _x0-1 end if end do; _dtbl[2][4][17] := 0; _dtbl[2][4][9] := 0; if _dtbl[1][4][10] = 1 then procname(procname("left")) end if end if; if _j[2] then for _k to _nevt+1 do if _k <= _nevt and not type(_dtbl[3][3][4][_k, 2], 'undefined') then userinfo(3, {'events', 'eventreset'}, `reinit #3, event code `, _k, ` to defined init `, _dtbl[3][3][4][_k, 2]); _dtbl[3][3][1][_k, 8] := _dtbl[3][3][4][_k, 2] elif _dtbl[3][3][1][_k, 2] = 0 and irem(iquo(round(_dtbl[3][3][1][_k, 4]), 32), 2) = 1 then userinfo(3, {'events', 'eventreset'}, `reinit #3, event code `, _k, ` to rate hysteresis init `, _dtbl[3][5][24]); _dtbl[3][3][1][_k, 8] := _dtbl[3][5][24] elif _dtbl[3][3][1][_k, 2] = 0 and irem(iquo(round(_dtbl[3][3][1][_k, 4]), 2), 2) = 0 then userinfo(3, {'events', 'eventreset'}, `reinit #3, event code `, _k, ` to initial init `, _x0); _dtbl[3][3][1][_k, 8] := _x0 else userinfo(3, {'events', 'eventreset'}, `reinit #3, event code `, _k, ` to fireinitial init `, _x0+1); _dtbl[3][3][1][_k, 8] := _x0+1 end if end do; _dtbl[3][4][17] := 0; _dtbl[3][4][9] := 0; if _dtbl[1][4][10] = 1 then procname(procname("right")) end if end if else for _k in _i do _dtbl[1][3][1][_k, 7] := 1 end do; _dtbl[2] := evaln(_dtbl[2]); _dtbl[3] := evaln(_dtbl[3]); _dtbl[4] := 0; if _dtbl[1][4][10] = 1 then if _x0 <= procname("right") then try procname(procname("right")) catch:  end try end if; if procname("left") <= _x0 then try procname(procname("left")) catch:  end try end if end if end if; return  elif type(_x_in, `=`) and lhs(_x_in) = "eventfired" then if not type(rhs(_x_in), 'list') then error "'eventfired' must be specified as a list" end if; if _nevt = 0 then error "this solution has no events" end if; if _dtbl[4] <> 2 and _dtbl[4] <> 3 then error "'direction' must be set prior to calling/setting 'eventfired'" end if; _i := _dtbl[4]; _val := NULL; if not assigned(_EnvEventRetriggerWarned) then _EnvEventRetriggerWarned := false end if; for _k in rhs(_x_in) do if type(_k, 'integer') then _src := _k elif type(_k, 'integer' = 'anything') and type(evalf(rhs(_k)), 'numeric') then _k := lhs(_k) = evalf[max(Digits, 18)](rhs(_k)); _src := lhs(_k) else error "'eventfired' entry is not valid: %1", _k end if; if _src < 1 or round(_dtbl[1][3][1][_nevt+1, 1]) < _src then error "event identifiers must be integers in the range 1..%1", round(_dtbl[1][3][1][_nevt+1, 1]) end if; _src := {seq(`if`(_dtbl[1][3][1][_j, 1]-_src = 0., _j, NULL), _j = 1 .. _nevt)}; if nops(_src) <> 1 then error "'eventfired' can only be set/queried for root-finding events and time/interval events" end if; _src := _src[1]; if _dtbl[1][3][1][_src, 2] <> 0. and _dtbl[1][3][1][_src, 2]-2. <> 0. then error "'eventfired' can only be set/queried for root-finding events and time/interval events" elif irem(round(_dtbl[1][3][1][_src, 4]), 2) = 1 then if _EnvEventRetriggerWarned = false then WARNING(`'eventfired' has no effect on events that retrigger`) end if; _EnvEventRetriggerWarned := true end if; if _dtbl[_i][3][1][_src, 2] = 0 and irem(iquo(round(_dtbl[_i][3][1][_src, 4]), 32), 2) = 1 then _val := _val, undefined elif type(_dtbl[_i][3][4][_src, _i-1], 'undefined') or _i = 2 and _dtbl[2][3][1][_src, 8] < _dtbl[2][3][4][_src, 1] or _i = 3 and _dtbl[3][3][4][_src, 2] < _dtbl[3][3][1][_src, 8] then _val := _val, _dtbl[_i][3][1][_src, 8] else _val := _val, _dtbl[_i][3][4][_src, _i-1] end if; if type(_k, `=`) then if _dtbl[_i][3][1][_src, 2] = 0 and irem(iquo(round(_dtbl[_i][3][1][_src, 4]), 32), 2) = 1 then error "cannot set event code for a rate hysteresis event" end if; userinfo(3, {'events', 'eventreset'}, `manual set event code `, _src, ` to value `, rhs(_k)); _dtbl[_i][3][1][_src, 8] := rhs(_k); _dtbl[_i][3][4][_src, _i-1] := rhs(_k) end if end do; return [_val] elif type(_x_in, `=`) and lhs(_x_in) = "direction" then if not member(rhs(_x_in), {-1, 1, ':-left', ':-right'}) then error "'direction' must be specified as either '1' or 'right' (positive) or '-1' or 'left' (negative)" end if; _src := `if`(_dtbl[4] = 2, -1, `if`(_dtbl[4] = 3, 1, undefined)); _i := `if`(member(rhs(_x_in), {1, ':-right'}), 3, 2); _dtbl[4] := _i; _dtbl[_i] := `dsolve/numeric/SC/IVPdcopy`(_dtbl[1], `if`(assigned(_dtbl[_i]), _dtbl[_i], NULL)); if 0 < _nevt then for _j to _nevt+1 do if _j <= _nevt and not type(_dtbl[_i][3][4][_j, _i-1], 'undefined') then userinfo(3, {'events', 'eventreset'}, `reinit #4, event code `, _j, ` to defined init `, _dtbl[_i][3][4][_j, _i-1]); _dtbl[_i][3][1][_j, 8] := _dtbl[_i][3][4][_j, _i-1] elif _dtbl[_i][3][1][_j, 2] = 0 and irem(iquo(round(_dtbl[_i][3][1][_j, 4]), 32), 2) = 1 then userinfo(3, {'events', 'eventreset'}, `reinit #4, event code `, _j, ` to rate hysteresis init `, _dtbl[_i][5][24]); _dtbl[_i][3][1][_j, 8] := _dtbl[_i][5][24] elif _dtbl[_i][3][1][_j, 2] = 0 and irem(iquo(round(_dtbl[_i][3][1][_j, 4]), 2), 2) = 0 then userinfo(3, {'events', 'eventreset'}, `reinit #4, event code `, _j, ` to initial init `, _x0); _dtbl[_i][3][1][_j, 8] := _x0 else userinfo(3, {'events', 'eventreset'}, `reinit #4, event code `, _j, ` to fireinitial init `, _x0-2*_i+5.0); _dtbl[_i][3][1][_j, 8] := _x0-2*_i+5.0 end if end do end if; return _src elif _x_in = "eventcount" then if _dtbl[1][3][1] = 0 or _dtbl[4] <> 2 and _dtbl[4] <> 3 then return 0 else return round(_dtbl[_dtbl[4]][3][1][_nevt+1, 12]) end if elif type(_x_in, `=`) and lhs(_x_in) = "setdatacallback" then if not type(rhs(_x_in), 'nonegint') then error "data callback must be a nonnegative integer (address)" end if; _dtbl[1][28] := rhs(_x_in) elif type(_x_in, `=`) and lhs(_x_in) = "Array" then _i := rhs(_x_in); if not type(_i, 'list') or nops(_i) <> 2 or not type(_i[1], 'numeric') or not type(_i[2], 'posint') or _i[2] < 2 then error "Array output must be specified as [end time, min number of points]" end if; _src := array(1 .. 1, [`dsolve/numeric/SC/IVPdcopy`(_dtbl[1])]); if 0 < 0 then if `dsolve/numeric/checkglobals`(op(_src[1][14]), _pars, _neq, _y0) then `dsolve/numeric/SC/reinitialize`(_src, _y0, _neq, procname, _pars, 1) end if end if; if _src[1][4][7] = 0 then error "parameters must be initialized before solution can be computed" end if; _val := `dsolve/numeric/SC/IVPvalues`(_src[1], _x0 .. _i[1], _i[2], _i[2], []); if _val[3] <> "" then `dsolve/numeric/warning`(cat(`requested integration incomplete, received error:`, convert(_val[3], 'symbol'))) end if; _t1 := Array(1 .. _val[2], 0 .. _neq-_nevar+nops(_pars)); _t1[() .. (), 0] := _val[1][1 .. _val[2], 0]; for _i to _neq-_nevar do _t1[() .. (), _i] := _val[1][1 .. _val[2], _vmap[_i]] end do; for _i to nops(_pars) do _t1[() .. (), _neq-_nevar+_i] := _val[1][1 .. _val[2], _neq+_i] end do; return _t1 else return "procname" end if end if; if _x_out = _x0 then return [_x0, seq(evalf(_dtbl[1][6][_vmap[_i]]), _i = 1 .. _neq-_nevar)] end if; _i := `if`(_x0 <= _x_out, 3, 2); if _x_in = "last" and 0 < _dtbl[_i][4][9] and _dtbl[_i][4][9] < 100 then _dat := eval(_dtbl[_i], 2); _j := _dat[4][20]; return [_dat[11][_j, 0], seq(_dat[11][_j, _vmap[_i]], _i = 1 .. _neq-_nevar-_ndisc), seq(_dat[8][1][_vmap[_i]], _i = _neq-_nevar-_ndisc+1 .. _neq-_nevar)] end if; if not type(_dtbl[_i], 'array') then _dtbl[_i] := `dsolve/numeric/SC/IVPdcopy`(_dtbl[1], `if`(assigned(_dtbl[_i]), _dtbl[_i], NULL)); if 0 < _nevt then for _j to _nevt+1 do if _j <= _nevt and not type(_dtbl[_i][3][4][_j, _i-1], 'undefined') then userinfo(3, {'events', 'eventreset'}, `reinit #5, event code `, _j, ` to defined init `, _dtbl[_i][3][4][_j, _i-1]); _dtbl[_i][3][1][_j, 8] := _dtbl[_i][3][4][_j, _i-1] elif _dtbl[_i][3][1][_j, 2] = 0 and irem(iquo(round(_dtbl[_i][3][1][_j, 4]), 32), 2) = 1 then userinfo(3, {'events', 'eventreset'}, `reinit #5, event code `, _j, ` to rate hysteresis init `, _dtbl[_i][5][24]); _dtbl[_i][3][1][_j, 8] := _dtbl[_i][5][24] elif _dtbl[_i][3][1][_j, 2] = 0 and irem(iquo(round(_dtbl[_i][3][1][_j, 4]), 2), 2) = 0 then userinfo(3, {'events', 'eventreset'}, `reinit #5, event code `, _j, ` to initial init `, _x0); _dtbl[_i][3][1][_j, 8] := _x0 else userinfo(3, {'events', 'eventreset'}, `reinit #5, event code `, _j, ` to fireinitial init `, _x0-2*_i+5.0); _dtbl[_i][3][1][_j, 8] := _x0-2*_i+5.0 end if end do end if end if; if _x_in <> "last" then if 0 < 0 then if `dsolve/numeric/checkglobals`(op(_dtbl[1][14]), _pars, _neq, _y0) then `dsolve/numeric/SC/reinitialize`(_dtbl, _y0, _neq, procname, _pars, _i) end if end if; if _dtbl[1][4][7] = 0 then error "parameters must be initialized before solution can be computed" end if end if; _dat := eval(_dtbl[_i], 2); _dtbl[4] := _i; try _src := `dsolve/numeric/SC/IVPrun`(_dat, _x_out) catch: userinfo(2, `dsolve/debug`, print(`Exception in solnproc:`, [lastexception][2 .. -1])); error  end try; if _dat[17] <> _dtbl[1][17] then _dtbl[1][17] := _dat[17]; _dtbl[1][10] := _dat[10] end if; if _src = 0 and 100 < _dat[4][9] then _val := _dat[3][1][_nevt+1, 8] else _val := _dat[11][_dat[4][20], 0] end if; if _src <> 0 or _dat[4][9] <= 0 then _dtbl[1][5][1] := _x_out else _dtbl[1][5][1] := _val end if; if _i = 3 and _val < _x_out then Rounding := -infinity; if _dat[4][9] = 1 then error "cannot evaluate the solution further right of %1, probably a singularity", evalf[8](_val) elif _dat[4][9] = 2 then error "cannot evaluate the solution further right of %1, maxfun limit exceeded (see ?dsolve,maxfun for details)", evalf[8](_val) elif _dat[4][9] = 3 then if _dat[4][25] = 3 then error "cannot evaluate the solution past the initial point, problem may be initially singular or improperly set up" else error "cannot evaluate the solution past the initial point, problem may be complex, initially singular or improperly set up" end if elif _dat[4][9] = 4 then error "cannot evaluate the solution further right of %1, accuracy goal cannot be achieved with specified 'minstep'", evalf[8](_val) elif _dat[4][9] = 5 then error "cannot evaluate the solution further right of %1, too many step failures, tolerances may be too loose for problem", evalf[8](_val) elif _dat[4][9] = 6 then error "cannot evaluate the solution further right of %1, cannot downgrade delay storage for problems with delay derivative order > 1, try increasing delaypts", evalf[8](_val) elif _dat[4][9] = 10 then error "cannot evaluate the solution further right of %1, interrupt requested", evalf[8](_val) elif 100 < _dat[4][9] then if _dat[4][9]-100 = _nevt+1 then error "constraint projection failure on event at t=%1", evalf[8](_val) elif _dat[4][9]-100 = _nevt+2 then error "index-1 and derivative evaluation failure on event at t=%1", evalf[8](_val) elif _dat[4][9]-100 = _nevt+3 then error "maximum number of event iterations reached (%1) at t=%2", round(_dat[3][1][_nevt+1, 3]), evalf[8](_val) else if _Env_dsolve_nowarnstop <> true then `dsolve/numeric/warning`(StringTools:-FormatMessage("cannot evaluate the solution further right of %1, event #%2 triggered a halt", evalf[8](_val), round(_dat[3][1][_dat[4][9]-100, 1]))) end if; Rounding := 'nearest'; _x_out := _val end if else error "cannot evaluate the solution further right of %1", evalf[8](_val) end if elif _i = 2 and _x_out < _val then Rounding := infinity; if _dat[4][9] = 1 then error "cannot evaluate the solution further left of %1, probably a singularity", evalf[8](_val) elif _dat[4][9] = 2 then error "cannot evaluate the solution further left of %1, maxfun limit exceeded (see ?dsolve,maxfun for details)", evalf[8](_val) elif _dat[4][9] = 3 then if _dat[4][25] = 3 then error "cannot evaluate the solution past the initial point, problem may be initially singular or improperly set up" else error "cannot evaluate the solution past the initial point, problem may be complex, initially singular or improperly set up" end if elif _dat[4][9] = 4 then error "cannot evaluate the solution further left of %1, accuracy goal cannot be achieved with specified 'minstep'", evalf[8](_val) elif _dat[4][9] = 5 then error "cannot evaluate the solution further left of %1, too many step failures, tolerances may be too loose for problem", evalf[8](_val) elif _dat[4][9] = 6 then error "cannot evaluate the solution further left of %1, cannot downgrade delay storage for problems with delay derivative order > 1, try increasing delaypts", evalf[8](_val) elif _dat[4][9] = 10 then error "cannot evaluate the solution further right of %1, interrupt requested", evalf[8](_val) elif 100 < _dat[4][9] then if _dat[4][9]-100 = _nevt+1 then error "constraint projection failure on event at t=%1", evalf[8](_val) elif _dat[4][9]-100 = _nevt+2 then error "index-1 and derivative evaluation failure on event at t=%1", evalf[8](_val) elif _dat[4][9]-100 = _nevt+3 then error "maximum number of event iterations reached (%1) at t=%2", round(_dat[3][1][_nevt+1, 3]), evalf[8](_val) else if _Env_dsolve_nowarnstop <> true then `dsolve/numeric/warning`(StringTools:-FormatMessage("cannot evaluate the solution further left of %1, event #%2 triggered a halt", evalf[8](_val), round(_dat[3][1][_dat[4][9]-100, 1]))) end if; Rounding := 'nearest'; _x_out := _val end if else error "cannot evaluate the solution further left of %1", evalf[8](_val) end if end if; if _EnvInFsolve = true then _digits := _dat[4][26]; if type(_EnvDSNumericSaveDigits, 'posint') then _dat[4][26] := _EnvDSNumericSaveDigits else _dat[4][26] := Digits end if; _Env_dsolve_SC_native := true; if _dat[4][25] = 1 then _i := 1; _dat[4][25] := 2 else _i := _dat[4][25] end if; _val := `dsolve/numeric/SC/IVPval`(_dat, _x_out, _src); _dat[4][25] := _i; _dat[4][26] := _digits; [_x_out, seq(_val[_vmap[_i]], _i = 1 .. _neq-_nevar)] else Digits := _dat[4][26]; _val := `dsolve/numeric/SC/IVPval`(eval(_dat, 2), _x_out, _src); [_x_out, seq(_val[_vmap[_i]], _i = 1 .. _neq-_nevar)] end if end proc, (2) = Array(0..0, {}), (3) = [t, x(t), diff(x(t), t)], (4) = []}); _vars := _dat[3]; _pars := map(lhs, _dat[4]); _n := nops(_vars)-1; _solnproc := _dat[1]; if not type(_xout, 'numeric') then if member(x_rkf45, ["start", 'start', "method", 'method', "left", 'left', "right", 'right', "leftdata", "rightdata", "enginedata", "eventstop", 'eventstop', "eventclear", 'eventclear', "eventstatus", 'eventstatus', "eventcount", 'eventcount', "laxtol", 'laxtol', "numfun", 'numfun', NULL]) then _res := _solnproc(convert(x_rkf45, 'string')); if 1 < nops([_res]) then return _res elif type(_res, 'array') then return eval(_res, 1) elif _res <> "procname" then return _res end if elif member(x_rkf45, ["last", 'last', "initial", 'initial', "parameters", 'parameters', "initial_and_parameters", 'initial_and_parameters', NULL]) then _xout := convert(x_rkf45, 'string'); _res := _solnproc(_xout); if _xout = "parameters" then return [seq(_pars[_i] = _res[_i], _i = 1 .. nops(_pars))] elif _xout = "initial_and_parameters" then return [seq(_vars[_i+1] = [_res][1][_i+1], _i = 0 .. _n), seq(_pars[_i] = [_res][2][_i], _i = 1 .. nops(_pars))] else return [seq(_vars[_i+1] = _res[_i+1], _i = 0 .. _n)] end if elif type(_xout, `=`) and member(lhs(_xout), ["initial", 'initial', "parameters", 'parameters', "initial_and_parameters", 'initial_and_parameters', NULL]) then _xout := convert(lhs(x_rkf45), 'string') = rhs(x_rkf45); if type(rhs(_xout), 'list') then _res := _solnproc(_xout) else error "initial and/or parameter values must be specified in a list" end if; if lhs(_xout) = "initial" then return [seq(_vars[_i+1] = _res[_i+1], _i = 0 .. _n)] elif lhs(_xout) = "parameters" then return [seq(_pars[_i] = _res[_i], _i = 1 .. nops(_pars))] else return [seq(_vars[_i+1] = [_res][1][_i+1], _i = 0 .. _n), seq(_pars[_i] = [_res][2][_i], _i = 1 .. nops(_pars))] end if elif type(_xout, `=`) and member(lhs(_xout), ["eventdisable", 'eventdisable', "eventenable", 'eventenable', "eventfired", 'eventfired', "direction", 'direction', "Array", 'Array', NULL]) then return _solnproc(convert(lhs(x_rkf45), 'string') = rhs(x_rkf45)) elif _xout = "solnprocedure" then return eval(_solnproc) elif _xout = "sysvars" then return _vars elif _xout = "Array" then return [op(_vars), op(_pars)] end if; if procname <> unknown then return ('procname')(x_rkf45) else _ndsol := 1; _ndsol := _ndsol; _ndsol := pointto(_dat[2][0]); return ('_ndsol')(x_rkf45) end if end if; try _res := _solnproc(_xout); [seq(_vars[_i+1] = _res[_i+1], _i = 0 .. _n)] catch: error  end try end proc

 

proc (t) options operator, arrow; A_opt+B_opt*sin(t) end proc

 

 

 

 

proc (B) options operator, arrow; evalf((1/2)*B^2*Pi+B*v*Pi-2*Pi*u2*BesselJ(0, B)) end proc

 

 

 

 

Generating educational plots...

 

 

 


========================================
EDUCATIONAL SUMMARY
========================================
1. Why are higher harmonics zero?
   The trial function x(t)=A+B sin(t) already gives a very low action.
   Adding cos(t), cos(2t), etc., would increase the action because the
   system is not strongly nonlinear (u is small) and forcing is at frequency 1.

2. What is the physical meaning of A = π?
   The cosine term u^2 cos(x) has a minimum at x = π (since cos(π) = -1).
   The system prefers to stay near the bottom of the cosine well, centered at π.

3. Why does the action become negative?
   J is not an energy; it can be negative because the Lagrangian includes
   the term x v sin(t) which can lower the value. The negative value indicates
   that the forcing does work on the system.

4. What do the plots show?
   - The comparison plot shows that the simple approximation π + b1 sin(t)
     matches the numerical solution very well over one period.
   - The J(B) plot confirms that the found B_opt indeed gives the minimum
     of the action functional.
========================================

 

 

 

 

 

restart;
with(plots):

# ----------------------------------------------------------------------
# PATHOLOGICAL EXAMPLE: STRICTLY CONVEX QUADRATIC FUNCTIONAL
# ----------------------------------------------------------------------
# Functional:  J[x] = ∫_0^{2π} [ 1/2 (dx/dt)^2 + 1/2 x^2 - x·f(t) ] dt
# Euler-Lagrange:  x'' - x = -f(t)
# Boundary conditions: x(0)=0, x(2π)=0
# Forcing (nontrivial, with three frequencies):
f := t -> sin(t) + 0.3*sin(2*t) + 0.1*sin(3*t);

# ----------------------------------------------------------------------
# 1. EXACT SOLUTION OF THE EULER-LAGRANGE ODE
# ----------------------------------------------------------------------
ode := diff(x(t), t, t) - x(t) = -f(t);
bc  := x(0)=0, x(2*Pi)=0;
sol_exact := dsolve({ode, bc}, x(t)):
x_exact := unapply(rhs(sol_exact), t):

# ----------------------------------------------------------------------
# 2. RITZ METHOD (DIRECT MINIMIZATION) USING A SINE BASIS
#    Because the functional is quadratic, the minimum satisfies a linear
#    system:  A c = b, where
#      A_{nm} = ∫ (φ_n' φ_m' + φ_n φ_m) dt,   φ_n = sin(n t)
#      b_n   = ∫ φ_n f dt
# ----------------------------------------------------------------------
N := 5;   # number of basis functions
# Define basis functions
phi := n -> t -> sin(n*t);

# Compute matrix A and vector b via numerical integration
A := Matrix(N, N, datatype=float[8]):
b := Vector(N, datatype=float[8]):
for n from 1 to N do
    for m from 1 to N do
        integrand_A := diff(phi(n)(t), t)*diff(phi(m)(t), t) + phi(n)(t)*phi(m)(t);
        A[n,m] := evalf(Int(integrand_A, t=0..2*Pi, method=_d01ajc));
    end do;
    integrand_b := phi(n)(t)*f(t);
    b[n] := evalf(Int(integrand_b, t=0..2*Pi, method=_d01ajc));
end do:

# Solve the linear system
c_opt := LinearAlgebra:-LinearSolve(A, b):
coeff_opt := [seq(c_opt[n], n=1..N)];

# Minimal value of J (optional)
J_min := 1/2 * (c_opt^%T . A . c_opt) - (b^%T . c_opt);

# Construct the Ritz approximation
x_ritz := unapply( add(coeff_opt[n]*sin(n*t), n=1..N), t );

# ----------------------------------------------------------------------
# 3. PLOT: COMPARE EXACT SOLUTION AND RITZ APPROXIMATION
# ----------------------------------------------------------------------
p_exact := plot(x_exact(t), t=0..2*Pi, color=blue, thickness=2, legend="Exact (Euler-Lagrange)");
p_ritz  := plot(x_ritz(t), t=0..2*Pi, color=red, linestyle=dash, thickness=2, legend="Ritz (direct min, N=5)");
display(p_exact, p_ritz,
        title="Equivalence: Euler-Lagrange ODE ↔ Direct minimization",
        labels=["t", "x(t)"],
        size=[800,400]);

# ----------------------------------------------------------------------
# 4. OUTPUT WITH EDUCATIONAL EXPLANATION
# ----------------------------------------------------------------------
printf("============================================================\n");
printf("PATHOLOGICAL EXAMPLE: CONVEX QUADRATIC FUNCTIONAL\n");
printf("============================================================\n");
printf("Functional: J[x] = ∫ (½ x'² + ½ x² - x·f(t)) dt\n");
printf("f(t) = sin(t) + 0.3 sin(2t) + 0.1 sin(3t)\n");
printf("Boundary conditions: x(0)=0, x(2π)=0\n\n");

printf("RESULTS:\n");
printf("Exact solution (Euler-Lagrange) computed.\n");
printf("Ritz coefficients (N=%d):\n", N);
for n from 1 to N do
    printf("  c[%d] = %.8f\n", n, coeff_opt[n]);
end do;
printf("Minimal J = %.8f\n", J_min);
printf("\nThe plot shows that both approaches coincide.\n\n");

printf("============================================================\n");
printf("WHAT IS ‘PATHOLOGICAL’ ABOUT THIS EXAMPLE?\n");
printf("============================================================\n");
printf("1. The functional is STRICTLY CONVEX (quadratic, positive definite).\n");
printf("   According to convex analysis (Rockafellar, Hiriart-Urruty/Lemarechal),\n");
printf("   a convex functional has at most one minimum, and the necessary\n");
printf("   condition (Euler-Lagrange) is also sufficient. This example confirms\n");
printf("   that the ODE solution and the direct minimization coincide exactly.\n\n");
printf("2. The Euler-Lagrange equation is LINEAR (x'' - x = -f(t)).\n");
printf("   In most physical problems, the calculus of variations is nonlinear.\n");
printf("   The linearity makes this example ‘artificial’ and therefore ideal\n");
printf("   for teaching: the exact solution is available in closed form.\n\n");
printf("3. Even though the linear ODE with constant coefficients has exponentially\n");
printf("   growing/decaying solutions, the boundary conditions x(0)=x(2π)=0 and\n");
printf("   the choice of the period 2π force the solution to be PERIODIC.\n");
printf("   This is a surprising effect that becomes clearly visible only in a\n");
printf("   ‘pathological’ example.\n\n");
printf("4. The Ritz method uses only sines (which satisfy the BCs). The exact\n");
printf("   solution also contains cosines and exponential terms, but those are\n");
printf("   suppressed by the boundary conditions. Nevertheless, the Ritz\n");
printf("   approximation with N=5 converges almost exactly to the analytical\n");
printf("   solution. This illustrates the power of direct minimization, even\n");
printf("   with a ‘pathological’ choice of basis.\n\n");
printf("In short: the example is ‘pathological’ because it is UNNATURALLY SIMPLE\n");
printf("(linear, convex, exactly solvable), but precisely that simplicity allows\n");
printf("us to demonstrate clearly the theoretical equivalence between the\n");
printf("Euler-Lagrange equation and the minimization problem.\n");
printf("============================================================\n\n");

printf("LITERATURE REFERENCES (as requested):\n");
printf("  Rockafellar, R.T. (1970). Convex Analysis. Princeton Univ. Press.\n");
printf("  Hiriart-Urruty, J.-B. & Lemaréchal, C. (1993). Convex Analysis and\n");
printf("    Minimization Algorithms. Springer.\n");
printf("  Michlin, S.G. (1964). Variation Problems of Mathematical Physics.\n");
printf("    (English translation) Pergamon Press.\n");
printf("============================================================\n");

proc (t) options operator, arrow; sin(t)+.3*sin(2*t)+.1*sin(3*t) end proc

 

diff(diff(x(t), t), t)-x(t) = -sin(t)-.3*sin(2*t)-.1*sin(3*t)

 

x(0) = 0, x(2*Pi) = 0

 

5

 

proc (n) options operator, arrow; proc (t) options operator, arrow; sin(n*t) end proc end proc

 

[HFloat(0.5000000000795676), HFloat(0.059999999993605835), HFloat(0.009999999999975468), HFloat(-2.0180475669809298e-14), HFloat(-1.645199834776748e-14)]

 

-.8152432940

 

proc (t) options operator, arrow; HFloat(0.5000000000795676)*sin(t)+HFloat(0.059999999993605835)*sin(2*t)+HFloat(0.009999999999975468)*sin(3*t)-HFloat(2.0180475669809298e-14)*sin(4*t)-HFloat(1.645199834776748e-14)*sin(5*t) end proc

 

 

 

 

============================================================
PATHOLOGICAL EXAMPLE: CONVEX QUADRATIC FUNCTIONAL
============================================================
Functional: J[x] = ∫ (½ x'² + ½ x² - x·f(t)) dt
f(t) = sin(t) + 0.3 sin(2t) + 0.1 sin(3t)
Boundary conditions: x(0)=0, x(2π)=0

RESULTS:
Exact solution (Euler-Lagrange) computed.
Ritz coefficients (N=5):
  c[1] = 0.50000000
  c[2] = 0.06000000
  c[3] = 0.01000000
  c[4] = -0.00000000
  c[5] = -0.00000000
Minimal J = -0.81524329

The plot shows that both approaches coincide.

============================================================
WHAT IS ‘PATHOLOGICAL’ ABOUT THIS EXAMPLE?
============================================================
1. The functional is STRICTLY CONVEX (quadratic, positive definite).
   According to convex analysis (Rockafellar, Hiriart-Urruty/Lemarechal),
   a convex functional has at most one minimum, and the necessary
   condition (Euler-Lagrange) is also sufficient. This example confirms
   that the ODE solution and the direct minimization coincide exactly.

2. The Euler-Lagrange equation is LINEAR (x'' - x = -f(t)).
   In most physical problems, the calculus of variations is nonlinear.
   The linearity makes this example ‘artificial’ and therefore ideal
   for teaching: the exact solution is available in closed form.

3. Even though the linear ODE with constant coefficients has exponentially
   growing/decaying solutions, the boundary conditions x(0)=x(2π)=0 and
   the choice of the period 2π force the solution to be PERIODIC.
   This is a surprising effect that becomes clearly visible only in a
   ‘pathological’ example.

4. The Ritz method uses only sines (which satisfy the BCs). The exact
   solution also contains cosines and exponential terms, but those are
   suppressed by the boundary conditions. Nevertheless, the Ritz
   approximation with N=5 converges almost exactly to the analytical
   solution. This illustrates the power of direct minimization, even
   with a ‘pathological’ choice of basis.

In short: the example is ‘pathological’ because it is UNNATURALLY SIMPLE
(linear, convex, exactly solvable), but precisely that simplicity allows
us to demonstrate clearly the theoretical equivalence between the
Euler-Lagrange equation and the minimization problem.
============================================================

LITERATURE REFERENCES (as requested):
  Rockafellar, R.T. (1970). Convex Analysis. Princeton Univ. Press.
  Hiriart-Urruty, J.-B. & Lemaréchal, C. (1993). Convex Analysis and
    Minimization Algorithms. Springer.
  Michlin, S.G. (1964). Variation Problems of Mathematical Physics.
    (English translation) Pergamon Press.
============================================================

 

 


 

restart;
with(plots):
with(Optimization):

# Parameters
u := 0.3:
v := -0.1:
N := 3:

# Trial function: Fourier series up to 3rd harmonic
x_trial := a0 + a1*cos(t) + b1*sin(t) + a2*cos(2*t) + b2*sin(2*t) + a3*cos(3*t) + b3*sin(3*t):

# Lagrangian
L_expr := 1/2*diff(x_trial, t)^2 + u^2*cos(x_trial) + x_trial*v*sin(t):

# Objective function: numerically integrate the Lagrangian over t = 0..2π
obj := proc(C::Vector)
    local integrand, val;
    integrand := eval(L_expr, [a0=C[1], a1=C[2], b1=C[3], a2=C[4], b2=C[5], a3=C[6], b3=C[7]]);
    val := evalf(Int(integrand, t=0..2*Pi, method=_d01ajc));
    return val;
end proc:

# Initial guess (slightly perturbed to avoid zero-gradient warning)
init := Vector([0.3, 0.1, 0.001, 0.001, -0.001, 0.001, -0.001], datatype=float[8]):

# Minimize the action using the SQP method
opt := NLPSolve(7, obj, initialpoint=init, method=sqp):
optimal_coeffs := opt[2];
J_min := opt[1];

printf("Optimal coefficients:\n");
printf("a0 = %.6f\n", optimal_coeffs[1]);
printf("a1 = %.6f, b1 = %.6f\n", optimal_coeffs[2], optimal_coeffs[3]);
printf("a2 = %.6f, b2 = %.6f\n", optimal_coeffs[4], optimal_coeffs[5]);
printf("a3 = %.6f, b3 = %.6f\n", optimal_coeffs[6], optimal_coeffs[7]);

# Ritz solution function
x_Ritz := t -> optimal_coeffs[1] + optimal_coeffs[2]*cos(t) + optimal_coeffs[3]*sin(t)
                + optimal_coeffs[4]*cos(2*t) + optimal_coeffs[5]*sin(2*t)
                + optimal_coeffs[6]*cos(3*t) + optimal_coeffs[7]*sin(3*t):

# Numerical reference solution from the Euler-Lagrange ODE
ode := diff(x(t), t$2) = -u^2*sin(x(t)) + v*sin(t):
ics := x(0)=0.3, D(x)(0)=0.1:
sol_numeric := dsolve({ode, ics}, numeric, range=0..2*Pi):

# Plot comparison
p1 := odeplot(sol_numeric, [t, x(t)], 0..2*Pi, color=blue, thickness=2, legend="numerical (dsolve)");
p2 := plot(x_Ritz(t), t=0..2*Pi, color=red, thickness=2, linestyle=dash, legend="Ritz (N=3)");
display(p1, p2, title="Comparison of solutions", labels=["t", "x(t)"]);

Download integral_en_minimum_berekend_mprimesDEF_9-4-2026.mw

 

 

 

This explanation does not cover all derivations; it simply gives an idea of how a rotation matrix is derived

 

 

 

# ============================================================================
# DIDACTIC WORKSHEET: DERIVATION OF THE ROTATION MATRIX ABOUT THE XAXIS
#
# This worksheet guides you through:
#   1. 2D rotation in the yzplane (point on a circle)
#   2. Extension to 3D: rotation of a vector about the xaxis
#   3. Rotation of a cube about the xaxis with a dynamic matrix display
#
# Run each section separately to see the theory and the animations.
# ============================================================================

restart;
with(plots):        # for plots and animations
with(plottools):    # for lines, polygons, spheres
with(LinearAlgebra):# for matrix multiplication

# ----------------------------------------------------------------------------
# PART 1: 2D ROTATION IN THE YZPLANE
# ----------------------------------------------------------------------------
print("============================================================================");
print("PART 1: 2D rotation in the yzplane");
print("We consider a point P = (y, z) in the yzplane.");
print("We want to rotate it counterclockwise by an angle θ.");
print("");

print("Step 1 – Polar coordinates:");
print("   y = r·cos(φ),   z = r·sin(φ)");
print("where r is the distance from the origin and φ is the angle with the positive yaxis.");
print("");

print("Step 2 – Rotation by θ adds θ to the angle:");
print("   y' = r·cos(φ+θ),   z' = r·sin(φ+θ)");
print("");

print("Step 3 – Use the addition formulas:");
print("   cos(φ+θ) = cosφ·cosθ - sinφ·sinθ");
print("   sin(φ+θ) = sinφ·cosθ + cosφ·sinθ");
print("");

print("Step 4 – Multiply by r and substitute y = r·cosφ, z = r·sinφ:");
print("   y' = y·cosθ - z·sinθ");
print("   z' = y·sinθ + z·cosθ");
print("");

print("Step 5 – Write as a matrix multiplication:");
print("   [ y' ]   [ cosθ  -sinθ ] [ y ]");
print("   [ z' ] = [ sinθ   cosθ ] [ z ]");
print("The 2×2 matrix is the 2D rotation matrix R_2D(θ).");
print("============================================================================");
print("");

print("Animation: A point starting at (1,0) rotates through a full circle.");
print("Below the plot you see the numerical matrix R_2D(θ).");
print("");

N := 32;  # number of frames
frames_2d := []:
for i from 0 to N do
    theta := i * (2*Pi/N);
    R2 := Matrix([[cos(theta), -sin(theta)], [sin(theta), cos(theta)]]);
    rotated := convert(R2 . Vector([1,0]), list);
    
    # Graphical elements
    p := pointplot([rotated], symbol=solidcircle, symbolsize=20, color="red");
    l := line([0,0], rotated, color="blue", linestyle=dot);
    circ := plot([cos(t), sin(t), t=0..2*Pi], color="gray", thickness=1);
    y_axis := plot([[-1.5,0],[1.5,0]], color="black", thickness=1);
    z_axis := plot([[0,-1.5],[0,1.5]], color="black", thickness=1);
    y_label := textplot([1.6,0.1, "y"], font=["Times",12]);
    z_label := textplot([0.1,1.6, "z"], font=["Times",12]);
    matrix_text := sprintf("R_2D = [%7.3f  %7.3f]\n        [%7.3f  %7.3f]",
                           cos(theta), -sin(theta), sin(theta), cos(theta));
    mat_plot := textplot([-1.2, -1.3, matrix_text], font=["Courier",10]);
    
    frames_2d := [op(frames_2d),
                  display(p, l, circ, y_axis, z_axis, y_label, z_label, mat_plot,
                          scaling=constrained, view=[-1.5..1.5,-1.5..1.5],
                          title=cat("θ = ", sprintf("%.2f", theta), " rad"))];
end do:
anim_2d := display(frames_2d, insequence=true):
print(anim_2d);
print("Click the play button. The point rotates and the matrix updates.");
print("");

# ----------------------------------------------------------------------------
# PART 2: EXTENSION TO 3D – ROTATION ABOUT THE XAXIS
# ----------------------------------------------------------------------------
print("============================================================================");
print("PART 2: From 2D to 3D – rotation about the xaxis");
print("In 3D we have coordinates (x, y, z).");
print("When rotating about the xaxis:");
print("  - The xcoordinate remains unchanged (the axis is the xaxis).");
print("  - The y and z coordinates rotate exactly as in the yzplane.");
print("Therefore:");
print("   x' = x");
print("   y' = y·cosθ - z·sinθ");
print("   z' = y·sinθ + z·cosθ");
print("");

print("Step 6 – Write as a 3×3 matrix:");
print("   [ x' ]   [ 1    0     0 ] [ x ]");
print("   [ y' ] = [ 0  cosθ -sinθ ] [ y ]");
print("   [ z' ]   [ 0  sinθ  cosθ ] [ z ]");
print("This is the rotation matrix R_x(θ).");
print("============================================================================");
print("");

print("Animation: A red vector initially at (0,1,0) rotates about the xaxis.");
print("The vector stays in the yzplane; its xcoordinate remains 0.");
print("");

Rx := theta -> Matrix([[1,0,0],[0,cos(theta),-sin(theta)],[0,sin(theta),cos(theta)]]):
frames_vec := []:
N := 32;
for i from 0 to N do
    theta := i * (2*Pi/N);
    v0 := Vector([0,1,0]);
    v_rot := Rx(theta) . v0;
    tip := convert(v_rot, list);
    # Draw vector as a line + a small sphere at the tip
    line_vec := line([0,0,0], tip, color="red", thickness=3);
    tip_sphere := sphere(tip, 0.08, color="red");
    # Coordinate axes as lines
    x_axis := line([-1.5,0,0], [3,0,0], color="black", thickness=1);
    y_axis := line([0,-1.5,0], [0,3,0], color="black", thickness=1);
    z_axis := line([0,0,-1.5], [0,0,3], color="black", thickness=1);
    axis_text := textplot3d([[3.2,0,0,"x"],[0,3.2,0,"y"],[0,0,3.2,"z"]], font=["Times",12]);
    frames_vec := [op(frames_vec),
                   display(line_vec, tip_sphere, x_axis, y_axis, z_axis, axis_text,
                           scaling=constrained, view=[-1.5..3,-1.5..3,-1.5..3],
                           orientation=[70,60], title=cat("θ = ", sprintf("%.2f", theta), " rad"))];
end do:
anim_vec := display(frames_vec, insequence=true):
print(anim_vec);
print("Click the play button. The red vector rotates in the yzplane.");
print("");

# ----------------------------------------------------------------------------
# PART 3: ROTATING A CUBE ABOUT THE XAXIS
# ----------------------------------------------------------------------------
print("============================================================================");
print("PART 3: Rotating a cube about the xaxis");
print("We apply the matrix R_x(θ) to every vertex of a cube.");
print("The cube has side length 2 and its centre at the origin.");
print("A dynamic caption below the plot shows the current numerical matrix.");
print("============================================================================");
print("");

# Cube definition
cube_vertices := [
    [-1,-1,-1], [ 1,-1,-1], [ 1, 1,-1], [-1, 1,-1],  # bottom face (z = -1)
    [-1,-1, 1], [ 1,-1, 1], [ 1, 1, 1], [-1, 1, 1]   # top face (z =  1)
];
edges := [
    [1,2],[2,3],[3,4],[4,1],  # bottom
    [5,6],[6,7],[7,8],[8,5],  # top
    [1,5],[2,6],[3,7],[4,8]   # vertical
];

draw_cube := proc(vertices)
    local edge, lines, faces;
    lines := seq( line(vertices[edge[1]], vertices[edge[2]], color="Black", thickness=2), edge in edges );
    faces := [
        polygon([vertices[1],vertices[2],vertices[3],vertices[4]], color="Red", transparency=0.5),
        polygon([vertices[5],vertices[6],vertices[7],vertices[8]], color="Green", transparency=0.5),
        polygon([vertices[1],vertices[2],vertices[6],vertices[5]], color="Blue", transparency=0.5),
        polygon([vertices[2],vertices[3],vertices[7],vertices[6]], color="Yellow", transparency=0.5),
        polygon([vertices[3],vertices[4],vertices[8],vertices[7]], color="Cyan", transparency=0.5),
        polygon([vertices[4],vertices[1],vertices[5],vertices[8]], color="Magenta", transparency=0.5)
    ];
    return display(lines, faces);
end:

frames_cube := []:
N := 32;
for i from 0 to N do
    theta := i * (2*Pi/N);
    rotated_vertices := map(v -> convert(Rx(theta) . Vector(v), list), cube_vertices);
    M := Rx(theta);
    matrix_caption := cat(
        "R_x(θ) = \n",
        sprintf("[%7.3f  %7.3f  %7.3f]", M[1,1], M[1,2], M[1,3]), "\n",
        sprintf("[%7.3f  %7.3f  %7.3f]", M[2,1], M[2,2], M[2,3]), "\n",
        sprintf("[%7.3f  %7.3f  %7.3f]", M[3,1], M[3,2], M[3,3])
    );
    frames_cube := [op(frames_cube),
                    display(draw_cube(rotated_vertices),
                            title = cat("θ = ", sprintf("%.2f", theta), " rad"),
                            orientation = [45,45,0],
                            lightmodel = light4,
                            scaling = constrained,
                            axes = normal,
                            labels = ["x","y","z"],
                            view = [-2.5..2.5, -2.5..2.5, -2.5..2.5],
                            caption = matrix_caption
                           )]:
end do:
anim_cube := display(frames_cube, insequence=true):
print(anim_cube);
print("Click the play button. The cube rotates about the xaxis.");
print("The caption shows the matrix R_x(θ) with current numerical values.");
print("============================================================================");
print("");

print("END OF WORKSHEET.");
print("You have now seen step by step how the rotation matrix about the xaxis is derived,");
print("from a 2D point rotation, through a 3D vector, to a full cube.");

"============================================================================"

 

"PART 1: 2D rotation in the yz‑plane"

 

"We consider a point P = (y, z) in the yz‑plane."

 

"We want to rotate it counter‑clockwise by an angle &theta;."

 

""

 

"Step 1 &ndash; Polar coordinates:"

 

"   y = r&middot;cos(&phi;),   z = r&middot;sin(&phi;)"

 

"where r is the distance from the origin and &phi; is the angle with the positive y‑axis."

 

""

 

"Step 2 &ndash; Rotation by &theta; adds &theta; to the angle:"

 

"   y' = r&middot;cos(&phi;+&theta;),   z' = r&middot;sin(&phi;+&theta;)"

 

""

 

"Step 3 &ndash; Use the addition formulas:"

 

"   cos(&phi;+&theta;) = cos&phi;&middot;cos&theta; - sin&phi;&middot;sin&theta;"

 

"   sin(&phi;+&theta;) = sin&phi;&middot;cos&theta; + cos&phi;&middot;sin&theta;"

 

""

 

"Step 4 &ndash; Multiply by r and substitute y = r&middot;cos&phi;, z = r&middot;sin&phi;:"

 

"   y' = y&middot;cos&theta; - z&middot;sin&theta;"

 

"   z' = y&middot;sin&theta; + z&middot;cos&theta;"

 

""

 

"Step 5 &ndash; Write as a matrix multiplication:"

 

"   [ y' ]   [ cos&theta;  -sin&theta; ] [ y ]"

 

"   [ z' ] = [ sin&theta;   cos&theta; ] [ z ]"

 

"The 2&times;2 matrix is the 2D rotation matrix R_2D(&theta;)."

 

"============================================================================"

 

""

 

"Animation: A point starting at (1,0) rotates through a full circle."

 

"Below the plot you see the numerical matrix R_2D(&theta;)."

 

""

 

32

 

 

"Click the play button. The point rotates and the matrix updates."

 

""

 

"============================================================================"

 

"PART 2: From 2D to 3D &ndash; rotation about the x‑axis"

 

"In 3D we have coordinates (x, y, z)."

 

"When rotating about the x‑axis:"

 

"  - The x‑coordinate remains unchanged (the axis is the x‑axis)."

 

"  - The y and z coordinates rotate exactly as in the yz‑plane."

 

"Therefore:"

 

"   x' = x"

 

"   y' = y&middot;cos&theta; - z&middot;sin&theta;"

 

"   z' = y&middot;sin&theta; + z&middot;cos&theta;"

 

""

 

"Step 6 &ndash; Write as a 3&times;3 matrix:"

 

"   [ x' ]   [ 1    0     0 ] [ x ]"

 

"   [ y' ] = [ 0  cos&theta; -sin&theta; ] [ y ]"

 

"   [ z' ]   [ 0  sin&theta;  cos&theta; ] [ z ]"

 

"This is the rotation matrix R_x(&theta;)."

 

"============================================================================"

 

""

 

"Animation: A red vector initially at (0,1,0) rotates about the x‑axis."

 

"The vector stays in the yz‑plane; its x‑coordinate remains 0."

 

""

 

32

 

 

"Click the play button. The red vector rotates in the yz‑plane."

 

""

 

"============================================================================"

 

"PART 3: Rotating a cube about the x‑axis"

 

"We apply the matrix R_x(&theta;) to every vertex of a cube."

 

"The cube has side length 2 and its centre at the origin."

 

"A dynamic caption below the plot shows the current numerical matrix."

 

"============================================================================"

 

""

 

[[-1, -1, -1], [1, -1, -1], [1, 1, -1], [-1, 1, -1], [-1, -1, 1], [1, -1, 1], [1, 1, 1], [-1, 1, 1]]

 

[[1, 2], [2, 3], [3, 4], [4, 1], [5, 6], [6, 7], [7, 8], [8, 5], [1, 5], [2, 6], [3, 7], [4, 8]]

 

32

 

 

"Click the play button. The cube rotates about the x‑axis."

 

"The caption shows the matrix R_x(&theta;) with current numerical values."

 

"============================================================================"

 

""

 

"END OF WORKSHEET."

 

"You have now seen step by step how the rotation matrix about the x‑axis is derived,"

 

"from a 2D point rotation, through a 3D vector, to a full cube."

(1.1)
 

 

Download rotatienmatrices_mprimes31-3-2026.mw

@Mapleliquid 
Hello , yes Heineken a fouvorite beer of  mine :-)

There is a complete guide  in Maple, so thi s make sense :
 

A Complete Guide for performing Tensors computations using Physics via maple help

A Complete Guide for Tensor computations using Physics - MaplePrimes

Tensors in Maple – definition and index actions (PDF)

with(Physics):
Setup();

@salim-barzani 

restart;
with(plots):

# Definieer de functie voor de 3D plot met parameters en componentkeuze
energie_3d_keuze := proc(comp, m, p, q, r, theta, w, v, t, alpha1, alpha2, alpha3, alpha4)
    local Delta, xi, Knum, Pnum, Hnum, plot_expressie, plot_kleur, plot_titel;
    # Bereken Delta
    Delta := sqrt(4*alpha1*w^2 + (4*theta*alpha3 - 4)*w + 3*alpha4*m^2 + 4*theta^2*alpha2 - 4*r) / 
             (2*sqrt(p^2*alpha1 + p*q*alpha3 + q^2*alpha2));
    # Definieer xi
    xi := p*x + q*y - t*v;
    # Bereken energie componenten
    Knum := - (m^2/(16*p^2*alpha1 + 16*p*q*alpha3 + 16*q^2*alpha2)) * 
            (3*m^2*alpha4 + 4*theta^2*alpha2 + 4*theta*w*alpha3 + 4*w^2*alpha1 - 4*r - 4*w) * 
            (-1 + cos(2*Delta*xi));
     Pnum := (1/(4*p^2*alpha1 + 4*p*q*alpha3 + 4*q^2*alpha2)) * cos(Delta*xi)^2 * 
            (alpha4*m^2*cos(Delta*xi)^2 + 2*alpha1*w^2 + (2*theta*alpha3 - 2)*w + 2*theta^2*alpha2 - 2*r) * m^2;
     Hnum := (m^2/(8*p^2*alpha1 + 8*p*q*alpha3 + 8*q^2*alpha2)) * 
            (2*alpha4*m^2*cos(Delta*xi)^4 - 3*alpha4*m^2*cos(Delta*xi)^2 + 
             3*alpha4*m^2 + 4*theta*w*alpha3 + 4*alpha1*w^2 + 4*theta^2*alpha2 - 4*r - 4*w);
    
    # Kies welke component geplot wordt
    if comp = 1 then
        plot_expressie := Knum;
        plot_kleur := red;
        plot_titel := "Kinetische Energie (Knum)";
    elif comp = 2 then
        plot_expressie := Pnum;
        plot_kleur := blue;
        plot_titel := "Potentiële Energie (Pnum)";
    else
        plot_expressie := Hnum;
        plot_kleur := green;
        plot_titel := "Totale Energie (Hnum)";
    end if;
    
    # Maak de 3D plot
    plot3d(plot_expressie, x = -5..5, y = -5..5, 
           view = [-5..5, -5..5, 0..0.35], color = plot_kleur,
           title = sprintf("%s (m=%.2f, p=%.2f, q=%.2f, t=%.2f)", plot_titel, m, p, q, t),
           labels = ["x", "y", "energie"],
           style = patchcontour, axes = boxed);
end proc:

# Maak de Explore versie met componentkeuze (zonder controller optie)
Explore(energie_3d_keuze(comp, m, p, q, r, theta, w, v, t, alpha1, alpha2, alpha3, alpha4),      
        parameters = [
            comp = [1, 2, 3],
            m = 0.1..5.0, p = 0.1..5.0, q = 0.1..5.0,
            r = 0.1..5.0, theta = 0.1..5.0, w = 0.1..5.0,
            v = 0.1..5.0, t = 0.1..5.0,
            alpha1 = 0.1..5.0, alpha2 = 0.1..5.0,
            alpha3 = 0.1..5.0, alpha4 = 0.1..5.0
        ],      
        initialvalues = [
            comp = 1, m = 1, p = 1, q = 1, r = 1, theta = 1, w = 1, v = 1, t = 1,
            alpha1 = 1, alpha2 = 1, alpha3 = 1, alpha4 = 1
        ],    
        placement = right);

Maybe this gui ?

Beta cannot be 0 , as a quick test, not symbolic , but numerically 

# Choose random numerical values for the parameters
#params := {beta = 0.5, eta1 = 1.2, eta2 = 0.8, gamma1 = 0.3, gamma2 = -0.4, N = 2};

# Evaluate both expressions with these values
eval(G0, params);
eval(G01, params);

# Check if they are (approximately) equal
evalb(eval(G0 - G01, params) = 0);
# Or use a tolerance
is(abs(eval(G0 - G01, params)) < 1e-10);




 

t := 5*Pi/9:
L := [-tan(4*Pi/9) + 4*sin(4*Pi/9)];
evalf~(L,20)[];

identify(-1.7320508075688772935);

A more practical approach ,well done..Maple, for recognizing a root form from the decimal form.

oneliner..( a long line ) 

toPrefix := e -> `if`(type(e,atomic), e,[op(0,e), seq(toPrefix(op(i,e)), i=1..nops(e))]):

ex := (a+b*c)^2:
toPrefix(ex);


exUltra :=
subs(a=b+c,
    expand(
        int(
            diff((x+y)^5*sin(exp(x^2+y^2)),x)
            /(1+sum(k*z^k,k=1..4)),
            x=0..1
        )
    )
):

toPrefix(exUltra );

exInsane :=
((f@g)@@3)(a+b*c)
+
(exp@@2)(sin@@3(x+y))
+
((a&*b)&+c)^5;

 exInsane := f(g(f(g(f(g(b c + a)))))) + @@(exp, 2)(@@(sin, 3))

                   5
    + (a &* b) &+ c 

toPrefix(exInsane );

A name is  a variable when there is a valued assigned to it. 


Used seq command here instead  a loop construction
Note: how fast the trees are growing :-) 

NULL

 

 

restart;
with(Fractals[LSystem]):
with(plots):

# Define the L-system generator
LGenerator := proc(n, Init, Angle0, Param, Rules, Color)
    local Iteration;
    
    # Use try-catch to avoid errors
    try
        if n = 0 then
            Iteration := Init;
        else
            Iteration := Iterate(Init, Rules, n);
        end if;
    catch:
        # If there's an error, use the initial string
        Iteration := Init;
    end try;
    
    # Draw the L-system
    LSystemPlot(
        Iteration,
        Param,
        initialangle = Angle0,
        color = Color,
        scaling = constrained,
        axes = none,
        thickness = 2
    );
end proc:

# First L-system (number 17)
Init17 := "X":
Angle17 := 90:

Param17 := [
  "F" = "draw:1",
  "+" = "turn:-25.7",
  "-" = "turn:25.7",
  "[" = "push:position;push:angle",
  "]" = "pop:position;pop:angle"
]:

Rules17 := [
  "F" = "FF",
  "X" = "F[+X][-X]FX"
]:

# Second L-system (number 18)
Init18 := "X":
Angle18 := 90:

Param18 := [
  "F" = "draw:1",
  "+" = "turn:20",
  "-" = "turn:-20",
  "[" = "push:position;push:angle",
  "]" = "pop:position;pop:angle"
]:

Rules18 := [
  "F" = "FF",
  "X" = "F[+X]F[-X]+X"
]:

# Test both L-systems without animation
print("L-system 17, iteration 4:");
display(LGenerator(4, Init17, Angle17, Param17, Rules17, "Red"));

print("L-system 18, iteration 4:");
display(LGenerator(4, Init18, Angle18, Param18, Rules18, "DarkGreen"));

# Create smoother animations with more frames
print("Smooth animation of L-system 17 (iterations 0-7):");
display([seq(LGenerator(i, Init17, Angle17, Param17, Rules17, "Red"), i = 0 .. 7)],
        insequence = true,
        frames = 64);  # More frames for smoother animation

print("Smooth animation of L-system 18 (iterations 0-7):");
display([seq(LGenerator(i, Init18, Angle18, Param18, Rules18, "DarkGreen"), i = 0 .. 7)],
        insequence = true,
        frames = 64);  # More frames for smoother animation

# Optional: Show all iterations side by side in a grid
print("All iterations of L-system 17 (0-7):");
display(Matrix(2, 4, [seq(LGenerator(i, Init17, Angle17, Param17, Rules17, "Red"), i = 0 .. 7)]));

print("All iterations of L-system 18 (0-7):");
display(Matrix(2, 4, [seq(LGenerator(i, Init18, Angle18, Param18, Rules18, "DarkGreen"), i = 0 .. 7)]));

# Even smoother version with interpolation (more iterations shown)
print("Extra smooth animation of L-system 17 (more frames):");
display([seq(LGenerator(i, Init17, Angle17, Param17, Rules17, "Red"), i = 0 .. 7)],
        insequence = true,
        frames = 128);  # Even more frames for extra smoothness

print("Extra smooth animation of L-system 18 (more frames):");
display([seq(LGenerator(i, Init18, Angle18, Param18, Rules18, "DarkGreen"), i = 0 .. 7)],
        insequence = true,
        frames = 128);

"L-system 17, iteration 4:"

 

 

"L-system 18, iteration 4:"

 

 

"Smooth animation of L-system 17 (iterations 0-7):"

 

 

"Smooth animation of L-system 18 (iterations 0-7):"

 

 

"All iterations of L-system 17 (0-7):"

 

 

 

 

 

 

 

"All iterations of L-system 18 (0-7):"

 

 

 

 

 

 

 

"Extra smooth animation of L-system 17 (more frames):"

 

 

"Extra smooth animation of L-system 18 (more frames):"

 

 

NULL


 

Download fractal_animatie_mprimes_26-1-2026.mw

@jalal 
Some experiment, but needs more thought 
I do need more math background/information for this figure in order to get this as a plot in Maple 

restart;
with(plots):

# parameters
p := 54.62;           # exponent
N := 120;             # number  rotaties
tmin := -1;
tmax := 1;

curves := []:

for k from 0 to N do
    theta := 2*Pi*k/N;

    x := t*cos(theta) - t^p*sin(theta);
    y := t*sin(theta) + t^p*cos(theta);

    curves := [op(curves),
        plot([x, y, t = tmin .. tmax],
             color = ColorTools:-Color([sin(theta)^2,
                                         cos(theta)^2,
                                         abs(sin(2*theta))]))];
end do:

display(curves,
        scaling = constrained,
        axes = none,
        background = white);

 

 

 

 

restart

with(PDEtools)

undeclare(prime, quiet)

declare(u(x, t), quiet); declare(U(xi), quiet); declare(V(xi), quiet); declare(Omega(x, t), quiet); declare(Q(x, t), quiet); declare(R(x, t), quiet)



# --- Symbols ---
declare(R(xi), phi(xi)):
#assume(alpha::real, beta::real, v::real):  ?????????????????

# --- Imaginary part Eq. (2.4) ---
ImEq :=
alpha*R(xi)*diff(phi(xi),xi$2)
+ 2*alpha*diff(R(xi),xi)*diff(phi(xi),xi)
- v*diff(R(xi),xi)
+ beta*(2*n+1)*R(xi)^(2*n)*diff(R(xi),xi):

# --- Chirp ansatz (Eq. 2.5) ---
phip  := eta_1*R(xi)^(2*n) + eta_2:
phipp := diff(phip, xi):

# --- Substitute ansatz ---
ImEq2 := subs(
  diff(phi(xi),xi)=phip,
  diff(phi(xi),xi$2)=phipp,
  ImEq
):

# --- Divide out R' ---
ImEq3 := factor(ImEq2/diff(R(xi),xi)):

# --- Helper symbol ---
Z := 'Z':
ImEq4 := subs(R(xi)^(2*n)=Z, ImEq3):

# --- Collect ---
C := collect(ImEq4, Z):

# --- Coefficients ---
C_Z := coeff(C, Z, 1):
C_0 := coeff(C, Z, 0):

# --- Solve ---
eta[1] := solve(C_Z = 0, eta_1);
eta[2] := solve(C_0 = 0, eta_2);

#eta1_sol, eta2_sol;

 

R(xi)*`will now be displayed as`*R

 

phi(xi)*`will now be displayed as`*phi

 

-(1/2)*beta*(2*n+1)/(alpha*(n+1))

 

(1/2)*v/alpha

(1.1)
 

``

Download chirped_parameter_eta1_eneta_2_mprimes_11-1-2026.mw

1 2 3 4 5 6 7 Last Page 1 of 9