I am trying to find a reciprocal function to the binary shannon entropy $H_2(p)$ (chosing the branch were $p>1/2$).
I used a method based on solving the differential equation that the reciprocal follows but it was a little too long for what i need to do.
Thus, I want to do a polynomial approximation of the shannon entropy and then find the reciprocal of this polynomial function.
But mathematica answers me things I don't understand.
Here is my code :
H2[x_] :=
If[x != 0, If[x != 1, (-x)*Log[x] - (1 - x)*Log[1 - x], 0], 0];
tableauValeursH2 = Table[{x, H2[x]}, {x, 1/2, 1, 0.001}];
ff[y_] = Fit[tableauValeursH2, Table[y^k, {k, 0, 10}], y]
Solve[y == ff[x], x]
And mathematica answers me :
{{x -> Root[
502925249036334454715336778553984003440864263790494070 +
79507334695638259109060376450677753198917644793560 y -
7228015973937440731974941433834202407604387494117592200 #1 +
46469470965681832229663230673595151067237874818752782840 #1^2 -
176009396354156927628824727628578542386502238219708082250 #1^3 \
+ 434953160110610020035094377442281900757943807833308766200 #1^4 -
732785165581324716157030456066865775762616415498186198190 #1^5 \
+ 852422521044952102836379759843676923790865671573802051255 #1^6 -
676099528944398287173100625127955582322701524364225111800 #1^7 \
+ 349947592110433543619114105190630648009305990596089919920 #1^8 -
106747371466686462957887174434503958626612109573992670672 #1^9 \
+ 14573808550521644768419974300540238469473534471735953168 #1^10 &,
1]}, {x ->
Root[502925249036334454715336778553984003440864263790494070 +
79507334695638259109060376450677753198917644793560 y -
7228015973937440731974941433834202407604387494117592200 #1 +
46469470965681832229663230673595151067237874818752782840 #1^2 -
176009396354156927628824727628578542386502238219708082250 #1^3 \
+ 434953160110610020035094377442281900757943807833308766200 #1^4 -
732785165581324716157030456066865775762616415498186198190 #1^5 \
+ 852422521044952102836379759843676923790865671573802051255 #1^6 -
676099528944398287173100625127955582322701524364225111800 #1^7 \
+ 349947592110433543619114105190630648009305990596089919920 #1^8 -
106747371466686462957887174434503958626612109573992670672 #1^9 \
+ 14573808550521644768419974300540238469473534471735953168 #1^10 &,
2]}, {x ->
Root[502925249036334454715336778553984003440864263790494070 +
79507334695638259109060376450677753198917644793560 y -
7228015973937440731974941433834202407604387494117592200 #1 +
46469470965681832229663230673595151067237874818752782840 #1^2 -
176009396354156927628824727628578542386502238219708082250 #1^3 \
+ 434953160110610020035094377442281900757943807833308766200 #1^4 -
732785165581324716157030456066865775762616415498186198190 #1^5 \
+ 852422521044952102836379759843676923790865671573802051255 #1^6 -
676099528944398287173100625127955582322701524364225111800 #1^7 \
+ 349947592110433543619114105190630648009305990596089919920 #1^8 -
106747371466686462957887174434503958626612109573992670672 #1^9 \
+ 14573808550521644768419974300540238469473534471735953168 #1^10 &,
3]}, {x ->
Root[502925249036334454715336778553984003440864263790494070 +
79507334695638259109060376450677753198917644793560 y -
7228015973937440731974941433834202407604387494117592200 #1 +
46469470965681832229663230673595151067237874818752782840 #1^2 -
176009396354156927628824727628578542386502238219708082250 #1^3 \
+ 434953160110610020035094377442281900757943807833308766200 #1^4 -
732785165581324716157030456066865775762616415498186198190 #1^5 \
+ 852422521044952102836379759843676923790865671573802051255 #1^6 -
676099528944398287173100625127955582322701524364225111800 #1^7 \
+ 349947592110433543619114105190630648009305990596089919920 #1^8 -
106747371466686462957887174434503958626612109573992670672 #1^9 \
+ 14573808550521644768419974300540238469473534471735953168 #1^10 &,
4]}, {x ->
Root[502925249036334454715336778553984003440864263790494070 +
79507334695638259109060376450677753198917644793560 y -
7228015973937440731974941433834202407604387494117592200 #1 +
46469470965681832229663230673595151067237874818752782840 #1^2 -
176009396354156927628824727628578542386502238219708082250 #1^3 \
+ 434953160110610020035094377442281900757943807833308766200 #1^4 -
732785165581324716157030456066865775762616415498186198190 #1^5 \
+ 852422521044952102836379759843676923790865671573802051255 #1^6 -
676099528944398287173100625127955582322701524364225111800 #1^7 \
+ 349947592110433543619114105190630648009305990596089919920 #1^8 -
106747371466686462957887174434503958626612109573992670672 #1^9 \
+ 14573808550521644768419974300540238469473534471735953168 #1^10 &,
5]}, {x ->
Root[502925249036334454715336778553984003440864263790494070 +
79507334695638259109060376450677753198917644793560 y -
7228015973937440731974941433834202407604387494117592200 #1 +
46469470965681832229663230673595151067237874818752782840 #1^2 -
176009396354156927628824727628578542386502238219708082250 #1^3 \
+ 434953160110610020035094377442281900757943807833308766200 #1^4 -
732785165581324716157030456066865775762616415498186198190 #1^5 \
+ 852422521044952102836379759843676923790865671573802051255 #1^6 -
676099528944398287173100625127955582322701524364225111800 #1^7 \
+ 349947592110433543619114105190630648009305990596089919920 #1^8 -
106747371466686462957887174434503958626612109573992670672 #1^9 \
+ 14573808550521644768419974300540238469473534471735953168 #1^10 &,
6]}, {x ->
Root[502925249036334454715336778553984003440864263790494070 +
79507334695638259109060376450677753198917644793560 y -
7228015973937440731974941433834202407604387494117592200 #1 +
46469470965681832229663230673595151067237874818752782840 #1^2 -
176009396354156927628824727628578542386502238219708082250 #1^3 \
+ 434953160110610020035094377442281900757943807833308766200 #1^4 -
732785165581324716157030456066865775762616415498186198190 #1^5 \
+ 852422521044952102836379759843676923790865671573802051255 #1^6 -
676099528944398287173100625127955582322701524364225111800 #1^7 \
+ 349947592110433543619114105190630648009305990596089919920 #1^8 -
106747371466686462957887174434503958626612109573992670672 #1^9 \
+ 14573808550521644768419974300540238469473534471735953168 #1^10 &,
7]}, {x ->
Root[502925249036334454715336778553984003440864263790494070 +
79507334695638259109060376450677753198917644793560 y -
7228015973937440731974941433834202407604387494117592200 #1 +
46469470965681832229663230673595151067237874818752782840 #1^2 -
176009396354156927628824727628578542386502238219708082250 #1^3 \
+ 434953160110610020035094377442281900757943807833308766200 #1^4 -
732785165581324716157030456066865775762616415498186198190 #1^5 \
+ 852422521044952102836379759843676923790865671573802051255 #1^6 -
676099528944398287173100625127955582322701524364225111800 #1^7 \
+ 349947592110433543619114105190630648009305990596089919920 #1^8 -
106747371466686462957887174434503958626612109573992670672 #1^9 \
+ 14573808550521644768419974300540238469473534471735953168 #1^10 &,
8]}, {x ->
Root[502925249036334454715336778553984003440864263790494070 +
79507334695638259109060376450677753198917644793560 y -
7228015973937440731974941433834202407604387494117592200 #1 +
46469470965681832229663230673595151067237874818752782840 #1^2 -
176009396354156927628824727628578542386502238219708082250 #1^3 \
+ 434953160110610020035094377442281900757943807833308766200 #1^4 -
732785165581324716157030456066865775762616415498186198190 #1^5 \
+ 852422521044952102836379759843676923790865671573802051255 #1^6 -
676099528944398287173100625127955582322701524364225111800 #1^7 \
+ 349947592110433543619114105190630648009305990596089919920 #1^8 -
106747371466686462957887174434503958626612109573992670672 #1^9 \
+ 14573808550521644768419974300540238469473534471735953168 #1^10 &,
9]}, {x ->
Root[502925249036334454715336778553984003440864263790494070 +
79507334695638259109060376450677753198917644793560 y -
7228015973937440731974941433834202407604387494117592200 #1 +
46469470965681832229663230673595151067237874818752782840 #1^2 -
176009396354156927628824727628578542386502238219708082250 #1^3 \
+ 434953160110610020035094377442281900757943807833308766200 #1^4 -
732785165581324716157030456066865775762616415498186198190 #1^5 \
+ 852422521044952102836379759843676923790865671573802051255 #1^6 -
676099528944398287173100625127955582322701524364225111800 #1^7 \
+ 349947592110433543619114105190630648009305990596089919920 #1^8 -
106747371466686462957887174434503958626612109573992670672 #1^9 \
+ 14573808550521644768419974300540238469473534471735953168 #1^10 &,
10]}}
As my polynomial is of degree 10 I have possibly 10 solutions to this equation. But actually I am looking what happens for $1/2 \leq x \leq 1$. Then, I changed my solve line by :
Solve[y == ff[x] && 1/2 <= x <= 1, x]
But then I have 0 solutions :
Solve::ratnz: Solve was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result.
But of course there is a solution we can see it graphically.
How can I solve this problem ?
Solve
, so exactly what you want $\endgroup$Reduce
instead ofSolve
, optionally withSimplify[…,y∈Reals]
$\endgroup$if = NDSolveValue[{H2'[x[y]] x'[y] == 1, x[H2[3/4]] == 3/4}, x, {y, 0, Log[2]}, WorkingPrecision->16]
$\endgroup$