To explain the appearance of an imaginary unit in the algebraic form of a record

20 Views Asked by At

In my code, I am looking for an algebraic expression for the maximum point. There is an imaginary unit in it, although when substituting numerical variables, I see that the imaginary part is not there. Does this mean that I can somehow simplify the algebraic expression by excluding the imaginary unit from it? The operation of taking the real part is not proposed, since it is necessary to get an expression where there will be no imaginary unit

clear all; close all; clc;
syms alpha x d a0 a2 a4

f  = @(alpha) a0 + a2*alpha^2 + a4*alpha^4;

% Variant 1:
% U = f(alpha + d)*0.7;

% Variant 2:
U = f(alpha + d)*0.7 + f(alpha - d)*0.3;

%% Find extrema:
eqn = diff(U, alpha) == 0;
S = solve(eqn, alpha, "MaxDegree", 3);
S = simplify(S, 'Steps', 100);
d = 0.25;
a0 = 1;
a1 = 0;
a2 = -1.4;
a3 = 0;
a4 = 0.96;

Sx = double(subs(S));

alpha = Sx;
Sy = double(subs(U));

alpha = -3:1/100:3;
U = double(subs(U));

figure;
hold on;
plot(alpha, U,'k');
grid on;
plot(Sx, Sy, '.');

xlabel('alpha');
ylabel('U', 'rotation', 0);
axis square
ylim([0.5 1.5])
grid minor

Here is an expression where the imaginary part is present, but when substituting values into which it disappears

s = -(150*a4*(((625*a2^3 + 9450*a2^2*a4*d^2 + 47628*a2*a4^2*d^4 + 95256*a4^3*d^6)/(135000*a4^3))^(1/2) + (42*d^3)/125)^(2/3) - 25*a2 + 3^(1/2)*a2*25i - 126*a4*d^2 + 3^(1/2)*a4*(((625*a2^3 + 9450*a2^2*a4*d^2 + 47628*a2*a4^2*d^4 + 95256*a4^3*d^6)/(135000*a4^3))^(1/2) + (42*d^3)/125)^(2/3)*150i + 120*a4*d*(((625*a2^3 + 9450*a2^2*a4*d^2 + 47628*a2*a4^2*d^4 + 95256*a4^3*d^6)/(135000*a4^3))^(1/2) + (42*d^3)/125)^(1/3) + 3^(1/2)*a4*d^2*126i)/(300*a4*(((625*a2^3 + 9450*a2^2*a4*d^2 + 47628*a2*a4^2*d^4 + 95256*a4^3*d^6)/(135000*a4^3))^(1/2) + (42*d^3)/125)^(1/3))

I noticed that the imaginary unit is missing when using Option 1, but appears when using option 2. But how can this be explained and is it possible to get rid of it? enter image description here