cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Solve Block so rude? We can fool ourselves by using Solve Block that we found all the solutions?

Cornel
18-Opal

Solve Block so rude? We can fool ourselves by using Solve Block that we found all the solutions?

Hi,

I took one of the equation from this topic https://community.ptc.com/t5/Mathcad/Newton-s-method/m-p/949155#M211771 

Cornel_1-1715589015241.png


I see that Solve Block does not give all the solutions of the system equations only by trying only one pairs of (x,y) guess values:

Cornel_0-1715589000073.png


And we need to change manually the guess values in the hoping that we will get the all solutions. But what to do when we do not have other alternatives to know that the system of eq has more one solution and when with the limited guess values tried we got the same solution?

Cornel_2-1715589096889.pngCornel_3-1715589106008.png

Cornel_5-1715589698791.png

Cornel_8-1715590226066.png

Cornel_6-1715589709025.png


But my questions are:
1. Why Solve block gives solutions like x=-0.779 and y=-0.443, why other method gives x=-0.22, y=-0.69, and so on.
2. How one can be sure while using Solve Block he finds all the solutions of when solving the system of equations? As I do not like the solution given with solve block that we cannot be sure that we found all the solutions, as one cannot be sure that he tried all the variants for guess values.

Without changing the guess values we conclude that this system of equations has only one solutions as was presented in the Newton's method topic from where I took this example, but relying that the above systems of eq has only one solution is wrong, as we can see from below (total (x,y) pairs of solutions are at least 4, and not only 1 as the solutions of this system of eq was presented in Newton's topic).  And moreover we can see that with solve block we can get more than 4 pairs of (x,y) solutions. 

Cornel_4-1715589256925.png

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To:Cornel)


@Cornel wrote:


In this case I do not know how to make the plot,


Here you are. Every point of intersection of the blue and the red "curve" is a solution 🙂

Werner_E_0-1715639697729.png

 


but in above set of equations I do not know really how many set of (x,y) paris of solutions there are..

Neither do I. Here are a few solutions out of a list of 104 solutions (and this list sure is not complete, I guess).

Werner_E_1-1715640464776.png

Have fun!

 

View solution in original post

16 REPLIES 16

How to use solve block for finding all the solutions of the system of eq, but being sure that one found/catch all the solutions by being sure that he tried all the guess values (so, without losing any solution)?

Werner_E
24-Ruby V
(To:Cornel)


@Cornel wrote:

How to use solve block for finding all the solutions of the system of eq, but being sure that one found/catch all the solutions by being sure that he tried all the guess values (so, without losing any solution)?


Simple answer: You can't.

But you can try your best, e.g. by parametrizing the solve block and searching for solutions using a tight net of guess values. But you can never nbe sure not to miss solutions when you use numerical methods and most system of equations simply are to complicated for symbolic solution.

For example look at this another example:

In this case we cannot rely on the above other method like I showed in the first post:

Cornel_0-1715599139454.png


But by using the solve block:

Cornel_1-1715599163503.png


Now if we change again the guess values:

Cornel_2-1715599239428.pngCornel_3-1715599247788.png

Cornel_4-1715599256466.png

And so on, we could continue infinitely, without knowing if we found all the solutions.

For example let's say that we want to find the solutions of this system of equations for:

Cornel_5-1715599367331.png

How to do?

ttokoro
20-Turquoise
(To:Cornel)

Make plot to find the answers.

 

image.pngimage.pngimage.pngimage.png

image.png

Make plot for this...:

Cornel_0-1715600164157.png

And find the answer for:

Cornel_1-1715600183415.png


In this case I do not know how to make the plot, at least as it is possible for the former set of equations from my first post..
And in the first set of system of eq we could be happy that there was about 4 set of pairs of solutions, but in above set of equations I do not know really how many set of (x,y) paris of solutions there are..

Werner_E
24-Ruby V
(To:Cornel)


@Cornel wrote:


In this case I do not know how to make the plot,


Here you are. Every point of intersection of the blue and the red "curve" is a solution 🙂

Werner_E_0-1715639697729.png

 


but in above set of equations I do not know really how many set of (x,y) paris of solutions there are..

Neither do I. Here are a few solutions out of a list of 104 solutions (and this list sure is not complete, I guess).

Werner_E_1-1715640464776.png

Have fun!

 

ttokoro
20-Turquoise
(To:Cornel)

 

image.pngimage.pngimage.pngimage.png

Werner_E
24-Ruby V
(To:Cornel)


@Cornel wrote:

For example look at this another example:

In this case we cannot rely on the above other method like I showed in the first post:

Yes, too bad! You never can rely on anything in life ...

 

 


And so on, we could continue infinitely, without knowing if we found all the solutions.


Correct! Now you got it!

Werner_E
24-Ruby V
(To:Cornel)


@Cornel wrote:

...

But what to do when we do not have other alternatives to know that the system of eq has more one solution and when with the limited guess values tried we got the same solution?


Welcome to the world of Math! You always have to use your own brain and mathematical knowledge to deal with the task. Mathcad is a tool and as such has sure its limits.

BTW, there is no way, no algorithm which will provide ALL solutions for any arbitrary equation or system of equations.
Numeric algorithms always will provide you with just one solution based on the guess(es). Sometimes it helps to use the symbolics, but as we know its capabilities are limited, too (especially true for the symbolics in Prime). In case of your example,

In real Mathcad and even in Prime starting with version 10 you also can choose from a menu the numerical algorithm which should be used - changing the algorithm may return a different solution using the very same guesses sometimes.

Werner_E_0-1715598047382.png

Choosing "Conjugate Gradient" returns the 0.779/0.443 solution pair in your first example.

 

Of course you always can parametrize the solve block, turning it into a function of the guess values and then use a program with nested loops to try many guesses within a certain range, collect all results and then remove the duplicates. But again - there is no guarantee that you will find ALL solutions within the range that way.

 

Mathematical tools will certainly become better and more powerful, but they will always have their limits. The push-button mathematics that you are apparently calling for, which makes your own knowledge and skills obsolete, will probably not be available any time soon.

 


Without changing the guess values we conclude that this system of equations has only one solutions

A wrong conclusion and that's not the fault of Prime! It means that the user does not understand that his tools have limits and that he need to use his own mathematical knowledge, too.
The point is that you should not blindly trust your tools, but that you should know as much as possible about their limitations and weaknesses so that you can use them sensibly and profitably to your advantage and make your work easier.


@Werner_E wrote:

Of course you always can parametrize the solve block, turning it into a function of the guess values and then use a program with nested loops to try many guesses within a certain range, collect all results and then remove the duplicates. But again - there is no guarantee that you will find ALL solutions within the range that way.

 


Do you have any idea on how this implementation would look like?

Werner_E
24-Ruby V
(To:Cornel)


@Cornel wrote:

@Werner_E wrote:

Of course you always can parametrize the solve block, turning it into a function of the guess values and then use a program with nested loops to try many guesses within a certain range, collect all results and then remove the duplicates. But again - there is no guarantee that you will find ALL solutions within the range that way.

 


Do you have any idea on how this implementation would look like?


Sure and examples can possibly be found here in older forum threads - I guess also in some of your own threads -mainly covering all(!?) zeros of an arbitrary function in just one variable.

In case your question is about parametrizing the solve block, here it is - you now conveniently can experiment with different guess values.

Werner_E_0-1715600331918.png

 

If you intend to write the program which creates a matrix of solution changing in small steps the guess values, you may run into the problem that some guesses might make the solve block fail, finding no solution. In that case your whole program would fail.
So it may be a good idea to wrap the "sol" function in a "try .. on error ..." statement:

Werner_E_1-1715601067284.png

Good luck!

 

BTW, I remember an oder thread initiated by Valery Ochkov where he played around (in real Mathcad) with numerical algorithms and the solution they provide depending on the guess values. Coloring each point (=pair of guess values) according to the solution it leads created some nice pictures. If you can find that thread you might be interested in the methods shown there.

 

EDIT: The mentioned thread was surprisingly easy to find: Portrait of roots of two equations

 

And is it possible to iterate an entire x, y vector of guess values?

Cornel_0-1715600774285.png

 

Werner_E
24-Ruby V
(To:Cornel)

Yes, its possible to use range variables but I would suggest that you instead use a program with for loops to create the 41 x 121 matrix of pairs. Furthermore you should wrap the sol function in a try..onerror... statement (I have shown in detail in one of my answers above) to avoid the effect seen in your picture  - if the solve block fails for just one set of guess values, the whole calculation fails.

 

BTW, did you already look at the thread I pointed you to (Portrait of roots of two equations). You could try something similar with your equations. Maybe we can at least see some nice pictures ....

Werner_E
24-Ruby V
(To:Cornel)

@Cornel 

Werner_E_0-1715615345466.png

WRONG!!

There actually ARE four solution pairs, but you just found two of them. Two of your solutions are NOT solution to this system! Make a check!

The solutions are:

Werner_E_1-1715615609856.png

 

 

 

Yes, I forgot to check what pairs of solutions are indeed the solutions for this system.
But then why with this method fails to find all the solutions of the system? (that is, all the solutions, even if some prove to be the right solutions for the system, and others not). I did not see any problems in how the solutions of the system was obtained. This method cannot be used to find all the potential solutions?

Cornel_0-1715617089845.png

 

By all solutions I mean also (0.779, 0.443), (-0.779, -0.443) to be found by above method

Top Tags