janhardo

715 Reputation

12 Badges

11 years, 101 days

MaplePrimes Activity


These are questions asked by janhardo

Can't figure out what code makes this simplification.
If this simplification works, it will be a part of a larger simplication procedure ( if it not conflicts hopefully) 
vereenvouding_hoe_-vraag_MPF.mw

Maybe someone get the code working ?
 

with(plots):
with(VectorCalculus):

# Example 1: Vector Field and Visualization
V := [x, y, z]:
print("Vector Field V:", V):
fieldplot3d([V[1], V[2], V[3]], x = -2..2, y = -2..2, z = -2..2, arrows = slim, title = "Vector Field in 3D"):

# Example 2: Tangent Vector to a Curve
curve := [cos(t), sin(t), t]:
print("Curve:", curve):
tangent := diff(curve, t):
print("Tangent Vector:", tangent):
plot3d([cos(t), sin(t), t], t = 0..2*Pi, labels = [x, y, z], title = "Curve in 3D"):

# Example 3: Curvature of a Surface
u := 'u': v := 'v':
surface := [u, v, u^2 - v^2]:
print("Surface:", surface):

# Compute the first fundamental form
ru := [diff(surface[1], u), diff(surface[2], u), diff(surface[3], u)]:
rv := [diff(surface[1], v), diff(surface[2], v), diff(surface[3], v)]:
E := ru[1]^2 + ru[2]^2 + ru[3]^2:
F := ru[1]*rv[1] + ru[2]*rv[2] + ru[3]*rv[3]:
G := rv[1]^2 + rv[2]^2 + rv[3]^2:
firstFundamentalForm := Matrix([[E, F], [F, G]]):
print("First Fundamental Form:", firstFundamentalForm):

# Compute the second fundamental form
ruu := [diff(surface[1], u, u), diff(surface[2], u, u), diff(surface[3], u, u)]:
ruv := [diff(surface[1], u, v), diff(surface[2], u, v), diff(surface[3], u, v)]:
rvv := [diff(surface[1], v, v), diff(surface[2], v, v), diff(surface[3], v, v)]:
normal := CrossProduct(ru, rv):
normal := eval(normal / sqrt(normal[1]^2 + normal[2]^2 + normal[3]^2)):
L := ruu[1]*normal[1] + ruu[2]*normal[2] + ruu[3]*normal[3]:
M := ruv[1]*normal[1] + ruv[2]*normal[2] + ruv[3]*normal[3]:
N := rvv[1]*normal[1] + rvv[2]*normal[2] + rvv[3]*normal[3]:
secondFundamentalForm := Matrix([[L, M], [M, N]]):
print("Second Fundamental Form:", secondFundamentalForm):

# Compute the Christoffel symbols
# Ensure DifferentialGeometry package is loaded
with(DifferentialGeometry):
DGsetup([u, v], N):
Gamma := Christoffel(firstFundamentalForm):
print("Christoffel Symbols:", Gamma):

# Visualize the surface
plot3d([u, v, u^2 - v^2], u = -2..2, v = -2..2, labels = [u, v, z], title = "Saddle Surface in 3D"):

 

This is still a  starting procedure and let's see what can be added?

restart;
# Define the procedure to draw a cylinder along the x-axis and a specifically positioned plane
CylinderAndPlane := proc(r, h, alpha_deg, beta_deg, P, axis_length)
    local alpha, beta, cylinder, plane, pointPlot, display, nx, ny, nz, px, py, pz, annotations, plane_type, titleStr, grafiek;  # Added: titleStr
    uses plots, LinearAlgebra;  
    # Convert angles from degrees to radians
    alpha := alpha_deg * Pi / 180;
    beta := beta_deg * Pi / 180;

    # Determine the normal vector based on angles
    nx := cos(alpha) * sin(beta);
    ny := sin(alpha) * sin(beta);
    nz := cos(beta);

    # Point P is directly used as given coordinates
    px, py, pz := op(P);

    # Cylinder along the x-axis
    cylinder := plots:-implicitplot3d(y^2 + z^2 = r^2, x = 0 .. h, y = -r .. r, z = -r .. r, style = surface, color = "LightBlue", transparency = 0.5);

    # Determine the type of plane based on angles alpha and beta
    if beta_deg = 90 then
        plane_type := "yz";
        plane := plots:-implicitplot3d(x = px, x = px - 10 .. px + 10, y = -axis_length .. axis_length, z = -axis_length .. axis_length, style = surface, color = "Yellow", transparency = 0.5);
    elif alpha_deg = 90 and beta_deg = 0 then
        plane_type := "xz";
        plane := plots:-implicitplot3d(y = py, x = -axis_length .. axis_length, y = py - 10 .. py + 10, z = -axis_length .. axis_length, style = surface, color = "Green", transparency = 0.5);
    elif beta_deg = 0 then
        plane_type := "xy";
        plane := plots:-implicitplot3d(z = pz, x = -axis_length .. axis_length, y = -axis_length .. axis_length, z = pz - 10 .. pz + 10, style = surface, color = "Blue", transparency = 0.5);
    else
        plane_type := "arbitrary";
        plane := plots:-implicitplot3d(nx * (x - px) + ny * (y - py) + nz * (z - pz) = 0, x = -axis_length .. axis_length, y = -axis_length .. axis_length, z = -axis_length .. axis_length, style = surface, color =            "Red", transparency = 0.7);
    end if;

    # Mark point P
    pointPlot := plots:-pointplot3d([px, py, pz], symbol = solidcircle, symbolsize = 10, color = "Red");

    # Create dynamic title - New
    titleStr := cat("Plane: ", plane_type, "\nAlpha: ", sprintf("%.2f", alpha_deg), " deg\nBeta: ", sprintf("%.2f", beta_deg), " deg\nPoint: [", sprintf("%.2f", P[1]), ", ", sprintf("%.2f", P[2]), ", ", sprintf("%.2f", P[3]), "]");

    # Display everything together - Modified: titleStr added in the display function
    grafiek := plots:-display(cylinder, plane, pointPlot, axes = normal, scaling = constrained, labels = ["x", "y", "z"], title = titleStr);

    return grafiek;
end proc:

# Example call to the procedure with coordinates of P and setting the axis length
# Alpha and Beta are now angles in degrees, P is a list of coordinates, axis_length is the length of the coordinate axes
CylinderAndPlane(15, 50, 0, 90, [15, 5, 5], 30);  # For yz-plane
#CylinderAndPlane(5, 15, 90, 0, [5, 5, 5], 10);  # For xz-plane
#CylinderAndPlane(5, 15, 0, 0, [5, 5, 5], 10);   # For xy-plane
#CylinderAndPlane(5, 55, 45, 45, [5, 5, 5], 10); # For arbitrary plane

 
 

 

Download maple_primes_-doorsnijdingsvlak_solids_procedureDEF.mw

Include print level in procedure
In the procedure code printlevel is not accepted
-enviroment variable
-interface variable 
error message : Error, (in interface) unknown interface variable, printlevel

More convenient in my opinion is to include on the printlevel depth in the procedure call?

restart;

fac := proc(n::integer)
    local previous_printlevel, result;
    previous_printlevel := interface('printlevel');  # Correct way to get the current printlevel
    interface('printlevel' = 3);  # Correct way to set the printlevel

    # De recursieve berekening
    if n = 0 then
        result := 1;  # Basisgeval
    else
        result := n * fac(n - 1);  # Recursieve aanroep
    end if;

    interface('printlevel' = previous_printlevel);  # Restore the original printlevel
    return result;
end proc;

fac(5);

proc (n::integer) local previous_printlevel, result; previous_printlevel := interface('printlevel'); interface('printlevel' = 3); if n = 0 then result := 1 else result := n*fac(n-1) end if; interface('printlevel' = previous_printlevel); return result end proc

 

Error, (in interface) unknown interface variable, printlevel

 
 

 

Download MP_vraag_printlevel_in_procedure_-lukt_niet.mw


Don't see here the FunctionAdvisor , what is included for every choosen function.

 

How to obtain a clear plot of Zeta function
- via a total plot ?
- via partial plots ?
- further take circle in complex domain : complex plane ( riemann surface) , to be continued..

 

ComplexSurface := proc(complex_function, x_range, y_range, view_opt, orient_opt, grid_opt)
    local f, plot, combined_plot;
    
    # Define the complex function f(z)
    f := unapply(complex_function, z);
    
    # Call the FunctionAdvisor to provide plot recommendations
    FunctionAdvisor(f(z), z = x + I*y, 'view' = view_opt, 'orientation' = orient_opt, 'grid' = grid_opt);
    
    # Plot the complex surface
    plot := plot3d([evalc(Re(f(x + I*y))), evalc(Im(f(x + I*y)))], x = x_range, y = y_range, view = view_opt, orientation = orient_opt, grid = grid_opt, style = surface, title = sprintf("Plot of %a", complex_function));
    
    # Print the combined plot
    combined_plot := plot;
    #printf("Plot of the complex surface:\n");
    print(combined_plot);
    
    # Display additional messages
    printf("Procedure input:\n");
    printf("ComplexSurface(complex_function, x_range, y_range, view_opt, orient_opt, grid_opt)\n");
    printf("complex_function: The complex function to be plotted\n");
    printf("x_range: Range of the real axis\n");
    printf("y_range: Range of the imaginary axis\n");
    printf("view_opt: List of the form [x_min..x_max, y_min..y_max, z_min..z_max], determines the visible region\n");
    printf("orient_opt: List of the form [angle_x, angle_y], determines the viewing angle\n");
    printf("grid_opt: List of the form [x_grid, y_grid], determines the grid resolution\n");
    printf("\n");
    printf("Example usage:\n");
    printf("ComplexSurface(Zeta(z), -50..5, -5..5, [-50..50, -5..5, 0..15], [120, 60], [50, 50]);\n");
    printf("\n");
    printf("Where Zeta(z) is the complex function to be plotted, and the ranges, view options, orientation options, and grid options are specified accordingly.\n");
end proc:
 

 

ComplexSurface(Zeta(z), -50..50, -5..5, [-50..50, -5..5, 0..15], [120, 60], [50, 50]);

 

Procedure input:
ComplexSurface(complex_function, x_range, y_range, view_opt, orient_opt, grid_opt)
complex_function: The complex function to be plotted
x_range: Range of the real axis
y_range: Range of the imaginary axis
view_opt: List of the form [x_min..x_max, y_min..y_max, z_min..z_max], determines the visible region
orient_opt: List of the form [angle_x, angle_y], determines the viewing angle
grid_opt: List of the form [x_grid, y_grid], determines the grid resolution

Example usage:
ComplexSurface(Zeta(z), -50..5, -5..5, [-50..50, -5..5, 0..15], [120, 60], [50, 50]);

Where Zeta(z) is the complex function to be plotted, and the ranges, view options, orientation options, and grid options are specified accordingly.

 

 

ComplexSurface(ln(z), -50..50, -5..5, [-50..50, -5..5, 0..15], [120, 60], [50, 50]);

 

Procedure input:
ComplexSurface(complex_function, x_range, y_range, view_opt, orient_opt, grid_opt)
complex_function: The complex function to be plotted
x_range: Range of the real axis
y_range: Range of the imaginary axis
view_opt: List of the form [x_min..x_max, y_min..y_max, z_min..z_max], determines the visible region
orient_opt: List of the form [angle_x, angle_y], determines the viewing angle
grid_opt: List of the form [x_grid, y_grid], determines the grid resolution

Example usage:
ComplexSurface(Zeta(z), -50..5, -5..5, [-50..50, -5..5, 0..15], [120, 60], [50, 50]);

Where Zeta(z) is the complex function to be plotted, and the ranges, view options, orientation options, and grid options are specified accordingly.

 

 


 

Download complex_oppervlak_zeta_functie_maple_primes.mw

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