<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, question on fsolve</title>
    <link>http://www.mapleprimes.com/questions/98111-Question-On-Fsolve</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Sat, 13 Jun 2026 18:47:06 GMT</lastBuildDate>
    <pubDate>Sat, 13 Jun 2026 18:47:06 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, question on fsolve</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, question on fsolve</title>
      <link>http://www.mapleprimes.com/questions/98111-Question-On-Fsolve</link>
    </image>
    <item>
      <title>More precise</title>
      <link>http://www.mapleprimes.com/questions/98111-Question-On-Fsolve?ref=Feed:MaplePrimes:question on fsolve:Comments#answer98113</link>
      <itunes:summary>&lt;p&gt;Cite from Maple 13 Help: If the fsolve command does not find any solutions, it returns the empty sequence (NULL) or returns unevaluated. This means that there are no solutions, or the fsolve command cannot find any solutions.&lt;/p&gt;
&lt;p&gt;See &lt;a href='http://www.maplesoft.com/support/help/search.aspx?term=fsolve,details' target='_new'&gt;?fsolve,details&lt;/a&gt; .&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Cite from Maple 13 Help: If the fsolve command does not find any solutions, it returns the empty sequence (NULL) or returns unevaluated. This means that there are no solutions, or the fsolve command cannot find any solutions.&lt;/p&gt;
&lt;p&gt;See &lt;a href='http://www.maplesoft.com/support/help/search.aspx?term=fsolve,details' target='_new'&gt;?fsolve,details&lt;/a&gt; .&lt;/p&gt;</description>
      <guid>98113</guid>
      <pubDate>Mon, 25 Oct 2010 17:44:46 Z</pubDate>
      <itunes:author>hirnyk</itunes:author>
      <author>hirnyk</author>
    </item>
    <item>
      <title>procedures are good for you</title>
      <link>http://www.mapleprimes.com/questions/98111-Question-On-Fsolve?ref=Feed:MaplePrimes:question on fsolve:Comments#answer98122</link>
      <itunes:summary>&lt;p&gt;You should be able to handle this in one of two ways. You can either test that the result is of a type (that a solution would take), or you can test whether the result is NULL or an unevaluated `fsolve` call.&lt;/p&gt;
&lt;pre&gt;result := fsolve(...);

if result = NULL or type(result, 'specfunc(anything,fsolve)' then
  no_solution_found := true;
end if;

# or, in the multivariate case,

if not type(result, set(symbol=complex(numeric))) then
  no_solution_found := true;
end if;
&lt;/pre&gt;
&lt;p&gt;Notice that if you are choosing to test whether the result has a given form then the type-check may depend on how you called fsolve. These next two should illustrate that. Note also that you can choose to test whether the numeric result is purely real (ie. of type &lt;strong&gt;numeric&lt;/strong&gt; which would be purely real instead of type &lt;strong&gt;complex(numeric)&lt;/strong&gt; which &lt;em&gt;might&lt;/em&gt; have nonzero imaginary part).&lt;/p&gt;
&lt;pre&gt;&amp;gt; result := fsolve( sin(5*x+3) , {x});
                      {x = 0.02831853072}

&amp;gt; type(result,set(symbol=numeric));
                              true

&amp;gt; result := fsolve( sin(5*x+3) , x);
                         0.02831853072

&amp;gt; type(result,numeric);
                              true
&lt;/pre&gt;
&lt;p&gt;One can see, that it's a bit easier to check whether the `fsolve` attempt failed. If you had success, then how you pick apart the result will depend on how you called fsolve, and perhaps on how many variables were involved or whether the input was a univariate polynomial (in which case multiple solutions may be returned). How you test for that, or how you pick apart the solution, will thus depend on the problem at hand.&lt;/p&gt;
&lt;p&gt;Now here is a related digression. You have realized that the result maybe a so-call unevaluated fsolve call, which is a fancy way of describing the situation that fsolve returns something that looks like the original call -- ie. a function call to `fsolve` itself.&lt;/p&gt;
&lt;p&gt;If you test this at the top-level, outside of a procedure, then Maple will try once again to evaluate that function call when you inspect it by passing it on to your test. You likely don't want that, since you don't want your code to waste time duplicating a non-fruitful computation.&lt;/p&gt;
&lt;p&gt;But if you instead perform the original fsolve call and the subsequent check &lt;em&gt;inside a procedure&lt;/em&gt;, where &lt;strong&gt;result&lt;/strong&gt; is a declared local variable, then any unevaluated fsolve function call will &lt;em&gt;not&lt;/em&gt; get re-evaluated when your pass it around for the test.&lt;/p&gt;
&lt;p&gt;Let's verify that claim, by simply counting how many times the argument to fsolve itself gets called. We'll use a procedure `f` as the thing to be solved-for, but the overall effect is the same even if the thing to be solved-for is an expression.&lt;/p&gt;
&lt;pre&gt;&amp;gt; restart:

&amp;gt; f:=proc(x)
&amp;gt;   global count;
&amp;gt;   count := count+1;
&amp;gt;   sin(5*x+3)-4;
&amp;gt; end proc:

# First let's do it inside a procedure.&lt;br&gt;&amp;nbsp;&lt;br&gt;&amp;gt; p:=proc(F)
&amp;gt;    global count;
&amp;gt;    local result;
&amp;gt;    result := fsolve(F);
&amp;gt;    printf("total number of f calls done: %a", count);
&amp;gt;    if type(result,numeric) then
&amp;gt;       print("root found");
&amp;gt;    else
&amp;gt;       print("no root found");
&amp;gt;    end if;
&amp;gt;    printf("total number of f calls done: %a", count);
&amp;gt; end proc:

&amp;gt; count := 0:
&amp;gt; p(f);

total number of f calls done: 828
                        "no root found"
total number of f calls done: 828
&lt;/pre&gt;
&lt;p&gt;Notice how the total number of calls to `f` did not increase due to calling `type` against the result&lt;/p&gt;
&lt;pre&gt;# Now, let's do it at the top-level, outiside if any procedure.&lt;br&gt;&lt;br&gt;&amp;gt; count := 0:
&amp;gt; result := fsolve(f);
                        result := fsolve(f)

&amp;gt; printf("total number of f calls done: %a", count);

total number of f calls done: 828

&amp;gt; if type(result,numeric) then
&amp;gt;    print("root found");
&amp;gt; else
&amp;gt;    print("no root found");
&amp;gt; end if;

                          "no root found"

&amp;gt; printf("total number of f calls done: %a", count);

total number of f calls done: 1656
&lt;/pre&gt;
&lt;p&gt;Look what's happened. The total count of calls to `f` has doubled, following the `type` check!&lt;/p&gt;
&lt;p&gt;The very act of passing the unevaluated fsolve call (assigned to `result`) to `type`() at the top-level causes it to get re-evaluated and thereby duplicates the entire unproductive attempt. But inside the procedure `p`, the variable `result` is a local variable and as such gets only one-level evaluation when passed into `type`(), and so does not cause a re-computation attempt.&lt;/p&gt;
&lt;p&gt;When done at the top-level, in the case that the computation failed and returned unevaluated, the mere act of checking it causes the failing computation to be needlessly redone. This can be quite an important distinction when one is concerned with efficiency or when the computation takes a very long time. The very same issue would arise when calling `int` to do symbolic integrals and then passing around an unevaluated `int` call, except that `int` may be safe from this effect due to its having remember tables to store prior results. But the issue can arise elsewhere, since not all Library routines which can return unevaluated have remember tables.&lt;/p&gt;
&lt;p&gt;This is one important reason why &lt;em&gt;programming&lt;/em&gt; in Maple (ie. writing and using procedures) is important.&lt;/p&gt;
&lt;p&gt;acer&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;You should be able to handle this in one of two ways. You can either test that the result is of a type (that a solution would take), or you can test whether the result is NULL or an unevaluated `fsolve` call.&lt;/p&gt;
&lt;pre&gt;result := fsolve(...);

if result = NULL or type(result, 'specfunc(anything,fsolve)' then
  no_solution_found := true;
end if;

# or, in the multivariate case,

if not type(result, set(symbol=complex(numeric))) then
  no_solution_found := true;
end if;
&lt;/pre&gt;
&lt;p&gt;Notice that if you are choosing to test whether the result has a given form then the type-check may depend on how you called fsolve. These next two should illustrate that. Note also that you can choose to test whether the numeric result is purely real (ie. of type &lt;strong&gt;numeric&lt;/strong&gt; which would be purely real instead of type &lt;strong&gt;complex(numeric)&lt;/strong&gt; which &lt;em&gt;might&lt;/em&gt; have nonzero imaginary part).&lt;/p&gt;
&lt;pre&gt;&amp;gt; result := fsolve( sin(5*x+3) , {x});
                      {x = 0.02831853072}

&amp;gt; type(result,set(symbol=numeric));
                              true

&amp;gt; result := fsolve( sin(5*x+3) , x);
                         0.02831853072

&amp;gt; type(result,numeric);
                              true
&lt;/pre&gt;
&lt;p&gt;One can see, that it's a bit easier to check whether the `fsolve` attempt failed. If you had success, then how you pick apart the result will depend on how you called fsolve, and perhaps on how many variables were involved or whether the input was a univariate polynomial (in which case multiple solutions may be returned). How you test for that, or how you pick apart the solution, will thus depend on the problem at hand.&lt;/p&gt;
&lt;p&gt;Now here is a related digression. You have realized that the result maybe a so-call unevaluated fsolve call, which is a fancy way of describing the situation that fsolve returns something that looks like the original call -- ie. a function call to `fsolve` itself.&lt;/p&gt;
&lt;p&gt;If you test this at the top-level, outside of a procedure, then Maple will try once again to evaluate that function call when you inspect it by passing it on to your test. You likely don't want that, since you don't want your code to waste time duplicating a non-fruitful computation.&lt;/p&gt;
&lt;p&gt;But if you instead perform the original fsolve call and the subsequent check &lt;em&gt;inside a procedure&lt;/em&gt;, where &lt;strong&gt;result&lt;/strong&gt; is a declared local variable, then any unevaluated fsolve function call will &lt;em&gt;not&lt;/em&gt; get re-evaluated when your pass it around for the test.&lt;/p&gt;
&lt;p&gt;Let's verify that claim, by simply counting how many times the argument to fsolve itself gets called. We'll use a procedure `f` as the thing to be solved-for, but the overall effect is the same even if the thing to be solved-for is an expression.&lt;/p&gt;
&lt;pre&gt;&amp;gt; restart:

&amp;gt; f:=proc(x)
&amp;gt;   global count;
&amp;gt;   count := count+1;
&amp;gt;   sin(5*x+3)-4;
&amp;gt; end proc:

# First let's do it inside a procedure.&lt;br&gt;&amp;nbsp;&lt;br&gt;&amp;gt; p:=proc(F)
&amp;gt;    global count;
&amp;gt;    local result;
&amp;gt;    result := fsolve(F);
&amp;gt;    printf("total number of f calls done: %a", count);
&amp;gt;    if type(result,numeric) then
&amp;gt;       print("root found");
&amp;gt;    else
&amp;gt;       print("no root found");
&amp;gt;    end if;
&amp;gt;    printf("total number of f calls done: %a", count);
&amp;gt; end proc:

&amp;gt; count := 0:
&amp;gt; p(f);

total number of f calls done: 828
                        "no root found"
total number of f calls done: 828
&lt;/pre&gt;
&lt;p&gt;Notice how the total number of calls to `f` did not increase due to calling `type` against the result&lt;/p&gt;
&lt;pre&gt;# Now, let's do it at the top-level, outiside if any procedure.&lt;br&gt;&lt;br&gt;&amp;gt; count := 0:
&amp;gt; result := fsolve(f);
                        result := fsolve(f)

&amp;gt; printf("total number of f calls done: %a", count);

total number of f calls done: 828

&amp;gt; if type(result,numeric) then
&amp;gt;    print("root found");
&amp;gt; else
&amp;gt;    print("no root found");
&amp;gt; end if;

                          "no root found"

&amp;gt; printf("total number of f calls done: %a", count);

total number of f calls done: 1656
&lt;/pre&gt;
&lt;p&gt;Look what's happened. The total count of calls to `f` has doubled, following the `type` check!&lt;/p&gt;
&lt;p&gt;The very act of passing the unevaluated fsolve call (assigned to `result`) to `type`() at the top-level causes it to get re-evaluated and thereby duplicates the entire unproductive attempt. But inside the procedure `p`, the variable `result` is a local variable and as such gets only one-level evaluation when passed into `type`(), and so does not cause a re-computation attempt.&lt;/p&gt;
&lt;p&gt;When done at the top-level, in the case that the computation failed and returned unevaluated, the mere act of checking it causes the failing computation to be needlessly redone. This can be quite an important distinction when one is concerned with efficiency or when the computation takes a very long time. The very same issue would arise when calling `int` to do symbolic integrals and then passing around an unevaluated `int` call, except that `int` may be safe from this effect due to its having remember tables to store prior results. But the issue can arise elsewhere, since not all Library routines which can return unevaluated have remember tables.&lt;/p&gt;
&lt;p&gt;This is one important reason why &lt;em&gt;programming&lt;/em&gt; in Maple (ie. writing and using procedures) is important.&lt;/p&gt;
&lt;p&gt;acer&lt;/p&gt;</description>
      <guid>98122</guid>
      <pubDate>Mon, 25 Oct 2010 19:26:25 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
    <item>
      <title>catchig fsolve output</title>
      <link>http://www.mapleprimes.com/questions/98111-Question-On-Fsolve?ref=Feed:MaplePrimes:question on fsolve:Comments#comment98119</link>
      <itunes:summary>&lt;p&gt;In that case, I assume this is a good solution to handle that solution has been found by fsolve:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If we have this equation:&lt;/p&gt;
&lt;p&gt;eqn1 := f1(t)=f2(t)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Let &amp;nbsp;the output of fsolve be tmp1&lt;/p&gt;
&lt;p&gt;tmp1 := fsolve(eqn1, t = 0 .. 1)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;to catch that solution has been found:&lt;/p&gt;
&lt;p&gt;if `and`(tmp1&amp;lt;&amp;gt;NULL,type(tmp1,float)) then ... end if&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What is your opinion?&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Zoltan&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;In that case, I assume this is a good solution to handle that solution has been found by fsolve:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If we have this equation:&lt;/p&gt;
&lt;p&gt;eqn1 := f1(t)=f2(t)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Let &amp;nbsp;the output of fsolve be tmp1&lt;/p&gt;
&lt;p&gt;tmp1 := fsolve(eqn1, t = 0 .. 1)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;to catch that solution has been found:&lt;/p&gt;
&lt;p&gt;if `and`(tmp1&amp;lt;&amp;gt;NULL,type(tmp1,float)) then ... end if&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What is your opinion?&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Zoltan&lt;/p&gt;</description>
      <guid>98119</guid>
      <pubDate>Mon, 25 Oct 2010 18:42:12 Z</pubDate>
      <itunes:author>zfaigl</itunes:author>
      <author>zfaigl</author>
    </item>
    <item>
      <title>A good idea, but...</title>
      <link>http://www.mapleprimes.com/questions/98111-Question-On-Fsolve?ref=Feed:MaplePrimes:question on fsolve:Comments#comment98120</link>
      <itunes:summary>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/questions/98111-Question-On-Fsolve#comment98119"&gt;@zfaigl&lt;/a&gt; There is a chance that the fsolve command&amp;nbsp; produces a few solutions. For example, see &lt;a href="/view.aspx?sf=98120/311900/few.mw"&gt;few.mw&lt;/a&gt;&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/questions/98111-Question-On-Fsolve#comment98119"&gt;@zfaigl&lt;/a&gt; There is a chance that the fsolve command&amp;nbsp; produces a few solutions. For example, see &lt;a href="/view.aspx?sf=98120/311900/few.mw"&gt;few.mw&lt;/a&gt;&lt;/p&gt;</description>
      <guid>98120</guid>
      <pubDate>Mon, 25 Oct 2010 19:04:39 Z</pubDate>
      <itunes:author>hirnyk</itunes:author>
      <author>hirnyk</author>
    </item>
    <item>
      <title>RE: Procedures are good to use</title>
      <link>http://www.mapleprimes.com/questions/98111-Question-On-Fsolve?ref=Feed:MaplePrimes:question on fsolve:Comments#comment98154</link>
      <itunes:summary>&lt;p&gt;Thank you Acer! I learnt again something on Maple. Zoltan&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Thank you Acer! I learnt again something on Maple. Zoltan&lt;/p&gt;</description>
      <guid>98154</guid>
      <pubDate>Tue, 26 Oct 2010 14:04:30 Z</pubDate>
      <itunes:author>zfaigl</itunes:author>
      <author>zfaigl</author>
    </item>
  </channel>
</rss>