Jamgreen
Jamgreen

Reputation: 11039

Positive solutions with fsolve in Maple

In Maple I use

solve(abs(-5.58 * L^(-1.88)) = 3, L);

and I get the results

L = 1.39 or L = -1.39

but if I use

fsolve(abs(-5.58 * L^(-1.88)) = 3, L);

I only get the result

L = -1.39

How can I make sure I get the positive result using fsolve?

Upvotes: 1

Views: 2693

Answers (3)

You can tell Maple to assume your variable in your expression is positive or any other kind of similar assumption. Here is one way to do it.

eq:=abs(-5.58*L^(-1.88)) assuming L>0;

Then ask Maple to solve it by fsolve, it will automatically look for only positive solutions.

fsolve(eq = 3, L)

I received this result from Maple (2019).

1.391098714

Upvotes: 0

Carl Love
Carl Love

Reputation: 1471

I'd avoid the avoid option. You can specify a range in which you want the solutions to fall, like this:

fsolve(abs(-5.58 * L^(-1.88)) = 3, L= 0..infinity);

Upvotes: 1

Lutz Lehmann
Lutz Lehmann

Reputation: 25972

https://www.maplesoft.com/support/help/maple/view.aspx?path=fsolve : "For a general equation or system of equations, the fsolve command computes a single real root. "

https://www.maplesoft.com/support/help/maple/view.aspx?path=fsolve%2fdetails : "Using the avoid option to find additional solutions"

S1:=fsolve(abs(-5.58 * L^(-1.88)) = 3, L );
S2:=fsolve(abs(-5.58 * L^(-1.88)) = 3, L, avoid = { S1 });

etc.

Upvotes: 0

Related Questions