# How to solve a transcendental equation?

2 views (last 30 days)
Ahsan Noor on 16 Jan 2020
Commented: John D'Errico on 22 Jan 2020
epsd=1;
epm=-1.0169 - 0.0250i;
zeta=-134-0.016i;
sg=sqrt(k^2-epsm);
ac=sqrt(k^2-epsd);
ga=sqrt(k^2-zeta);
%and the actual equation solved for 'k' is the follwoing:
k^2*(epsd-epsm)=ga*(al*epsm+sg*epsd)
%The equation has complex roots.

#### 1 Comment

John D'Errico on 22 Jan 2020
How is this transcendental? NOT.
By the way, a big problem in your code is you never defined epsm. You did define epm, which I assume is supposed to be the same thing. But then you try to use epsm.

Guru Mohanty on 22 Jan 2020
Hi, I understand you are trying to solve this equation having complex roots. You can solve the equation using solvefunction. Here is the code for it.
clc;
clear all;
syms k
epsd=1;
epm=-1.0169 - 0.0250i;
zeta=-134-0.016i;
sg=sqrt(k^2-epsm);
ac=sqrt(k^2-epsd);
ga=sqrt(k^2-zeta);
% and the actual equation solved for 'k' is the follwoing:
eqn = k^2*(epsd-epsm) == ga*(ac*epsm+sg*epsd);
%The equation has complex roots.
Sol = double(solve(eqn,k));
disp(Sol);

Walter Roberson on 22 Jan 2020
It is odd that vpasolve() returns an empty solution.
Guru Mohanty on 22 Jan 2020
I have checked with vpasolve and it is returning the same solution. You may try it using the following code.
clc;
clear all;
syms k
epsd=1;
epsm=-1.0169 - 0.0250i;
zeta=-134-0.016i;
sg=sqrt(k^2-epsm);
ac=sqrt(k^2-epsd);
ga=sqrt(k^2-zeta);
% and the actual equation solved for 'k' is the follwoing:
eqn = k^2*(epsd-epsm) == ga*(ac*epsm+sg*epsd);
%The equation has complex roots.
Sol = double(solve(eqn,k));
Sol1=double(vpasolve(eqn,k));
disp(Sol);
disp(Sol1);
Walter Roberson on 22 Jan 2020
Notice that the original code defines epsd and epm but not epsm, but uses epsm anyhow.
It just so happens that epsm is a function in the Mapping Toolbox that returns a value of 1e-6 .
When that (accidental) value is used in eqn, solve() can find four roots for the equation, but vpasolve() returns empty.
eqn =
(9007190247541737*k^2)/9007199254740992 == (k^2 + 134 + 2i/125)^(1/2)*((k^2 - 1)^(1/2)/1000000 + (k^2 - 1/1000000)^(1/2))
>> solve(eqn)
ans =
-(4*root(z^8 + z^6*(834454315777359667686173382578062569804530196775819264995357092773326925608159487/358138990351727082983582815083491551894474553273290039871750000 + 348727176742777174630250231036071447379804163125721955440400056568445403136i/1253486466231044790442539852792220431630660936456515139551125) + z^4*(391359845386070448888706838714665986023487930089577485026236049546130268088207431035018827349227/5013945864924179161770159411168881726522643745826060558204500000000000 + 365074490565570817424189483780559028445600816138306420570226898955525860019295613878272i/19585726034860074850664685199878444244229077132133049055486328125) + z^2*(388438881466780657720765702614211601147238780002224632671430663479495981379013233177116409/2506972932462089580885079705584440863261321872913030279102250000000000000000 + 11365997441581558821082008143008366080734161299451741824482885801329342805966848i/306026969294688669541635706248100691316079330189578891491973876953125) + (794444088335024803982924562035202394153874285989604449373894552359019645159961116409/10027891729848358323540318822337763453045287491652121116409000000000000000000000000 + 12827783001197039242204012145810813792023975258553917324748232056635392i/683095913604215780226865415732367614544819933458881454223155975341796875), z, 5)^2 + 1/250000)^(1/2)/2
(4*root(z^8 + z^6*(834454315777359667686173382578062569804530196775819264995357092773326925608159487/358138990351727082983582815083491551894474553273290039871750000 + 348727176742777174630250231036071447379804163125721955440400056568445403136i/1253486466231044790442539852792220431630660936456515139551125) + z^4*(391359845386070448888706838714665986023487930089577485026236049546130268088207431035018827349227/5013945864924179161770159411168881726522643745826060558204500000000000 + 365074490565570817424189483780559028445600816138306420570226898955525860019295613878272i/19585726034860074850664685199878444244229077132133049055486328125) + z^2*(388438881466780657720765702614211601147238780002224632671430663479495981379013233177116409/2506972932462089580885079705584440863261321872913030279102250000000000000000 + 11365997441581558821082008143008366080734161299451741824482885801329342805966848i/306026969294688669541635706248100691316079330189578891491973876953125) + (794444088335024803982924562035202394153874285989604449373894552359019645159961116409/10027891729848358323540318822337763453045287491652121116409000000000000000000000000 + 12827783001197039242204012145810813792023975258553917324748232056635392i/683095913604215780226865415732367614544819933458881454223155975341796875), z, 5)^2 + 1/250000)^(1/2)/2
-(4*root(z^8 + z^6*(834454315777359667686173382578062569804530196775819264995357092773326925608159487/358138990351727082983582815083491551894474553273290039871750000 + 348727176742777174630250231036071447379804163125721955440400056568445403136i/1253486466231044790442539852792220431630660936456515139551125) + z^4*(391359845386070448888706838714665986023487930089577485026236049546130268088207431035018827349227/5013945864924179161770159411168881726522643745826060558204500000000000 + 365074490565570817424189483780559028445600816138306420570226898955525860019295613878272i/19585726034860074850664685199878444244229077132133049055486328125) + z^2*(388438881466780657720765702614211601147238780002224632671430663479495981379013233177116409/2506972932462089580885079705584440863261321872913030279102250000000000000000 + 11365997441581558821082008143008366080734161299451741824482885801329342805966848i/306026969294688669541635706248100691316079330189578891491973876953125) + (794444088335024803982924562035202394153874285989604449373894552359019645159961116409/10027891729848358323540318822337763453045287491652121116409000000000000000000000000 + 12827783001197039242204012145810813792023975258553917324748232056635392i/683095913604215780226865415732367614544819933458881454223155975341796875), z, 6)^2 + 1/250000)^(1/2)/2
(4*root(z^8 + z^6*(834454315777359667686173382578062569804530196775819264995357092773326925608159487/358138990351727082983582815083491551894474553273290039871750000 + 348727176742777174630250231036071447379804163125721955440400056568445403136i/1253486466231044790442539852792220431630660936456515139551125) + z^4*(391359845386070448888706838714665986023487930089577485026236049546130268088207431035018827349227/5013945864924179161770159411168881726522643745826060558204500000000000 + 365074490565570817424189483780559028445600816138306420570226898955525860019295613878272i/19585726034860074850664685199878444244229077132133049055486328125) + z^2*(388438881466780657720765702614211601147238780002224632671430663479495981379013233177116409/2506972932462089580885079705584440863261321872913030279102250000000000000000 + 11365997441581558821082008143008366080734161299451741824482885801329342805966848i/306026969294688669541635706248100691316079330189578891491973876953125) + (794444088335024803982924562035202394153874285989604449373894552359019645159961116409/10027891729848358323540318822337763453045287491652121116409000000000000000000000000 + 12827783001197039242204012145810813792023975258553917324748232056635392i/683095913604215780226865415732367614544819933458881454223155975341796875), z, 6)^2 + 1/250000)^(1/2)/2
>> vpasolve(eqn)
ans =
Empty sym: 0-by-1