Program code with solve function
|
06-27-2024, 10:30 AM
(This post was last modified: 06-29-2024 05:00 PM by Gene222.)
Post: #6
|
|||
|
|||
RE: Program code with solve function
If the equation being solved is difficult, solve can give a wrong or unexpected answer, as discussed in the following posts.
Solve wrong answer Question on solve. See Tim's reply. This occures when solve cannot symbolically solve the equation and reverts to using fsolve. fsolve will take the valve stored in the solve variable, gX, and possibly uses it like an initial guess or something else that may effects the results. In some instances, this can lead to the wrong answer. On difficult equations, to help prevent solve from reverting to fsolve, it was suggested to write the equation in the exact form, instead of the approximate form. Apparently, the increased accuracy can make a difference on some equations, and the exact form helps prevent solve from reverting to fsolve. For the solve variable, it was suggested to purge the variable to remove anything stored in the variable and return it to its symbolic state. See purge help. Alternatively, one can use the fsolve bisection method, provided one knows where the solution exists. I added a purge statement. However, for me, it was more important to write the equation in the exact form for the improved accuracy. Revised program shown below. Code: LOCAL gX,gY,gAns; |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Program code with solve function - SoxxoZ - 06-19-2024, 02:23 PM
RE: Program code with solve function - gehakte_bits - 06-20-2024, 10:04 PM
RE: Program code with solve function - Gene222 - 06-25-2024, 08:17 PM
RE: Program code with solve function - Gene222 - 06-26-2024, 04:10 AM
RE: Program code with solve function - Gene222 - 06-27-2024 10:30 AM
RE: Program code with solve function - Gene222 - 06-28-2024, 05:54 PM
RE: Program code with solve function - ftneek - 06-29-2024, 02:28 AM
RE: Program code with solve function - Gene222 - 06-29-2024, 04:31 PM
RE: Program code with solve function - gehakte_bits - 06-21-2024, 02:13 PM
RE: Program code with solve function - Gene222 - 07-09-2024, 09:19 PM
|
User(s) browsing this thread: 1 Guest(s)