# How to use algebra_solver

Hello,

I am trying to use algebra_solver, but couldn’t get the code right. Any help on the issue is greatly appreciated!

Here is my function and then try to solve it.

``````  vector algebra_system(vector effpi,vector theta, real[] x_r, int[] x_i){
vector rslt;
rslt=(theta+theta/effpi+theta/effpi^2) - (theta+theta*effpi);
return rslt;
}
real desrfunc (real effpi,
real toxpi,
vector param,
real[] x_r,
int[] x_i){
real a = param;
real b = param;
real c = param;

real rhop;
real rhoq;
real desr;

vector effpi0;
real toxpi0;

vector effpi_guess=[0.5]';
vector param_ex=append_row(append_row(param, -toxpi/(effpi-1)), toxpi/(effpi-1));

effpi0 = algebra_solver(algebra_system, effpi_guess, param_ex, x_r, x_i);
toxpi0 = a + b/effpi0 + c/effpi0^2;

rhop=sqrt(effpi0^2+toxpi0^2);
rhoq=sqrt(effpi^2+toxpi^2);
desr =(rhop>0)? rhoq/rhop-1: -500;
return desr;
}
``````

The algebra solver needs to know that `x_r` and `x_i` are data. You must mark them in the function signature

``````real desrfunc (real effpi,
real toxpi,
vector param,
data real[] x_r,
data int[] x_i){
``````
1 Like

This solves the problem! Thank you!