Problem with equation in Programming - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Problem with equation in Programming (/thread-4017.html) |
Problem with equation in Programming - nakjaen - 05-29-2015 02:38 PM Hi guys i have a problem with a program, i need solve a 3grade equation, i input the code but i dont have the solution When i solve in home window i have the solution, why? code: Code: EXPORT prueba1() programming: [attachment=2115] home window: [attachment=2116] RE: Problem with equation in Programming - DrD - 05-29-2015 05:47 PM This seems to work: Code:
RE: Problem with equation in Programming - nakjaen - 05-29-2015 05:54 PM no, take me the same error "{}" RE: Problem with equation in Programming - DrD - 05-29-2015 06:40 PM If you want "that" result, this take you there: Code:
RE: Problem with equation in Programming - nakjaen - 05-29-2015 08:50 PM no, it is part of a bigger program, the variables are obtained and then solve the equation I do not understand why other equations solved and that no how i can use function fsolve? RE: Problem with equation in Programming - DrD - 05-29-2015 10:29 PM There are two pertinent points: 1. The formula used in your program is not the same as the formula used to manually produce the values in your screenshot. The difference is in the paren's. 2. Local variables in HOME mode don't cross over to CAS mode as expected. That is why the snippet I sent (with GLOBAL variables) produces the same result as obtained in your screenshot; or, conversely, why your program isn't working as you expect. There are ways to get around this, such as by not mixing HOME and CAS program constructs, use of global variables, and possibly other means. You can work out the details from this information. RE: Problem with equation in Programming - DrD - 05-30-2015 12:08 PM This is closer to your original program, with output matching your screenshot: Code:
|