Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Bug
Options
Go to last post Go to first unread
Offline pdalet  
#1 Posted : 09 November 2010 23:12:30(UTC)
pdalet


Rank: Advanced Member

Groups: Registered
Joined: 19/09/2009(UTC)
Posts: 34
Man
France, Metropolitan

Was thanked: 17 time(s) in 11 post(s)
Hello,

I've found a bug on the solve function.



ess.sm

best regards

Philippe DALET
FRANCE

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline omorr  
#2 Posted : 10 November 2010 01:37:56(UTC)
omorr


Rank: Administration

Groups: Registered, Advanced Member
Joined: 23/06/2009(UTC)
Posts: 1,740
Man
Serbia

Was thanked: 318 time(s) in 268 post(s)
Hello Philippe,

I do not think this is a bug. You just bumped into some numerical problems.
For instance, try to increase the number of decimal places:

res←solve(0.05-x-x^2*1/K,x) res=mat(0.00126962,0.00040433,2,1)
x←el(res,1) 0.05-x-x^2*1/K=-0.04391025
x←el(res,2) 0.05-x-x^2*1/K=0.04020022

Not so good, isn't it. That is a problem when you have the function with a rational expression and small value in the denominator (division with K) and the roots close to zero. This is a polynomial of the second degree and when you plot this function you could see that there are two roots, one positive and one negative. Let's try the "roots" this time (guess values are important here):

res1←roots(0.05-X-X^2*1/K,X,-1)
res1=-0.00094148 0.05-res1-res1^2*1/K=2.07062052*10^{-17}
res2←roots(0.05-X-X^2*1/K,X,1)
res2=0.00092408 0.05-res2-res2^2*1/K=-1.47531712*10^{-16}

For this problematic equation, the transforming of the equation will give a slight better results (not much better, but "solve" will did its best):

res←solve(K*(0.05-x)-x^2,x) res=mat(0.00126962,0.00040433,2,1)
K*(0.05-el(res,1))-el(res,1)^2=-0.00000076
K*(0.05-el(res,2))-el(res,2)^2=0.0000007

Moreover, you could try to use the searching interval:
res←solve(K*(0.05-x)-x^2,x,0,1)
res=0.0009240784783
K*(0.05-res)-res^2=3.5504197442949*10^{-16}
(negative root could not find?)

You could try "roots" here as well. The results will be the same (-0.00094148,0.00092408). These are very close to the analytical results.

"solve" and "roots" use the different numerical algorithms and solving the nonlinear equations could be troublesome sometimes. Here you have both roots close to zero and that could make troubles.

Regards,
Radovan

Edited by user 10 November 2010 09:51:35(UTC)  | Reason: Not specified

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Users browsing this topic
Guest
Similar Topics
Ellipse and... go to bugs (Bugs & Problems)
by OchkovVF 07/09/2023 17:05:14(UTC)
One strange bug (Bugs & Problems)
by OchkovVF 01/09/2023 14:18:51(UTC)
Bug tracking system: Write access for assignee of an issue (Questions)
by mkraska 11/08/2023 14:36:34(UTC)
Maxima Plugin Feedback Survey: Share Your Ideas and Report Bugs (Feature Requests)
by fakemoses 16/06/2023 13:27:33(UTC)
bug? (Questions)
by Beyaz 13/04/2023 16:52:03(UTC)
Residual Imaginary Bug (Bugs & Problems)
by Jean Giraud 09/02/2023 22:01:33(UTC)
Bug in solve() (Bugs & Problems)
by uni 08/02/2023 08:12:47(UTC)
Bug in Smath Viewer using Special Functions (Bugs & Problems)
by Hildebrando Pereira 02/02/2023 19:38:59(UTC)
Bug inverting matrices (Bugs & Problems)
by David R 28/10/2022 04:51:20(UTC)
iOS iPhone Version Crash Bug fix request (Bugs & Problems)
by Camma 07/09/2022 09:22:50(UTC)
Table Problems, Possible bug? (Bugs & Problems)
by ianlh 28/07/2022 12:59:37(UTC)
TooManyBugs in There (Samples)
by Jean Giraud 14/05/2022 16:21:19(UTC)
bug in matrix function involving a double loop (Bugs & Problems)
by loha 29/03/2022 18:52:52(UTC)
bug in if() (Bugs & Problems)
by MarB 26/03/2022 14:49:18(UTC)
Special Plots On 2D Plot Bug (Bugs & Problems)
by Mr. Whiskers 21/03/2022 18:00:29(UTC)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.