Hello,
I am pretty new to Octave and I need some help figuring out a code.
I wrote this code:
function y = f(x)
y = zeros(2,1);
P1=100000;
nu1=.8333;
gamma=1.4;
mu2=(gamma-1)/(gamma+1);
q=1200e3;
E=2*q*mu2/(P1*nu1);
a = 1 + x(1)^2/(P1*nu1)*(1-x(2));
b = -mu2 + (1 - mu2^2 + E)/(x(2) - mu2);
c = -x(1)^2/(P1*nu1);
d = -(1 - mu2^2 + E)/((x(2) - mu2)^2);
y(1) = a - b ;
y(2) = c - d ;
endfunction
And then used:
[x, fval, info] = fsolve (@f, [1;2])
to solve for x(1) and x(2) when a = b and c = d (where c and d are respective derivatives of a and b).
I know that the x values are supposed to be x(1)=1000 and x(2)=0.5, as I previously solved this system by hand. However, fsolve gives me:
x =
-73.3172
9.6259
Is there anything I can do to improve he code so that it gives the correct answers, or something close?