(11-11-2023 05:03 AM)ZDog2002 Wrote: [ -> ]If I create n as a local variable, it doesn't give any errors but always returns 0.
The following is what I observed for software version 2.1.14730 (2023 04 13), when using solve in a program.
Solve variable
The solve variable can be a system variable A-Z, export variable, or global variable. The solve variable cannot be a local function variable, function parameter variable, or list variable, such as gD(1). When solving an equation symbolically, the equation variables are not declared or exist anywhere on the calculator. So, the solve variable can also be a variable that does not exist on the calculator, even if the equation is solved approximately, and not symbolically
When the solve function determines the answer, the answer is not stored in the solve variable. The solve function only returns the answer. So, the program must be written to save or use the answer.
In your program, when using x=0, y=0, system variable N as the solve variable, and not specifying a guess for N, the program returns {-sqrt(2), 0, sqrt(2)}. If the solve function tried to store the answer in system variable N, an error would occur, because a list cannot be stored in a real object. So, it is good that solve does not store the answer in the solve variable, and forces the user to specify how the answer is saved.
When a guess or range is not provided, solve tries to find all solutions. The current help for solve implies that this should be done with caution, and advises the user to supply a guess or define an interval. However, providing a guess is not fullproof. Sometimes the guess needs to be reasonnably close to the solution. Personally, when solving an equation that I am not familiar with, I find it helpful to graph the equation, and look for areas that can interfer with solve's ability to find a solution or to graphically see the solutions to the equation. The solve app makes charting a function with several known variables easy, but the solve app has it's own set of rules and issues. However, sometimes charting the equation does not help. In these cases, one needs to known the situations that can can mess up Newton's or bisection methods. Sometimes, it may be necessary to test these methods using excel.
For one equation that I used where a guess or range was not provided, solve returned no answer. When a guess was provided, solve returned one solution, and when a range was provided, solve returned two solutions. On another equation, not providing a guess and providing a guess did not work, but specifying a range did work. This might be the reason the solve help advises the user to supply a guess or define a range.
The solve function does not check the syntac of the equation. In one instance, I had an equation with an extra left parenthesis. I could not get the solve function to return an answer, until I removed the extra parenthesis.
The solve function will ignore any value that was previously stored in the solve variable. A value, list, or complex number stored in the solve variable will be ignored. So, there is no need to clear the solve variable.
Known variables
The known variables can be a system variable (A-Z), export variable, global variable, function parameter variable (x or y in your program), or list variable, such as uD(1). The known variables cannot be local function variables.
Answer variable
The answer variable can be a system variable A-Z (provided that solve does not return a complex number or list), export variable, global variable, local function variable, or list variable, such as uD(1). The answer variable cannot be a function parameter variable.