x1=0.2232585;x2=0.2232585;iteration=0;while true iteration=iteration+1; syms x1s x2s t func=(x2s-x1s^2)^2+(1-x1s)^2; dif_x1=diff(func,x1s); dif_x2=diff(func,x2s); grad_x1_temp=vpa(subs(dif_x1,x1)); grad_x1=vpa(subs(grad_x1_temp,x2)); grad_x2_temp=vpa(subs(dif_x2,x2)); grad_x2=vpa(subs(grad_x2_temp,x1)); tx1_temp=subs(dif_x1,x1-grad_x1*t); tx1=subs(tx1_temp,x2s,x2-grad_x2*t); tx2_temp=subs(dif_x2,x2s,x2-grad_x2*t); tx2=subs(tx2_temp,x1s,x1-grad_x1*t); eqn=tx1*grad_x1+tx2*grad_x2; a=solve(eqn,t,'Real',true); val_temp=vpa(subs(func,x1s,x1)); val=vpa(subs(val_temp,x2s,x2)); x1=x1-grad_x1*a; x2=x2-grad_x2*a; val_temp_end=vpa(subs(func,x1s,x1)); val_end=vpa(subs(val_temp_end,x2s,x2)); if(val_end>val) break; end enditeration
Error using symengine
Array sizes must match.
Error in sym/privBinaryOp (line 1013)
Csym = mupadmex(op,args{1}.s,
args{2}.s, varargin{:});
Error in – (line 7)
X = privBinaryOp(A, B,
'symobj::zipWithImplicitExpansion',
'_subtract');
Error in THE5 (line 26)
tx1_temp=subs(dif_x1,x1-grad_x1*t);
I keep getting these errors anyone has a clue?
Best Answer