I am trying to obtain a numerical answer for a non linear system with 3 equations and 3 unknowns. When running the code, I receive:
Warning: Trust-region-dogleg algorithm of FSOLVE cannot handle non-square systems; using Levenberg-Marquardt algorithminstead. > In fsolve (line 287) In RegimeTwo (line 60) Equation solved.fsolve completed because the vector of function values is near zeroas measured by the selected value of the function tolerance, andthe problem appears regular as measured by the gradient.<stopping criteria details>Equation solved. The sum of squared function values, r = 1.832713e-25, is lessthan sqrt(options.TolFun) = 1.000000e-03. The relative norm of the gradient ofr, 3.027138e-14, is less than 1e-4*options.TolFun = 1.000000e-10.Optimization Metric Optionsrelative norm(grad r) = 3.03e-14 1e-4*TolFun = 1e-10 (selected)r = 1.83e-25 sqrt(TolFun) = 1.0e-03 (selected)
My code:
opts = optimset('fsolve'); opts = optimset(opts,'Maxiter',700,'Tolx',1e-6,'tolfun',1e-6); xx = [0 0 0];nle = fsolve(Switch,xx,opts, lambda,row, mu, mu_one, a, b, c, r, gamma, A, sigma_one, beta1,delta1);OP = nle(1,1); EC = nle(1,2); OC = nle(1,3);
My function:
function [m, VM, SP] = Switch(h,lambda,row, mu, mu_one, a, b, c, r, gamma, A, sigma_one, beta1,delta1) OP = h(1); EC = h(2); OC = h(3); pi = (lambda+row-mu)/((row+lambda-mu_one)*(row-mu)); m = -OC+((1/(r*b*gamma))*(pi*row*OP-c-r*a))^(1/(gamma-1)) ; A_hat= (-lambda*A)/ (((sigma_one^2)/2)*beta1*(beta1-1)+(mu_one*beta1)-(row+lambda)) ; VM = A_hat*(OP^beta1) + EC*(OP^delta1)- (pi*OC*OP)+((c*OC+r*(a*OC+b*(OC^gamma)))/row); SP = beta1*A_hat*(OP^(beta1-1)) + delta1*EC*(OP^(delta1-1))- (pi*OC);
Any ideas where I am going wrong?
Best Answer