janhardo

805 Reputation

12 Badges

11 years, 198 days

MaplePrimes Activity


These are replies submitted by janhardo

Not using this : it are periodic functions : t>=0,t<=2*Pi
They repeating themselves. 
 ,  ( )
generalized sin  function : JacobiSN(u, 0) = -1

sol := solve({cos(t) = 0, sin(t) = -1}, t, allsolutions);

works too for the generalized sin and cos function

sol := solve({
    JacobiCN(u, 0) = 0,
    JacobiSN(u, 0) = -1
}, u,allsolutions);

@C_R

Expr := 'int(1 / (sqrt(-alpha*l^2 + 1) * sqrt(-alpha*l^2 * (x + 1)/2 + 1)), alpha = 0 .. z)';
EvaluatedExpr := value(Expr);
'int(1 / (sqrt(-alpha*l^2 + 1) * sqrt(-alpha*l^2 * (x + 1)/2 + 1)), alpha = 0 .. z)' = EvaluatedExpr;

@C_R 



This form is also acceptable ?, or the denominator must still  be 1 ?,although it is the same integral.
Expression II_subs is  chanced by a function.

What expression for the integrand is better to handle ?

@nm 

simplify(int(sqrt(1 + sin(x)^2), x), symbolic);

and this ?
 

int(sqrt(1 + sin(x)^2), x, method=_RETURNVERBOSE);

A left Riemann sum for sin(x) 

"maple.ini in user"

(1)

NULL

 

 

restart:
with(Student:-Calculus1):

RiemannSum(
    sin(x),
    x = 0...2*Pi,
    partition = 50,
    method = left,
    output = plot, size=[1000,600]
);

"maple.ini in user"

 

 

Int(sin(x), x = 0..2*Pi) = int(sin(x), x = 0..2*Pi);

Int(sin(x), x = 0 .. 2*Pi) = 0

(1.1)

Limit(Sum(sin(2*Pi*i/n)*(2*Pi/n), i=1..n), n=infinity)= limit(sum(sin(2*Pi*i/n)*(2*Pi/n), i=1..n), n=infinity); # a limit of sums

Limit(Sum(2*sin(2*Pi*i/n)*Pi/n, i = 1 .. n), n = infinity) = 0

(1.2)

Int(sin(x), x = 0 .. 2*Pi) =  Limit(Sum(2*sin(2*Pi*i/n)*Pi/n, i = 1 .. n), n = infinity) ;

Int(sin(x), x = 0 .. 2*Pi) = Limit(Sum(2*sin(2*Pi*i/n)*Pi/n, i = 1 .. n), n = infinity)

(1.3)

verify(
  int(sin(x), x = 0 .. 2*Pi),
  limit(sum(2*sin(2*Pi*i/n)*Pi/n, i = 1 .. n), n = infinity),
  equal
);

true

(1.4)
 

NULL

Download linker_riemannsom_voor_sinus_plot_mprimes_23-12-2025.mw

dimensions in  A en B    are not possible ?

A := Vector(2, symbol=a):
B := Matrix(2$2, symbol=b):
R := A.B.A^+


 

NULL

 

 

NULL

restart;

RiemannPlot := proc({meth::string:="left", n::posint:=5, animate::boolean:=false})
    local f, a, b, dx, xvals, yvals, i, exact, approx, k,
          plot_func, rect_plots, point_plots, line_plots, rect_color,
          frames, frame_list, anim, left_x, right_x, rect_height;
    
    f := x -> x^2;
    a := 0;
    b := 1;
    exact := 1/3;  # ∫¹ x² dx = 1/3
    
    # If animation is requested, create a series of frames
    if animate then
        frames := [seq(i, i=2..20, 2)];  # n = 2, 4, 6, ..., 20
        frame_list := [];
        
        for k in frames do
            dx := (b - a)/k;
            
            # Generate x-values based on the method
            if meth = "left" then
                xvals := [seq(a + (i-1)*dx, i = 1..k)];
                rect_color := "LightBlue";
            elif meth = "right" then
                xvals := [seq(a + i*dx, i = 1..k)];
                rect_color := "LightGreen";
            elif meth = "midpoint" then
                xvals := [seq(a + (i-1/2)*dx, i = 1..k)];
                rect_color := "LightPink";
            else
                error "Invalid method. Choose 'left', 'right' or 'midpoint'";
            end if;
            
            yvals := map(f, xvals);
            approx := add(yvals[i]*dx, i = 1..k);
            
            # Create rectangles with smart borders
            rect_plots := NULL;
            for i from 1 to k do
                left_x := a + (i-1)*dx;
                right_x := a + i*dx;
                rect_height := yvals[i];
                
                # Colored rectangle
                rect_plots := rect_plots,
                    plottools:-rectangle([left_x, 0], [right_x, rect_height],
                                         color = rect_color, style = polygon,
                                         transparency = 0.3);
                
                # Draw rectangle borders intelligently
                if rect_height > 0 then
                    if meth = "left" then
                        # ALWAYS draw bottom
                        rect_plots := rect_plots,
                            plot([[left_x, 0], [right_x, 0]],
                                 color = "Black", thickness = 0.5);
                        
                        # ALWAYS draw top
                        rect_plots := rect_plots,
                            plot([[left_x, rect_height], [right_x, rect_height]],
                                 color = "Black", thickness = 0.5);
                        
                        # Draw LEFT side ONLY for FIRST rectangle
                        if i = 1 then
                            rect_plots := rect_plots,
                                plot([[left_x, 0], [left_x, rect_height]],
                                     color = "Black", thickness = 0.5);
                        end if;
                        
                        # Draw RIGHT side ONLY for LAST rectangle
                        if i = k then
                            rect_plots := rect_plots,
                                plot([[right_x, 0], [right_x, rect_height]],
                                     color = "Black", thickness = 0.5);
                        end if;
                        
                    elif meth = "right" then
                        # ALWAYS draw bottom
                        rect_plots := rect_plots,
                            plot([[left_x, 0], [right_x, 0]],
                                 color = "Black", thickness = 0.5);
                        
                        # ALWAYS draw top
                        rect_plots := rect_plots,
                            plot([[left_x, rect_height], [right_x, rect_height]],
                                 color = "Black", thickness = 0.5);
                        
                        # Draw LEFT side (always for right method)
                        rect_plots := rect_plots,
                            plot([[left_x, 0], [left_x, rect_height]],
                                 color = "Black", thickness = 0.5);
                        
                        # Draw RIGHT side ONLY for LAST rectangle
                        if i = k then
                            rect_plots := rect_plots,
                                plot([[right_x, 0], [right_x, rect_height]],
                                     color = "Black", thickness = 0.5);
                        end if;
                        
                    else  # midpoint
                        # Draw ALL sides (dashed line is in middle, no overlap)
                        rect_plots := rect_plots,
                            plot([[left_x, 0], [right_x, 0]],  # Bottom
                                 color = "Black", thickness = 0.5);
                        rect_plots := rect_plots,
                            plot([[left_x, 0], [left_x, rect_height]],  # Left
                                 color = "Black", thickness = 0.5);
                        rect_plots := rect_plots,
                            plot([[right_x, 0], [right_x, rect_height]],  # Right
                                 color = "Black", thickness = 0.5);
                        rect_plots := rect_plots,
                            plot([[left_x, rect_height], [right_x, rect_height]],  # Top
                                 color = "Black", thickness = 0.5);
                    end if;
                end if;
            end do;
            
            # Points and vertical dashed lines
            point_plots := NULL;
            line_plots := NULL;
            for i from 1 to k do
                if yvals[i] > 0 then
                    point_plots := point_plots,
                        plot([[xvals[i], yvals[i]]], style = point, symbol = solidcircle,
                             symbolsize = 10, color = "Red");
                    
                    # Vertical dashed line
                    line_plots := line_plots,
                        plot([[xvals[i], 0], [xvals[i], yvals[i]]],
                             color = "Red", linestyle = dash, thickness = 0.5);
                end if;
            end do;
            
            # Function curve
            plot_func := plot(f(x), x = a..b, color = "DarkBlue", thickness = 2);
            
            # Add frame to list
            frame_list := [op(frame_list),
                plots:-display([rect_plots, line_plots, plot_func, point_plots],
                              title = sprintf("Riemann Sum (%s) for f(x) = x²\nn = %d | Approximation: %.5f | Exact: %.5f",
                                             meth, k, approx, exact),
                              view = [a..b, -0.1..1.1],
                              axes = boxed,
                              labels = ["x", "f(x)"])];
        end do;
        
        # Create the animation
        anim := plots:-display(frame_list, insequence = true);
        return anim;
        
    else
        # Static plot
        dx := (b - a)/n;
        
        # Generate x-values based on the method
        if meth = "left" then
            xvals := [seq(a + (i-1)*dx, i = 1..n)];
            rect_color := "LightBlue";
        elif meth = "right" then
            xvals := [seq(a + i*dx, i = 1..n)];
            rect_color := "LightGreen";
        elif meth = "midpoint" then
            xvals := [seq(a + (i-1/2)*dx, i = 1..n)];
            rect_color := "LightPink";
        else
            error "Invalid method. Choose 'left', 'right' or 'midpoint'";
        end if;
        
        yvals := map(f, xvals);
        approx := add(yvals[i]*dx, i = 1..n);
        
        # Create rectangles with smart borders
        rect_plots := NULL;
        for i from 1 to n do
            left_x := a + (i-1)*dx;
            right_x := a + i*dx;
            rect_height := yvals[i];
            
            # Colored rectangle
            rect_plots := rect_plots,
                plottools:-rectangle([left_x, 0], [right_x, rect_height],
                                     color = rect_color, style = polygon,
                                     transparency = 0.3);
            
            # Draw rectangle borders intelligently
            if rect_height > 0 then
                if meth = "left" then
                    # ALWAYS draw bottom
                    rect_plots := rect_plots,
                        plot([[left_x, 0], [right_x, 0]],
                             color = "Black", thickness = 1);
                    
                    # ALWAYS draw top
                    rect_plots := rect_plots,
                        plot([[left_x, rect_height], [right_x, rect_height]],
                             color = "Black", thickness = 1);
                    
                    # Draw LEFT side ONLY for FIRST rectangle
                    if i = 1 then
                        rect_plots := rect_plots,
                            plot([[left_x, 0], [left_x, rect_height]],
                                 color = "Black", thickness = 1);
                    end if;
                    
                    # Draw RIGHT side ONLY for LAST rectangle
                    if i = n then
                        rect_plots := rect_plots,
                            plot([[right_x, 0], [right_x, rect_height]],
                                 color = "Black", thickness = 1);
                    end if;
                    
                elif meth = "right" then
                    # ALWAYS draw bottom
                    rect_plots := rect_plots,
                        plot([[left_x, 0], [right_x, 0]],
                             color = "Black", thickness = 1);
                    
                    # ALWAYS draw top
                    rect_plots := rect_plots,
                        plot([[left_x, rect_height], [right_x, rect_height]],
                             color = "Black", thickness = 1);
                    
                    # Draw LEFT side (always for right method)
                    rect_plots := rect_plots,
                        plot([[left_x, 0], [left_x, rect_height]],
                             color = "Black", thickness = 1);
                    
                    # Draw RIGHT side ONLY for LAST rectangle
                    if i = n then
                        rect_plots := rect_plots,
                            plot([[right_x, 0], [right_x, rect_height]],
                                 color = "Black", thickness = 1);
                    end if;
                    
                else  # midpoint
                    # Draw ALL sides (dashed line is in middle, no overlap)
                    rect_plots := rect_plots,
                        plot([[left_x, 0], [right_x, 0]],  # Bottom
                             color = "Black", thickness = 1);
                    rect_plots := rect_plots,
                        plot([[left_x, 0], [left_x, rect_height]],  # Left
                             color = "Black", thickness = 1);
                    rect_plots := rect_plots,
                        plot([[right_x, 0], [right_x, rect_height]],  # Right
                             color = "Black", thickness = 1);
                    rect_plots := rect_plots,
                        plot([[left_x, rect_height], [right_x, rect_height]],  # Top
                             color = "Black", thickness = 1);
                end if;
            end if;
        end do;
        
        # Points and vertical dashed lines
        point_plots := NULL;
        line_plots := NULL;
        for i from 1 to n do
            if yvals[i] > 0 then
                point_plots := point_plots,
                    plot([[xvals[i], yvals[i]]], style = point, symbol = solidcircle,
                         symbolsize = 12, color = "Red");
                
                # Vertical dashed line
                line_plots := line_plots,
                    plot([[xvals[i], 0], [xvals[i], yvals[i]]],
                         color = "Red", linestyle = dash, thickness = 1);
            end if;
        end do;
        
        # Function curve
        plot_func := plot(f(x), x = a..b, color = "DarkBlue", thickness = 2);
        
        # Display the plot
        return plots:-display([rect_plots, line_plots, plot_func, point_plots],
                             title = sprintf("Riemann Sum (%s) for f(x) = x² with n = %d\nExact: %.5f | Approximation: %.5f | Error: %.5f",
                                            meth, n, exact, approx, abs(exact-approx)),
                             view = [a..b, -0.1..1.1],
                             axes = boxed,
                             labels = ["x", "f(x)"]);
    end if;
end proc:

"maple.ini in user"

(1.1)

NULL

# ========== DRIE STATISCHE PLOTS ==========
print("=== THREE STATIC PLOTS ===");

# 1. Left endpoint method
p1 := RiemannPlot(meth = "left", n = 8):
print("Left endpoint plot created");
p1;

# 2. Midpoint method  
p2 := RiemannPlot(meth = "midpoint", n = 8):
print("Midpoint plot created");
p2;

# 3. Right endpoint method
p3 := RiemannPlot(meth = "right", n = 8):
print("Right endpoint plot created");
p3;

# Display all three static plots side by side
with(plots):
print("=== DISPLAYING ALL THREE STATIC PLOTS ===");
display(Array([p1, p2, p3]), title = "Comparison of Riemann Sum Methods (n=8)", size = [1200, 400]);

# ========== DRIE ANIMATIES ==========
print("=== CREATING THREE ANIMATIONS ===");

# 1. Animation for left endpoint method
print("Creating left endpoint animation...");
anim1 := RiemannPlot(meth = "left", animate = true):
print("Left endpoint animation created");

# 2. Animation for midpoint method  
print("Creating midpoint animation...");
anim2 := RiemannPlot(meth = "midpoint", animate = true):
print("Midpoint animation created");

# 3. Animation for right endpoint method
print("Creating right endpoint animation...");
anim3 := RiemannPlot(meth = "right", animate = true):
print("Right endpoint animation created");

# Display all three animations
print("=== DISPLAYING ALL THREE ANIMATIONS ===");

# Option 1: Display animations one after another
print("Animation 1: Left Endpoint Method");
anim1;

print("Animation 2: Midpoint Method");
anim2;

print("Animation 3: Right Endpoint Method");
anim3;

# Option 2: Display animations in an array (might not work for animations in all Maple versions)
# display(Array([anim1, anim2, anim3]), title = "Comparison of Riemann Sum Animations");

"=== THREE STATIC PLOTS ==="

 

"Left endpoint plot created"

 

 

"Midpoint plot created"

 

 

"Right endpoint plot created"

 

 

"=== DISPLAYING ALL THREE STATIC PLOTS ==="

 

 

 

 

 

 

 

"=== CREATING THREE ANIMATIONS ==="

 

"Creating left endpoint animation..."

 

"Left endpoint animation created"

 

"Creating midpoint animation..."

 

"Midpoint animation created"

 

"Creating right endpoint animation..."

 

"Right endpoint animation created"

 

"=== DISPLAYING ALL THREE ANIMATIONS ==="

 

"Animation 1: Left Endpoint Method"

 

 

"Animation 2: Midpoint Method"

 

 

"Animation 3: Right Endpoint Method"

 

 

 

NULL


 

Download Riemann_someemn_mprimes_23-12-2025.mw

@salim-barzani 
You need the math for doing this ...

@dharr Your code is invaluable, and I don't know if the ai is clever enough if it gets the problem definition for this , to come up with the right programming too ?
The ideas in  your code are a basis for variants via AI.

variants_op_maple_collect_21-12-2025.mw

@salim-barzani 
Perhaps the AI will come up with a suitable solution, otherwise I don't know either
.generalisatie_Bij_mprimes_vraag_15-12-2025.mw

@salim-barzani 

restart;

# Shorter version
e_ij := ((3*c1*ki*(ki - kj)*lj - c3)*li^2 - 3*(c1*kj*(ki - kj)*lj - (2/3)*c3)*lj*li - c3*lj^2) /
        ((3*c1*ki*(ki + kj)*lj - c3)*li^2 + 3*(c1*kj*(ki + kj)*lj + (2/3)*c3)*lj*li - c3*lj^2);

# Show the limit definition using the inert form
Limit_definition := Limit((subs(ki=k1, kj=k3, li=l1, lj=l3, e_ij) - 1)/(k1*k3), k1=0)= limit((subs(ki=k1, kj=k3, li=l1, lj=l3, e_ij) - 1)/(k1*k3), k1=0);

# Calculate the limit using the active form
B13_direct := limit((subs(ki=k1, kj=k3, li=l1, lj=l3, e_ij) - 1)/(k1*k3), k1=0);

# Simplify
B13_result := simplify(B13_direct);
1 2 3 4 5 6 7 Last Page 1 of 80