# Thread: Solving Nonlinear Equation in Matlab

1. ## Solving Nonlinear Equation in Matlab

I need to solve for B and n in for these two equations using the gamma
function.
175=n*gamma(1+1/B)
25=n*sqrt(gamma(1+2/B)-(gamma(1+1/B))^2)

This is the code I have formulated but my professor informed me I did
something wrong and am getting the incorrect answer. The B variable
should probably be around 1. Any help would be appreciated.

clear all; close all; clc;

eq1='175=x*gamma(1+(1/y))';
eq2='25=x*sqrt(gamma(1+(2/y))-(gamma(1+(1/y)))^2)';
vars='x,y'
W=solve(eq1,eq2,vars);

n=eval(W.x)
B=eval(W.y)

2. Originally Posted by aggie09
I need to solve for B and n in for these two equations using the gamma
function.
175=n*gamma(1+1/B)
25=n*sqrt(gamma(1+2/B)-(gamma(1+1/B))^2)

This is the code I have formulated but my professor informed me I did
something wrong and am getting the incorrect answer. The B variable
should probably be around 1. Any help would be appreciated.

clear all; close all; clc;

eq1='175=x*gamma(1+(1/y))';
eq2='25=x*sqrt(gamma(1+(2/y))-(gamma(1+(1/y)))^2)';
vars='x,y'
W=solve(eq1,eq2,vars);

n=eval(W.x)
B=eval(W.y)
>help solve

will tell you why you do not have a symbolic solution. "solve" solves algebraic equations, if it cant solve them it returns a numeric solution which is what you have.

There appears to be more than one solution, there is another with B~= +8.330

CB