MATLAB: How to solve extra long equations with multiple unknowns

equationMATLABmultiple unknownsolve

Hi, I have two equations with 2 unknowns. In my case, the equations are too long with a number of transcendental functions. I tried Simplify command with other stricting strategy to solve but neither of them worked. How can I solve such Equations? Any hints/tips will be appreciated.
Here are my equations with unknown 'W' and 's':
A = (131072*29284206217013915^(1/2))/(625*(((6987459706243381*W – (6987459706243381*W – ((188416*(9223372036854775808*W – 5856841243402783)^2)/12869035935211193115234375 + (1184898369045330659387084111872*2^(1/2))/(87890625*((2305843009213693952*W + 17570523730208349)/W)^(1/2)) + 1343418817046756753408/87890625)/log(((2305843009213693952*W^2)/5856841243402783 + 127/25000)/W))/((5856841243402783*tanh((73786976294838206464*s)/5856841243402783)*exp(-exp(233/100 – (583378281331064569856*W)/146421031085069575)/10))/(9223372036854775808*s) + 1) + ((188416*(9223372036854775808*W – 5856841243402783)^2)/12869035935211193115234375 + (1184898369045330659387084111872*2^(1/2))/(87890625*((2305843009213693952*W + 17570523730208349)/W)^(1/2)) + 1343418817046756753408/87890625)/log(((2305843009213693952*W^2)/5856841243402783 + 127/25000)/W))*(191916973863822393344*tanh((73786976294838206464*s)/5856841243402783) + 604462909807314587353088*s*exp(exp(233/100 – (583378281331064569856*W)/146421031085069575)/10) + 48167231430905666015625*W*log(((2305843009213693952*W^2)/5856841243402783 + 127/25000)/W)*tanh((73786976294838206464*s)/5856841243402783)))/(log(((2305843009213693952*W^2)/5856841243402783 + 127/25000)/W)*(5856841243402783*tanh((73786976294838206464*s)/5856841243402783) + 9223372036854775808*s*exp(exp(233/100 – (583378281331064569856*W)/146421031085069575)/10))))^(1/2)) == sym('82.9367')
B = 4848604884312330996192171599799452960064720961461794373632/(390625*((30197372856938873356783865240544523007076102631740932096*W + 1196803464977447626879572441392246924444885789442048*log(2*(2*W + s)^(1/2) + 2*2^(1/2)*W^(1/4)*(W + s)^(1/4)) + 1196803464977447626879572441392246924444885789442048*log(1/((2*W + s)^(1/2) – 2^(1/2)*W^(1/4)*(W + s)^(1/4))) + 12207395342769963168946347226992069644318890998628352*log(coth((50000*s*pi)/127)) – ((31721688620111212543053501011329024*(9223372036854775808*W – 5856841243402783)^2)/501342689882353 + (80464336588145820923004586700794002638127030245202533672503105028096*W^(1/2))/(1953125*(576460752303423488*W + 4392630932552087)^(1/2)) + 66056980683050248153209450614638153187005796318183424)/(log(W) – log((2305843009213693952*W^2)/5856841243402783 + 127/25000)) – ((715913401141667049096758589128704*W + ((133952*(9223372036854775808*W – 5856841243402783)^2)/89296875 + (28614490977577140881519611179794734764726943744*W^(1/2))/(29296875*(576460752303423488*W + 4392630932552087)^(1/2)) + 1566065959909660640395860639744)/(log(W) – log((2305843009213693952*W^2)/5856841243402783 + 127/25000)))*(27153607276500459978752*s + 1112053888018253184))/s)*(227645271101905578581467981701973076307609129058304*W + 92026410225101700192114242347788464628541947904*log(2*(2*W + s)^(1/2) + 2*2^(1/2)*W^(1/4)*(W + s)^(1/4)) + 92026410225101700192114242347788464628541947904*log(1/((2*W + s)^(1/2) – 2^(1/2)*W^(1/4)*(W + s)^(1/4))) + 92026410225101679909704638696118040681290661888*log(coth((50000*s*pi)/127)) – 43872128685689108753488251272750948277693341237248/(5859375*s*(log(W) – log((2305843009213693952*W^2)/5856841243402783 + 127/25000))) – 15943838407882170125382859023155862270216286202583056384/(17578125*log(W) – 17578125*log((2305843009213693952*W^2)/5856841243402783 + 127/25000)) – (9396058564731152614103031140650616447679070208*W)/(5*s)))^(1/2)) == sym('37.6092')
This equations sometimes results in following:
struct with fields:
W: [0×1 sym]
s: [0×1 sym]
But these fields don't have any results.

Best Answer

  • You have two fairly complicated equations, in two unknowns. Why do you expect an analytical solution to exist at all? I'd have been utterly surprised if one did. It is better if you just subtract the constant right hand side, because now you can plot the surfaces.
    A = (131072*29284206217013915^(1/2))/(625*(((6987459706243381*W - (6987459706243381*W - ((188416*(9223372036854775808*W - 5856841243402783)^2)/12869035935211193115234375 + (1184898369045330659387084111872*2^(1/2))/(87890625*((2305843009213693952*W + 17570523730208349)/W)^(1/2)) + 1343418817046756753408/87890625)/log(((2305843009213693952*W^2)/5856841243402783 + 127/25000)/W))/((5856841243402783*tanh((73786976294838206464*s)/5856841243402783)*exp(-exp(233/100 - (583378281331064569856*W)/146421031085069575)/10))/(9223372036854775808*s) + 1) + ((188416*(9223372036854775808*W - 5856841243402783)^2)/12869035935211193115234375 + (1184898369045330659387084111872*2^(1/2))/(87890625*((2305843009213693952*W + 17570523730208349)/W)^(1/2)) + 1343418817046756753408/87890625)/log(((2305843009213693952*W^2)/5856841243402783 + 127/25000)/W))*(191916973863822393344*tanh((73786976294838206464*s)/5856841243402783) + 604462909807314587353088*s*exp(exp(233/100 - (583378281331064569856*W)/146421031085069575)/10) + 48167231430905666015625*W*log(((2305843009213693952*W^2)/5856841243402783 + 127/25000)/W)*tanh((73786976294838206464*s)/5856841243402783)))/(log(((2305843009213693952*W^2)/5856841243402783 + 127/25000)/W)*(5856841243402783*tanh((73786976294838206464*s)/5856841243402783) + 9223372036854775808*s*exp(exp(233/100 - (583378281331064569856*W)/146421031085069575)/10))))^(1/2)) - sym('82.9367');
    B = 4848604884312330996192171599799452960064720961461794373632/(390625*((30197372856938873356783865240544523007076102631740932096*W + 1196803464977447626879572441392246924444885789442048*log(2*(2*W + s)^(1/2) + 2*2^(1/2)*W^(1/4)*(W + s)^(1/4)) + 1196803464977447626879572441392246924444885789442048*log(1/((2*W + s)^(1/2) - 2^(1/2)*W^(1/4)*(W + s)^(1/4))) + 12207395342769963168946347226992069644318890998628352*log(coth((50000*s*pi)/127)) - ((31721688620111212543053501011329024*(9223372036854775808*W - 5856841243402783)^2)/501342689882353 + (80464336588145820923004586700794002638127030245202533672503105028096*W^(1/2))/(1953125*(576460752303423488*W + 4392630932552087)^(1/2)) + 66056980683050248153209450614638153187005796318183424)/(log(W) - log((2305843009213693952*W^2)/5856841243402783 + 127/25000)) - ((715913401141667049096758589128704*W + ((133952*(9223372036854775808*W - 5856841243402783)^2)/89296875 + (28614490977577140881519611179794734764726943744*W^(1/2))/(29296875*(576460752303423488*W + 4392630932552087)^(1/2)) + 1566065959909660640395860639744)/(log(W) - log((2305843009213693952*W^2)/5856841243402783 + 127/25000)))*(27153607276500459978752*s + 1112053888018253184))/s)*(227645271101905578581467981701973076307609129058304*W + 92026410225101700192114242347788464628541947904*log(2*(2*W + s)^(1/2) + 2*2^(1/2)*W^(1/4)*(W + s)^(1/4)) + 92026410225101700192114242347788464628541947904*log(1/((2*W + s)^(1/2) - 2^(1/2)*W^(1/4)*(W + s)^(1/4))) + 92026410225101679909704638696118040681290661888*log(coth((50000*s*pi)/127)) - 43872128685689108753488251272750948277693341237248/(5859375*s*(log(W) - log((2305843009213693952*W^2)/5856841243402783 + 127/25000))) - 15943838407882170125382859023155862270216286202583056384/(17578125*log(W) - 17578125*log((2305843009213693952*W^2)/5856841243402783 + 127/25000)) - (9396058564731152614103031140650616447679070208*W)/(5*s)))^(1/2)) - sym('37.6092');
    fA = matlabFunction(A);
    fB = matlabFunction(B);
    HA = fcontour(fA,[0,.00100,-.001,.001]);
    HA.LevelList = 0;
    HA.LineColor = 'r';
    hold on
    HB = fcontour(fB,[0,.00100,-.001,.001]);
    HB.LevelList = 0;
    HB.LineColor = 'g';
    legend('A','B')
    xlabel W
    ylabel s
    grid on
    That plot enables me to find the intersection of the two level lines, and thus the solution. Remember that a contour plot can act as a graphical version of a rootfinder.
    You CANNOT use solve though. You MUST use a numerical solver.
    Ws = vpasolve(A,B,W,s,[.0003 .0001])
    Ws =
    struct with fields:
    W: [1×1 sym]
    s: [1×1 sym]
    Ws.W
    ans =
    0.0003813215765050440174161487085986
    Ws.s
    ans =
    0.00012687605236583108888940489516916