janhardo

435 Reputation

8 Badges

10 years, 232 days

MaplePrimes Activity


These are questions asked by janhardo

I'm a little busy with the Rule feature in Maple 
Just started with the limits and can't get 1 limit rule working in my FSimp procedure yet
As a limit example I saw this in Maple help 

with(Student:-Calculus1);
infolevel[Student[Calculus1]] := 1;

Rule[lhopital, ln(x)](Limit(x*ln(x), x = 0, right));
Creating problem #2

                  lim   (x ln(x)) =   lim   (-x)
                x -> 0+             x -> 0+     

A meaningless example of how one limit of a function is equal to another limit of a function, when I think there is no connection between the two functions. ( I don't see it ) 
You might as well calculate the limit value right away.

It gets more interesting when you analyze the function/expression : x*ln(x) and start rewriting it, to a [0/0] or [infinity/infinity] form in this case and from this it shows the need to start using lhopital rule.

The Rule feature has a Hint capability and gives as a hint, lhopital that this rule is applied 
Of course, you also have a series of standard limits, beyond the lhopital limits
The Rule feature for the limit is not yet step by step, because the need to start using a lhopital limit rule has not yet been demonstrated by the user

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

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