Rank: Newbie
Groups: Registered
Joined: 27/01/2012(UTC) Posts: 3 Location: Guatemala
|
I have gone crazy trying to figure out what I´m doing wrong but I came to the conclusion that there must be some kind of bug because I try to do a calculation in different ways and I get different results. I don´t know how to attach a file or insert an image of what I mean, can someone help?
|
|
|
|
Rank: Administration Groups: Registered, Advanced Member Joined: 23/06/2009(UTC) Posts: 1,740 Was thanked: 318 time(s) in 268 post(s)
|
Hello, jamlatino wrote:I have gone crazy trying to figure out what I´m doing wrong but I came to the conclusion that there must be some kind of bug because I try to do a calculation in different ways and I get different results. I don´t know how to attach a file or insert an image of what I mean, can someone help? 1. Try to use "Live" version here. Use "Upload" and upload your *.sm file. If everything goes well - get the link and put it here. Pay attention that there are restrictions regarding Live version - no plots, complicated programming structures etc. Actually, if Live version can not "swallow" your file - error will be issued. 2.Register to some free hosting service like, say, dropbox. You will get free 2GB space initially (never expires). There you can have your folders, upload files etc. Put your files in the dropbox "Public" folder. Get the links to the files ( right mouse click and get the "Public link" ) and put those links in your posts here on the Forum by using "Insert image" if there is a link to an image, or "Create link" if there is a link to a file - as easy as that. Regards, Radovan Edited by user 29 January 2012 00:35:55(UTC)
| Reason: Not specified |
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!" |
|
|
|
Rank: Newbie
Groups: Registered
Joined: 27/01/2012(UTC) Posts: 3 Location: Guatemala
|
Thanks so much for your help, here's the link to the file with the error I mentioned Error
|
|
|
|
Rank: Administration Groups: Registered, Advanced Member Joined: 23/06/2009(UTC) Posts: 1,740 Was thanked: 318 time(s) in 268 post(s)
|
Hello, It seems there is a bug in SMath, or at least something we must take care off. Here is the expression. GAr(A,G,i,n)←A*({(1+i)^n-1}/{(1+i)^n*i})+G/i*({(1+i)^n-1}/{(1+i)^n*i}-n/{(1+i)^n})Now, if the Optimization|Symbolic is set, here is the result - it seems the wrong one: GAr(1000,100,0.04,5)=4453.1911 Now, if the Optimization|Numeric or None is set, it is the right one: GAr(1000,100,0.04,5)=5307.2893On the other hand, apparently strange thing happen when you exchange the order of regions 1. First expressions then assignment - wrong 2. First assignment then expressions - right Actually, I found the reason. The problem is in variable "i" - imaginary unit , but I still believe this is wrong regarding the function definition. Just change everywhere the variable "i" into something else and there would be no problem. For instance: GAr(A,G,ii,n)←(A*({(1+ii)^n-1}/{(1+ii)^n*ii}))+(G/ii*({(1+ii)^n-1}/{(1+ii)^n*ii}-n/{(1+ii)^n}))GAr(1000,100,0.04,5)=5307.2893Regardless the Optimization set. On the other hand, when you did it step by step - the imaginary unit was used and not the variable you defined AFTER the expressions defined. You would have seen this by putting the mouse over the expression (symbolic value) if the imaginary unit would have been replaced by its value or: f1—(1+sqrt(-1))^n instead of: f1—(1+i)^nRegards, Radovan Edited by user 29 January 2012 12:35:13(UTC)
| Reason: Not specified |
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!" |
|
|
|
Rank: Newbie
Groups: Registered
Joined: 27/01/2012(UTC) Posts: 3 Location: Guatemala
|
Thanks a lot, I changed i to ii as you suggested and got the right answer, but still, is there a bug in the program?
|
|
|
|
Rank: Administration Groups: Registered, Advanced Member Joined: 23/06/2009(UTC) Posts: 1,740 Was thanked: 318 time(s) in 268 post(s)
|
Yes, I think it is a bug regarding function definition and using variable "i" as a fictive argument. The safest way is not to use it as an argument in function definition Regards, Radovan EDIT: Actually, there is a solution. Define function with line(). Often, this will be the only way we can define a function. Based on my experience, it seems that the safest way is to define even a single line function by using line() environment. Maybe a bit confusing, but I do not know whay is that working this way: f(i)←line(i^2,1,1)f(100)=10000Contrary to the wrong one f(i)←i^2f(100)=-1Edited by user 29 January 2012 17:28:42(UTC)
| Reason: Not specified |
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!" |
|
|
|
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.