# Taylor Series of numerical solution of FindRoot

I have found the inverse to the following equation by using FindRoot. I want to have a Taylor approximation (say starting from SDbeta = 0) of the inverse function. I'm only interested in values of SDbeta <0.030.

σ =1
Fun0[tau_, W_, Ce_] := 12 σ^2/ Ce^2*(tau^2/W^3 - 3 tau^3/W^4 + 12 tau^5/W^6 - 3 tau^3/W^6 Exp[-W/tau]*(W + 2 tau)^2)
Fun2[tau_] := Sqrt[Fun0[tau, 10, 10]]
InverseFun2[SDbeta_] := tau /. FindRoot[SDbeta == Fun2[tau], {tau,6}][[1]]
InverseFun2[0.01]


Simply using Series doesn't lead to a result

Series[InverseFun2[x], {x, 0, 5}]


FindRoot::nlnum: The function value {-0.0251585+x} is not a list of numbers with dimensions {1} at {tau} = {6.}. ReplaceAll::reps: {x==1/5 Sqrt[3] Sqrt[tau^2/1000-(3 tau^3)/10000+(3 tau^5)/250000-(3 E^Times[<<2>>] tau^3 Plus[<<2>>]^2)/1000000]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. ....

Is it possible to find a Taylor Series if, as in this case, the analytical solution is not available.

Edit: I just discovered that there is a thing called NSeries in the Numerical calculus package. Adjusting these lines in the code correspondingly:

<< NumericalCalculus
InverseFun2[SDbeta_?NumericQ] := tau /. FindRoot[SDbeta == Fun2[tau], {tau, 6}][[1]]
NSeries[InverseFun2[x], {x, 0, 5}]


leads me to the following errors:

FindRoot::jsing: Encountered a singular Jacobian at the point {tau} = {22900.1 +0. I}. Try perturbing the initial point(s).

FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

FindRoot::cvmit: Failed to converge to the requested accuracy or precision within 100 iterations.

I assume those errors occur because it is trying to compute values of SDbeta that are ill defined.. Is that the case? If so, how to restrict the domain?

• Fun2[tau]depends on \[Sigma] which isn't defined. That's the reason why FindRoot doesn't work. Aug 7, 2018 at 15:11
• Welcome to Mma.SE. Start by taking the tour now and learning about asking and what's on-topic. Always edit if improvable, show due diligence, give brief context, include minimal working example of code and data in formatted form. By doing all this you help us to help you and likely you will inspire great answers. The site depends on participation, as you receive give back: vote and answer questions, keep the site useful, be kind, correct mistakes and share what you have learned. Aug 7, 2018 at 15:19
• I forgot to add the first line, where sigma=1. The FindRoot does work (InverseFun2[1] does give proper answer). It's just that I cannot find a numerical Taylor Expansion. I got a bit further now.. Aug 7, 2018 at 15:26
• It seems to me Exp[-W/tau], and therefore Fun2[tau] also, has an essential singularity at tau = 0 (corresponding to SDbeta = x = 0). The term that has that factor will contribute zero, if you use the right derivative to define the Taylor series. Aug 7, 2018 at 21:35
• Away from singularities, it might be easiest to use implicit differentiation of the (polynomial) defining relation SDbeta^2-Fubn2[tau[SDbeta]]^2==0, then solve for the various derivatives (each will appear linearly in terms of earlier ones). Aug 8, 2018 at 14:22

If I understand you right you want to solve the equation Fun2[tau]==sd , sd<.03

inverse function

\[Tau][sd_?NumericQ] := tau /. NSolve[sd == Fun2[tau], tau, Reals][[1]]
Plot[\[Tau][sd], {sd, 0.01, .03}, AxesLabel -> {sd, tau=inverseFun2[sd]}]


But if I misunderstood you, you could use Series[...] and InverseSeries[] to solve the problem:

Series&InverseSeries

First you have to choose value tau0 for the series expansion

tau0 = tau /. NSolve[Fun2[tau] == 0.03, tau, Reals][[1]]
(*13.984*)


series expansion(plus inverse series):

ser = Series[Fun2[tau], {tau, tau0, 3}]
invser = InverseSeries[ser , sd]


final plot

Show[{
Plot[ Fun2[tau] , {tau, 0, 50}, PlotRange -> {0, .1}],
Plot[Evaluate[Normal[ser ]], {tau, 0, 30}, PlotRange -> {0, .1},PlotStyle -> Red],
ParametricPlot[Evaluate[{Normal[invser ], sd}], {sd, .027, .032},PlotStyle -> Green],
ParametricPlot[Evaluate[{\[Tau][sd], sd}], {sd, .027, .032},PlotStyle -> Green]
}, PlotRange -> {{0, 50}, {0, .1}}, AxesLabel -> {tau, Fun2}, GridLines ->{{tau0}, None}]


• Cool. When I use InverseSeries and Series, I do not get a Taylor Series, but instead InverseSeries[1/5 Sqrt[3] Sqrt[E^(-10/x) (SeriesData[x, 0, {Rational[-3, 10000], Rational[-3, 25000], Rational[-3, 250000]}, 3, 6, 1]) + (SeriesData[x, 0, {Rational[1, 1000], Rational[-3, 10000], 0, Rational[3, 250000]}, 2, 6, 1])]]. Could it be possible no Taylor Series is available? Aug 8, 2018 at 7:56
• So what I was doing wrong is trying to find the Taylor Expansion around tau=0 because of the singularity. Aug 8, 2018 at 10:07
• Ok, but the Series around tau =0  exists: Limit[ Table[Derivative[k][Fun2][tau], {k, 0, 5}], tau -> 0];ser = SeriesData[tau, 0, %, 0, 5, 1] Aug 8, 2018 at 10:34
• That code in your previous comment does not work for me, because of an essential singularity mentioned here. Need to approach along the positive real line to get a series. Of course the Taylor Series makes a rather poor approximation even around 0.01 in such a case as this. It's not clear to me that the OP appreciates that. Aug 8, 2018 at 13:13
• @ Michael E2: In MMA (version 11.0.1. Windows64) Limit[ Table[Derivative[k][Fun2][tau], {k, 0, 5}], tau -> 0] evaluates to {0, Sqrt[3/10]/50, -((3 Sqrt[3/10])/500), -((27 Sqrt[3/10])/20000), ( 207 Sqrt[3/10])/100000, (2241 Sqrt[3/10])/1600000}` Aug 8, 2018 at 13:21