Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I want to get a positive solution "x" for the linear system Ax = b. Is there any function for this?

I did some research and I find a function called "lsq" under scilab, what this function is for?

Thank you.

share|improve this question
    
The Scilab Online Help website includes a section on the lsq function. –  Peter Phipps Nov 9 '12 at 21:46
add comment

1 Answer 1

As far as I know, lsq does not deal with linear inequalities such as $x\ge 0$. You can use the linear programming function karmarkar instead. The choice of target function does not matter much; it is natural to maximize $\sum x_i$. If no linear inequalities are provided, the routine automatically imposes $x\ge 0$.

The code below finds a solution to $5x_1-x_3=3$, $x_1-2x_2+3x_3=4$ subject to $x\ge 0$.

Aeq = [5 0 -1 ; 1  -2 3]
beq = [3 4]'
c = [-1 -1 -1]'
xopt = karmarkar(Aeq,beq,c)
print(%io(2),xopt)

returns

0.9102308
0.7818466
1.5511541

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.