janhardo

430 Reputation

8 Badges

10 years, 208 days

MaplePrimes Activity


These are replies submitted by janhardo

this example is a intersection in implicit 2D functions
Add any two implicit function you can think of in the intersections ( )  proc 
let's look how intersections( ) can handle this :-)  

Its about polynome expressions, so all functions as polynomes expressed can be used


 

intersections := proc(P, Q, T, rangeX, rangeY)
    local R, W, w, t, a, b, sol, symbolicAlgcurves, buff, v, eq1, eq2, solplot, points, yvals, xvals, final_solutions, i;

    sol := [];  # List for numerical solutions

    # Gebruik `algcurves` voor expliciete symbolische oplossingen
    with(algcurves):
    symbolicAlgcurves := intersectcurves(P, Q, X, Y);

    if nops(symbolicAlgcurves) > 0 then
        yvals := Y = ~[solve(symbolicAlgcurves[1][2][2], Y)];
        xvals := map2(eval, symbolicAlgcurves[1][2][1], yvals);
        final_solutions := zip((x, y) -> {solve(x, {X})[], y}, xvals, yvals);

        print("Symbolic solutions (explicit notation):");
        for i in final_solutions do
            print(i);
        end do;
    else
        print("No symbolic solutions found.");
    end if;

    # Swap variable depending on T
    if T = Y then
        W := X;
    else
        W := Y;
    end if;

    # Compute resultant to eliminate one variable
    R := resultant(P, Q, T);
    print("Resultant:");
    print(R);

    # Numerical solution for the resultant equation
    w := [fsolve(R, W, rangeX)];  # Solutions for W
    t := [];

    # Solve for the dependent variable
    for v in w do
        t := [op(t), op([fsolve(subs(W = v, P), T, rangeY)])]; # Add solutions to the list
    end do;

    # Validate and store unique solutions
    for a in w do
        for b in t do
            if T = Y then
                buff := abs(subs(X = a, Y = b, P)) + abs(subs(X = a, Y = b, Q));
                if buff < 1/100000000 then
                    if not member([a, b], sol) then
                        sol := [op(sol), [a, b]];
                    end if;
                end if;
            else
                buff := abs(subs(X = b, Y = a, P)) + abs(subs(X = b, Y = a, Q));
                if buff < 1/100000000 then
                    if not member([b, a], sol) then
                        sol := [op(sol), [b, a]];
                    end if;
                end if;
            end if;
        end do;
    end do;

    # Display results
    printf("Number of unique numerical solutions: %a", nops(sol));
    print("");
    print("Numerical solutions:");
    print(sol);

    # Format points for pointplot
    points := [seq([sol[i][1], sol[i][2]], i = 1 .. nops(sol))];

    # Determine dynamic ranges for plotting
    eq1 := plots:-implicitplot(P, X = rangeX, Y = rangeY, color = red, grid = [100, 100]);
    eq2 := plots:-implicitplot(Q, X = rangeX, Y = rangeY, color = blue, grid = [100, 100]);
    solplot := plots:-pointplot(points, symbol = solidcircle, symbolsize = 12, color = black);

    # Combine and display plots
    plots:-display([eq1, eq2, solplot], title = "Intersections of the Curves", scaling = constrained);
end proc:

intersections(Y-X^2 ,Y+(X^2)-1 , X, -2 .. 2, -2 .. 2);

"Symbolic solutions (explicit notation):"

 

{Y = 1/2, {X = -(1/2)*2^(1/2)}, {X = (1/2)*2^(1/2)}}

 

"Resultant:"

 

(-2*Y+1)^2

 

Number of unique numerical solutions: 2

 

""

 

"Numerical solutions:"

 

[[-.7071067812, .5000000000], [.7071067812, .5000000000]]

 

 

intersections(X^2 + Y^2 - 1 , X - Y, X, -2 .. 2, -2 .. 2);

"Symbolic solutions (explicit notation):"

 

{X = (1/2)*2^(1/2), Y = (1/2)*2^(1/2)}

 

{X = -(1/2)*2^(1/2), Y = -(1/2)*2^(1/2)}

 

"Resultant:"

 

2*Y^2-1

 

Number of unique numerical solutions: 2

 

""

 

"Numerical solutions:"

 

[[-.7071067812, -.7071067812], [.7071067812, .7071067812]]

 

 

intersections(Y^2 + X^2-3/2 , (1/4)*X^2 + Y^2 - 1, X, -2 .. 2, -2 .. 2);# rational input

"Symbolic solutions (explicit notation):"

 

{Y = (1/6)*30^(1/2), {X = -(1/3)*6^(1/2)}, {X = (1/3)*6^(1/2)}}

 

{Y = -(1/6)*30^(1/2), {X = -(1/3)*6^(1/2)}, {X = (1/3)*6^(1/2)}}

 

"Resultant:"

 

(1/64)*(6*Y^2-5)^2

 

Number of unique numerical solutions: 4

 

""

 

"Numerical solutions:"

 

[[-.8164965809, -.9128709292], [.8164965809, -.9128709292], [-.8164965809, .9128709292], [.8164965809, .9128709292]]

 

 

 


 

Download snijpunten_van_2d_curves_maple_primesDEF_6-1-2025.mw

 

restart;

with(DEtools):
with(plots):

# Define the direction field with actual arrows
F := fieldplot([-3*x - 4*y, 2*x + y],
               x = -4..4,
               y = -4..4,
               arrows = slim,  # Use arrows in the field
               grid = [10, 10]):  # Grid density

# Generate the solution curves
S := DEplot(
    [diff(x(t), t) = -3*x(t) - 4*y(t), diff(y(t), t) = 2*x(t) + y(t)],
    [x(t), y(t)],
    t = 0..10,
    x = -4..4,
    y = -4..4,
    'labels' = [x(t), y(t)],
    'axes' = 'boxed',
    'arrows' = 'none'
):

# Combine the field and the solutions in one plot
display(F, S);

"maple.ini in users"

 

 
 

 

Download de_plot_met_minder_pijlen_mapl_eprimes5-1-2024.mw

ode : Ordinary Differential Equation
pde : Partial differential Equation 

@salim-barzani 

Outline here , how you think you will find a function as a solution of the pde that will satisfy the ode test?

I have a variant of this : 4 dogs starting on the vertices of a square.
The dogs also chase each other and have maple code of it and a differential equation was constructed from this, with a plot of the dogs' trajectories
This seems like an analogous example to me ?..no my example is 2D and this spatial 

sirmodel_met_explore_mogelijk.mw

In 2000 when  start to study for B Ed math for secondary education , i choosed this Sir model  as a assigment to work on.
Note: this example of the sir model is not made by me  

It has not been wise of the member to comply not with the friendly request to stop deleting done questions, but simply join a previously done question or come up with an entirely new question separate from the existing one and post it.

Then there would have been nothing wrong and he could have asked any question, provided the proper procedure is followed.
Now again, why has the member's last post been deleted ? , that does not become clear now... Were there several questions under one posted question ?

Yes, duplicate questions , that is a problem, but well had the member complied with request not to delete done questions again, then duplicate questions could have started being asked by him again and that is a danger if you start asking a lot of questions and would need moderation again .

@salim-barzani    Well for this kind of practice they have the wrong one in front of them  
Follow the two points  i earlier made for posting question, otherwise you are a shooting duck :-)


Should these tips not help and happen again , I want to hold the moderators accountable. 
Going to discuss this undesirable behaviour at Maple headquarters themselves that someone from their maple primes moderators is making it impossible for forum users to familiarize themselves with the software
You cannot afford everything to a forum user should you be a moderator and think you are Jesus. 

@mmcdara 

"Do you have any idea where your last question aboiur the Wiener process and the 2D representation of T2 is now?"

Surely this deletion of a question is not automated ?
Interestingly, I was looking at the questions on Maple primes late last night and shortly after, the question had been removed ?

Note that also that you don't put two not really related questions together, because that way you put two loosely related questions together and that is not the intention either.
Possibly this was the reason for the removal.

I can't think of anything else for it, unless there must be a sick mind, but I don't think so and the questions are not automatically deleted either.
That leaves only one possibility ...
I would find it so user-friendly for forum users that the reason for the deletion of the question is stated and who is responsible for it 

if not , I find that weak behaviour to guide users on the forum in this way and you are not a good moderator in my own, but a stubborn pusher.

---------------------------------------------------------------

1) Do not ask multiple questions on the same topic and start posting them as separate questions on mapleprimes.
Instead, ask 1 question and connect related follow-up questions to the existing question.
2) No asking multiple questions with different topics and posting them as 1 question.
Instead ask these as separate questions and post them on mapleprimes forum.

@salim-barzani 

The question now is who will help you, if you delete the questions with the help again, because that is not the intention on a forum as a place where people want to gain new knowledge for themselves as well as others.



What does this mean ?

factor(x^2-4);
                        (x - 2) (x + 2)

expression:=x^2-4;
factor(expression);

Factoring a curious product.. has nothing to do with a equation

 

collect((x-2)*(x+2),x);
                              2    
                             x  - 4


 

@salim-barzani 

The 2D mode does not seem to work error-free , but it does seem easier to work with.
Use the 1D mode , then you can be sure you won't encounter any error surprises, which can occur in 2D mode 

@salim-barzani 

"i think it is usless, instead of this ask question there is a lot people which can help a lot "
Yes, if they will ...

I did not tried yet  to make a procedure out of the code of @mmcdara
"Currently, the equations are simple, but improvements are needed to extend this method to higher dimensions, such as (2+1) and (3+1). Right now, it’s only applicable to (1+1) dimensions"

So i try first to make code for (1+1) dimensions , what accepts th ewandted pdes 

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