I’m a newbie in CVX. I tried to solve the problem of a subtraction of two convex functions using the Taylor expansion and CCCP algorithms.

Before that, I wrote a piece of code that was simple and similar to the problem:

```
%%The objective function is x^4-x^2
%%The minimize is -0.25
% x=-5:0.0001:5;
% y=x.^4-x.^2;
% plot(x,y)
%%main
x0 = 5;
jj = 1;
while (1)
cvx_begin quiet;
variable x(2,1);
g = (x.^4-(x0.^2+2.*x0.*(x-x0)));
minimize g;
cvx_end;
f1 = x^4-x^2;
x0 =x;
cvx_begin quiet;
variable x;
g = (x^4-(x0^2+2*x0*(x-x0)));
minimize g;
cvx_end;
f2 = x^4-x^2;
J(jj)=jj;
F2(jj)=f2;
jj=jj+1;
if(abs(f1-f2)<=0.001) % Set the accuracy threshold
break
end
end
x
f2
plot(J,F2)
```

Output：

```
x =
0.7128
f2 =
-0.2499
```

This is good, but I had a problem expanding x0 and x to (1,2).

```
x0 = [5;5]; %Modification
jj = 1;
while (1)
cvx_begin quiet;
variable x(2,1); %Modification
g = (x.^4-(x0.^2+2.*x0.*(x-x0)));
minimize g;
cvx_end;
f1 = x^4-x^2;
x0 =x;
cvx_begin quiet;
variable x(2,1); %Modification
g = (x^4-(x0^2+2*x0*(x-x0)));
minimize g;
cvx_end;
f2 = x^4-x^2;
J(jj)=jj;
F2(jj)=f2;
jj=jj+1;
if(abs(f1-f2)<=0.001) % Set the accuracy threshold
break
end
end
```

**“Your objective function is not a scalar.”**

Thank you for your help!