taking too long to get a solution

Hi Everyone,
This code runs fine, i have defined values for everything except x and y. But it takes 4 - 5 hours. Is there a faster way to do this?
S=solve([C1*(A*x+B1*y^(1/N1))^-1 + C2*(A*x+B2*y^(1/N2))^-1 == 1, x/(y*N1)*(C1*(A*x+B1*y^(1/N1))^-1) + x/(y*N2)*(C2*(A*x+B2*y^(1/N2))^-1)==1],[x,y])

Answers (2)

Don’t use the Symbolic Math Toolbox. If you have the Optimization Toolbox, use the fsolve function:
[C1,A,B1,N1,C2,B2,N2] = deal(1,2,3,4,5,6,7); % Constants
% MAPPING: x = b(1), y = b(2)
Fn = @(b) [C1./(A*b(1)+B1*b(2).^(1/N1)) + C2./(A*b(1)+B2*b(2)^(1/N2)) - 1; b(1)./(b(2)*N1)*C1./(A*b(1)+B1*b(2).^(1/N1)) + b(1)./(b(2)*N2)*C2./(A*b(1)+B2*b(2)^(1/N2)) - 1];
B = fsolve(Fn, [1; 1]);
When I created values for the constants, it took fsolve about a second. Be sure to check the equations, since I recoded them to make them more efficient. I also substituted my ‘b’ vector for ‘x’ and ‘y’. See the documentation for fsolve for the coding of the function and other details.

Categories

Find more on Mathematics in Help Center and File Exchange

Asked:

on 27 Aug 2015

Answered:

on 21 Jun 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!