After some simplifications I was eventually get the following piecewise function.
mypdf[x_] =Piecewise[{
{Indeterminate, x == -1.12568412580949},
{(E^(-0.42044483028504587*x - 1.222667146921728*Sqrt[1.1256841258094925 + 1.*x])*(0.04164934621418419 + 0.04164934621418419*E^(2.445334293843456*Sqrt[1.1256841258094925 + 1.*x])))/Sqrt[1.1256841258094925 + 1.*x],
1.*Sqrt[1.1256841258094925 + 1.*x] >= 1.2241479465411274},
{(E^(-1.3335678123173245*x - 1.222667146921728*Sqrt[1.1256841258094925 + 1.*x])*(0.04164934621418419*E^(0.9131229820322787*x) + 0.05004800901350002*E^(0.42044483028504587*x + 2.4453342938612392*Sqrt[1.1256841258094925 + 1.*x])))/Sqrt[1.1256841258094925 + 1.*x],
1.*Sqrt[1.1256841258094925 + 1.*x] >= 1.2241479465050318},
{(E^(-0.42044483028504587*x -1.222667146921728*Sqrt[1.1256841258094925 + 1.*x])*(0.05620334996303362 +0.05620334996303362*E^(2.445334293843456*Sqrt[1.1256841258094925 +1.*x])))/Sqrt[1.1256841258094925 + 1.*x],
1.*Sqrt[1.1256841258094925 + 1.*x] <= 0.9435301862601678},
{(E^(-1.3335678123173245*x - 1.222667146939511*Sqrt[1.1256841258094925 + 1.*x])*(0.05004800901350002*E^(0.42044483028504587*x) + 0.05620334996303362*E^(0.9131229820322787*x + 2.4453342938612392*Sqrt[1.1256841258094925 + 1.*x])))/Sqrt[1.1256841258094925 + 1.*x],
1.*Sqrt[1.1256841258094925 + 1.*x] <= 0.9435301862962627},
{(E^(-0.9131229820322787*x - 1.222667146939511*Sqrt[1.1256841258094925 + 1.*x])*(0.05004800901350002 + 0.05004800901350002*E^(2.445334293879022*Sqrt[1.1256841258094925 + 1.*x])))/Sqrt[1.1256841258094925 + 1.*x],
x >= -1.12568412580949}}, 0]
But I dont understand why Mathematica outputs such a strange form?! Because first of all, the function is defined $2$ times in this range $1. Sqrt[1.12568 + 1. x] >= 1.22415$ and two times in this range $1. Sqrt[1.12568 + 1. x] <= 0.94353$.
Even worse the functions for the same range or condition are not the same! However, I am able to plot this function very nicely. Below is a plot of it
My eventual aim is to transfer this function to Matlab. I know how to do it from here but piecewise function is not recognized by Matlab and I want to define it if possible in terms of UnitSteps. I am also able to do it but as I mentioned the piecewise function above is very strange! the conditions are not defined in terms of for example $0.9<x$ but for example $1. Sqrt[1.12568 + 1. x] <= 0.94353$.
Is it possible to obtain a unser friendly non-ugly function so that I can transer it to Matlab? Why is it two times defined in the same range by Mathematica?
1.` Sqrt[1.1256841258094925` + 1.` x] >= 1.2241479465411274
and1.` Sqrt[1.1256841258094925` + 1.` x] >= 1.2241479465050318
. It's a small difference, but a difference nonetheless. And the first one does not preclude the second one from being satisfied.Piecewise
"falls" through the cases. The first condition that is true determines the value. $\endgroup$UnitStep
. 3) This will simplify the inequalities:MapAt[Reduce, mypdf[x], {1, All, 2}]
. 4) This will remove the overlaps:foo = mypdf[x]; foo[[1, All, 2]] = With[{conds = mypdf[x][[1, All, 2]]}, FoldList[{Or[First@#1, #2], Reduce[#2 && ! Last@#1]} &, {False, Reduce@First[conds]}, Rest[conds]][[All, 2]]]; foo
, but I don't think that will be a computational improvement. $\endgroup$