Solving a large equation
8 次查看(过去 30 天)
显示 更早的评论
I have a large equation of the form:
8.5567=10.75-158.34*y+2112.07*y^2-12211.07*y^3-29.44*x+2185.91*x*y-35690.08*x*y^2+187137.42*x*y^3+129.16*x^2-9697.93*x^2*y+173834.73*x^2*y^2-935832.82*x^2*y^3-174.03*x^3+13191.71*x^3*y-245488.55*x^3*y^2+1384550.57*x^3*y^3
For x ranging from 0.15 to 0.39 I want to develop the value(s) of y.
Any ideas on how to do this would be greatly appreciated.
Thank you.
0 个评论
回答(3 个)
Roger Stafford
2014-9-2
编辑:Roger Stafford
2014-9-2
You can use 'roots'. For each value of x you can compute the corresponding value of each of the four coefficients of the powers of y. For example the powers of y^3 can be collected to form a single coefficient which would be:
c3(x) = -12211.07+187137.42*x-935832.82*x^2+1384550.57*x^3
Use a for-loop:
x = linspace(0.15,0.39,n); % You choose n (= 25?)
y = zeros(n,3);
for k = 1:n
y(k,:) = roots([c3(x(k)),c2(x(k)),c1(x(k)),c0(x(k))]).'; % Get three y roots each trip
end
This gives you an n x 3 array of the corresponding possible values of y, some of which may be complex-valued, depending on the numbers you are using.
You may wish to reorder the rows in y you obtain this way in order to preserve continuity in the three branches. That would be an extra step.
0 个评论
MJTHDSN
2018-4-12
Dear Matlabers,
I have a similar question but a little bit confusing. Let`s assume we have 6 equations as below:
EQ1:a{{(L^2)*(Z^2)+(L^2)*(M^2)-2*L*(Z^2)+(Z^2)}}=(L^2)*(T^2)-2*L*(T^2)+ (T^2)-(2*L*T*B)+(T*B)+(B^2)
EQ2: b{{(L^2)*(Z^2)+(L^2)*(M^2)-2*L*(Z^2)+(Z^2)}}=(L^2)*(T^2)+(2*L*T*B)+(B^2)
EQ3: c{{(L^2)*(Z^2)+(L^2)*(M^2)-2*L*(Z^2)+(Z^2)}}=(T^2)+(2*T*B)+(B^2)
EQ4:d{{(L^2)*(Z^2)+(L^2)*(M^2)-2*L*(Z^2)+(Z^2)}}=(L^2)*(T^2)-2*L*(T^2)+ (T^2)-(2*L*T*B)-(T*B)+(B^2)
EQ5: e{{(L^2)*(Z^2)+(L^2)*(M^2)-2*L*(Z^2)+(Z^2)}}=(L^2)*(T^2)-(2*L*T*B)+(B^2)
EQ6: f{{(L^2)*(Z^2)+(L^2)*(M^2)-2*L*(Z^2)+(Z^2)}}=(T^2)-(2*T*B)+(B^2)
in the equations above a,b,c,d,e and f are the numerical known values (0.543 for example). So we have 6 equations with 5 unknowns as L, Z, M, T and B.
Can you please give me cues how to solve the equations to find these unknowns using MATLAB.
Best Regards,
5 个评论
Walter Roberson
2020-3-25
syms B L M T Z
Q = @(v) sym(v);
a = sqrt(Q(2)); b = Q(3); c = Q(-5); d = 1/Q(7); e = Q(11); f = sqrt(Q(13));
EQ1 = a*(((L^2)*(Z^2)+(L^2)*(M^2)-2*L*(Z^2)+(Z^2)))==(L^2)*(T^2)-2*L*(T^2)+ (T^2)-(2*L*T*B)+(T*B)+(B^2);
EQ2 = b*(((L^2)*(Z^2)+(L^2)*(M^2)-2*L*(Z^2)+(Z^2)))==(L^2)*(T^2)+(2*L*T*B)+(B^2);
EQ3 = c*(((L^2)*(Z^2)+(L^2)*(M^2)-2*L*(Z^2)+(Z^2)))==(T^2)+(2*T*B)+(B^2);
EQ4 = d*(((L^2)*(Z^2)+(L^2)*(M^2)-2*L*(Z^2)+(Z^2)))==(L^2)*(T^2)-2*L*(T^2)+ (T^2)-(2*L*T*B)-(T*B)+(B^2);
EQ5 = e*(((L^2)*(Z^2)+(L^2)*(M^2)-2*L*(Z^2)+(Z^2)))==(L^2)*(T^2)-(2*L*T*B)+(B^2);
EQ6 = f*(((L^2)*(Z^2)+(L^2)*(M^2)-2*L*(Z^2)+(Z^2)))==(T^2)-(2*T*B)+(B^2);
EQN = [EQ1, EQ2, EQ3, EQ4, EQ5, EQ6];
sol = vpasolve(EQN, [B L M T Z]);
temp = struct2cell(sol);
disp(vertcat(temp{:}));
The result turns out to be all-zero.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Algebra 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!