I'm new with Mathematica and I have a problem with that, It would be great if you could help me with that. I try to draw a maximum slope of a plot in the same diagram using resource function tangent line, but it seams that it doesn't work for complex function.
ClearAll; $Assumptions = n ∈ Reals && z ∈ Reals && znew ∈ Reals; z = Sqrt[2 epsilon] E^(n); ztwotransitions = Sqrt[2 epsilontwotransitions] E^(n); znew = Sqrt[2 epsilonnew] E^(n); epsilon = aminus1^2/( 18 MPL^2 H0^4) (1 - (aminus1 - aplus)/ aminus1 E^(-3 (n - n0new)))^2; epsilontwotransitions = aminus1^2/( 18 MPL^2 H0^4) (1 - (aminus1 - aplus)/aminus1 E^(-3 (n - n0)))^2; epsilonnew = astar^2/(18 MPL^2 H0^4) (1 - (astar - aminus2)/ astar E^(-3 (n - n1)))^2; modefristsr = 1/Sqrt[2 k] (1 - I/(k τ)) E^(-I k τ); modefristsrprime = D[modefristsr, τ]; modensr = c1/Sqrt[2 k] (1 - I/(k τ)) E^(-I k τ) + c2/Sqrt[2 k] (1 + I/(k τ)) E^(I k τ); modensrprime = D[modensr, τ]; modesecondsr = d1/Sqrt[2 k] (1 - I/(k τ)) E^(-I k τ) + d2/Sqrt[2 k] (1 + I/(k τ)) E^(I k τ); modesecondsrprime = D[modesecondsr, τ]; modefristsrn = Evaluate[modefristsr /. τ -> -1/H0 E^(-n)]; modefristsrprimen = Evaluate[modefristsrprime /. τ -> -1/H0 E^(-n)]; modensrn = Evaluate[modensr /. τ -> -1/H0 E^(-n)]; modensrprimen = Evaluate[modensrprime /. τ -> -1/H0 E^(-n)]; modesecondsrn = Evaluate[modesecondsr /. τ -> -1/H0 E^(-n)]; modesecondsrprimen = Evaluate[modesecondsrprime /. τ -> -1/H0 E^(-n)]; modefristsrn0new = Evaluate[modefristsrn /. n -> n0new]; modefristsrprimen0new = Evaluate[modefristsrprimen /. n -> n0new]; modensrn0new = Evaluate[modensrn /. n -> n0new]; modensrprimen0new = Evaluate[modensrprimen /. n -> n0new]; eqns = {modefristsrn0new - modensrn0new == 0 && modensrprimen0new - modefristsrprimen0new == f0 modensrn0new}; c1c2 = Solve[eqns, {c1, c2}]; solevedmodensrn = modensrn /. c1c2; modefristsrn0 = Evaluate[modefristsrn /. n -> n0]; modefristsrprimen0 = Evaluate[modefristsrprimen /. n -> n0]; modensrn0 = Evaluate[modensrn /. n -> n0]; modensrprimen0 = Evaluate[modensrprimen /. n -> n0]; eqnswithf2 = {modefristsrn0 - modensrn0 == 0 && modensrprimen0 - modefristsrprimen0 == f2 modensrn0}; c11c21 = Solve[eqnswithf2, {c1, c2}]; solvedfirstslowroll = modefristsrn /. c1c2; solevedmodensrnnew = modensrn /. c11c21; solevedmodensrn1 = Evaluate[solevedmodensrnnew /. n -> n1]; solvedmodensrprimen = modensrprimen /. c11c21; solvedmodensrprimen1 = Evaluate[solvedmodensrprimen /. n -> n1]; modesecondsrn1 = Evaluate[modesecondsrn /. n -> n1]; modesecondsrprimen1 = Evaluate[modesecondsrprimen /. n -> n1]; d1d2 = Solve[ solevedmodensrn1 - modesecondsrn1 == 0 && modesecondsrprimen1 - solvedmodensrprimen1 == f1 solevedmodensrn1, {d1, d2}]; solevedmodesecondsrn = modesecondsrn /. d1d2; powerwithc1c2 = k^3/(2 π^2) (z^(-2)) Abs[solevedmodensrn]^2; powerwithd1d2 = k^3/(2 π^2) (znew^(-2)) Abs[solevedmodesecondsrn]^2; f0 = 3 k0new ( aminus1 - aplus)/aplus; f1 = 3 k1 (astar - aminus2)/aminus2; f2 = 3 k0 (aminus - aplus)/aplus; MPL = 1; a = E^(n); k1 = a1 H0; a0 = E^(n0); a0new = E^(n0new); a1 = E^(n1); τ1 = 0.1; H0 = 8.8 10^(-7); σ = 0.01; astar = 7 10^(-16) MPL^3; aminus = 7.26 10^(-15) MPL^3; aplus = 3.35 10^(-14) MPL^3; deltaa = aminus1 - aplus; n0 = 10; n1 = 15; n0new = 10; k0 = a0 H0; k0new = a0new H0; aminus1 = 7 10^(-16); aminus2 = 7.26 10^(-15); LogLogPlot[ Evaluate[{powerwithc1c2 , powerwithd1d2} /. {k -> k0 kstar, n -> 200}], {kstar, 10^(-1), 1000} , AxesLabel -> {"\!\(\*FractionBox[\(k\), \(k0\)]\)", "Power_Spectrum"}, PlotLegends -> {"one_transition", "Two_transitions"}]
Edited post: This is what should how result should look like:
ComplexPlot3DandComplexPlot- not sure about log-log space. But something like this, maybe:func = (var^2 + 1)/(var^2 - 1); number = 1 + I; slope = D[func, var] /. var -> number; height = func /. var -> number; ComplexPlot3D[#, {var, -2 - I, 3 + 4 I}] & /@ {func, slope (var - number) + height} // Show$\endgroup$