Different sympy.solve results in the video tutorial course I am working on and on my local jupyter installation.

42 views
Skip to first unread message

Ronnie van Aarle

unread,
Jul 23, 2026, 6:40:20 AM (yesterday) Jul 23
to sympy
Hello sympy group,
 
I am working on a course about python programming and I stumbled across a noticable difference between the results in the course and in the results I get on my screen.
 
There have been a few differences between the course and the actual programming I have done due to version updates and changes in python. Presumably nothing special. 

But now I see a difference in output that bothers me because the values resulting from the expressions are different between the tutorial examples in the training video and the results I get myself. 

According to my limited knowlegde about mathematics the results I get are wrong because the plus and minus signs are left out and there is a minus in the first resulting expression that should be a plus sign if you'd ask me. 

I added screenshots of the results on my screen and in the video tutorial and also the actual jupyter python notebook file I made as attachements to this email so you can see for yourself.
 
I have installed jupyter as part of anaconda navigator 2.7.1 last week and I assume the sympy library I'm using is the one supplied with the anaconda jupyter installation. I've never worked with jupyter before until now.
 
I think that result from computation in the tutorial:

+(1/2)+(sqrt(7)/2) and -(1/2)+(sqrt(7)/2)
 
is pretty different from result from computation on my system

(1/2)-(sqrt(7)/2) and (1/2)+(sqrt(7)/2)

Notice the plus and minus signs before both answers in the tuturial's outcome and the plus and minus in the results of the functions being solved in my case using pympy.solve(equation)

Due to the fact that the square root of a number or a polynomial can be either positive or negative I think the first answer is the right one and the second one is wrong.

Maybe someone who's more experienced can see what is going on here and tell me if I'm right or  wrong and in the latter case what I didn't understand or do right.

With kind regards, Ronnie van Aarle.
solving for x exercises1.ipynb
different result after solve.png
different result in my program or version of either python or sympy.png
Message has been deleted

Peter Stahlecker

unread,
Jul 23, 2026, 7:25:07 AM (yesterday) Jul 23
to sympy
Did they solve the same equation in your tutorial?
sympy's result is correct as you can verify manually.

Ronnie van Aarle

unread,
Jul 23, 2026, 9:19:26 AM (yesterday) Jul 23
to sympy
Yes, the equation in the tutorial is the same as the equation I entered in my own Jupyter developer environment.

I've done some checking and using a scientific calculator I do get three different results for:

 1/2 + sqrt(7)/2, 
-1/2 + sqrt(7)/2 
and 1/2 - sqrt(7)/2.

The one screenshot with the lesser amount of lines is from the video tutorial and the other screenshot is the one I made on my own system.

A made a few more screenshots, of the calculator results this time, so you can see for yourself.

minus half plus.png
half plus.png
half minus.png

Peter Stahlecker

unread,
Jul 23, 2026, 9:28:53 AM (yesterday) Jul 23
to sympy
If the equation is -2q + 2 + 3/q = 0   <-->  -2q^2 + 2q + 3 = 0
the only two solutions are 1/2 + 1/2 * sqrt(7) and 1/2 - 1/2 * sqrt(7)

You may verify manually by using the general formula for quadratic equations:  Quadratic formula - Wikipedia

Message has been deleted

Peter Stahlecker

unread,
5:23 AM (5 hours ago) 5:23 AM
to sympy
most welcome!

ronnie.v...@gmail.com schrieb am Freitag, 24. Juli 2026 um 11:21:35 UTC+2:
Now I see what I didn't see yesterday.

There is no  -1/2 + sqrt(7)/2  in the results from the course output. I need to take a break quicker.

(1/2) and -(sqrt(7)/2 have been swapped over the plus sign in the different versions of sympy according to commutative law and I failed to notice that.
Multiplying all terms by q does make sense indeed, I did the math on paper and I got to the same results as yo did.

Thank you for your reply, now I see where I went wrong.

Ronnie van Aarle

unread,
5:43 AM (4 hours ago) 5:43 AM
to sympy
Now I see what I didn't see yesterday.

There is no  -1/2 + sqrt(7)/2  in the results from the course output. I need to take a break quicker.

(1/2) and -(sqrt(7)/2 have been swapped over the plus sign in the different versions of sympy according to commutative law and I failed to notice that.
Multiplying all terms by q does make sense indeed, I did the math on paper and I got to the same results as you did.

Thank you for your reply, now I see where I went wrong.

On Thursday, July 23, 2026 at 3:28:53 PM UTC+2 peter.st...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages