Message Boards Message Boards

0
|
213 Views
|
5 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Solve, Reduce, and other black arts

Posted 8 days ago

After working with Maple and Maxima for 15+ years, I'm working through the learning curve to add Mathematica to the arsenal. As part of the process, I'm porting very simple problems I assign to students from Maple and Maxima worksheets/notebooks to Mathematica (using Wolfroam 14.2).

This has largely been transparent, but this morning I ran into a 'solve' problem that puzzles me, since superficially its trivial.

First, I define a function (a variation of the logistic equation from classic population biology):

 h[N_] = r*N*(1 - (N/K)^\[Alpha])

All I want students to do next is solve the equation wrt N. In other words, under what conditions for N does h[N]==0. This is trivial, since by inspection the solutions are N=0, and N=K.

Tried the following as an obvious startiing point, but it fails completely.

Solve[h[N]==0,N]

So, after much fussing about, realized that Mathematica needs to know simething about \Alpha. Specifically, that is positive and real. So, after a bit of reading, ended up trying things like

 Reduce[N (1 - (N/K)^\[Alpha]) r == 0 && \[Alpha] > 
    0 && \[Alpha] \[Element] Reals && N \[Element] Reals, N]

and

 Solve[N (1 - (N/K)^\[Alpha]) r == 0, N, 
  Assumptions -> {\[Alpha] > 0, \[Alpha] \[Element] Reals}, 
  Domain -> Reals]

But these and all other attempts fail. Errors to the effect that 'this system cannot be solved with methods available to Reduce.' And so on. I tried multiple attempts with AIbots - like chatGPT using the Wolfram plugin -- but in the end, even they 'gave up', and said the solution would require 'manual intervention'.

So, other than the obvious question (how, in fact do I solve this equation, subject to the constraint that \Alpha>0 and is real, in Mathematica, such that N=0 and N=K are returned, why is Mathematica having trouble with this at all? Maple does it in a single Solve command, and Maxima does, after asking if \Alpha is integer or not? I'm simply curious as to why Mathematica is struggling with this simple expression, since the 'equations down the road' are far more compicated.

Many thanks in advance...

POSTED BY: Evan Cooch
5 Replies

The exponential function is not invertible on the complex domain. Solve has probably used one of its inverses to solve the equation. But this way it may have missed some solutions. For example, for this choice of parameter values, 0 and K are not the only solutions:

Clear[h, n, r, K, \[Alpha]];
h[n_] := r*n*(1 - (n/K)^\[Alpha]);
Block[{K = 1 + I, \[Alpha] = 2, r = 1},
 Reduce[h[n] == 0, n]]
% // N

The problem is not trivial in the complex domain.

To work in the real domain you must make it explicit:

h[n_] := r*n*(1 - (n/K)^\[Alpha])
Solve[h[n] == 0, n, Reals]

I personally try not to use N as a variable name, as it is a built-in function name.

POSTED BY: Gianluca Gorni

Evan,

I would try is like so:

h[n_] := r*n*(1 - (n/k)^\[Alpha]);
Solve[h[n] == 0, n, Assumptions -> {\[Alpha] > 0, k > 0}]

If positive parameters are really not appropriate, you can do what the warning message recommends:

Reduce[h[n] == 0, n, Reals]

It might not be the reason for the problems in this example, but a general rule is: Never use names starting with (or consisting of) a capital letter! E.g. N is a function, try:

?N

K also has some meaning:

?K
POSTED BY: Henrik Schachner

I'd avoid using system symbols. Not that it's a problem here, but it seems like inviting trouble. Also equations with arbitrary exponential forms also invite trouble. If you seek real solutions, best to have positive bases.

Solve[n (1 - (n/k)^\[Alpha]) r == 0 && \[Alpha] > 0 && n >= 0 && k > 0, n]
(*
{{n -> ConditionalExpression[0, k > 0 && \[Alpha] > 0]},
 {n -> ConditionalExpression[k, k > 0 && \[Alpha] > 0]}}
*)
POSTED BY: Michael Rogers
Posted 8 days ago

So, after starting over, and

 Solve[h[N] == 0, N]

does now seem to work (perhaps Remove["Global`*"] did the trick, but even though Mathematica did respond with

 {{N -> 0}, {N -> K}}

the solutions are accompanied by a 'notice':

 Inverse functions are being used by Solve, so some solutions may not  be found; use Reduce for complete solution information

Was wondering if there was a simple explanation for this 'notice'?

POSTED BY: Evan Cooch

Actually, 0 and K may not be the only solutions even in the real domain:

Clear[h, n, r, K, \[Alpha]];
h[n_] := r*n*(1 - (n/K)^\[Alpha]);
Block[{K = 1, \[Alpha] = 2, r = 1}, Solve[h[n] == 0, n]]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract