plotting – Can’t plot derivative of Hankel function

I am trying to plot the first derivative of $H^{(1)}_3 (ix)$ with respect to its argument $ix$, where $H^{(1)}_3 (ix)$ is the Hankel function of the first kind with order $3$, $x in mathbb{R}$ is a real variable and $i = sqrt{-1}$ is the imaginary unit.

According to the chain rule, it should be:

$$frac{mathrm{d}}{mathrm{d}(ix)} left( H^{(1)}_3 (ix) right) = frac{1}{i} frac{mathrm{d}}{mathrm{d}x} left( H^{(1)}_3 (ix) right)$$

So, first, I defined:

a(x_) := HankelH1(3, I*x);

It is a real-valued function and it’s easy to plot, for example with Plot(a(X), {X, 0, 10}).

Then:

b(x_) := D(a(x), x);

which is pure imaginary and should represent $displaystyle frac{mathrm{d}}{mathrm{d}x} left( H^{(1)}_3 (ix) right)$. Then,

c(x_) := D(a(x), x) / I;

should be $displaystyle frac{mathrm{d}}{mathrm{d}(ix)} left( H^{(1)}_3 (ix) right)$ and should be real.

However, I can’t plot it:

Plot(c(X), {X, 0, 10})

gives

General::ivar: 0.0002042857142857143` is not a valid variable.
General::ivar: 0.20428591836734694` is not a valid variable.
General::ivar: 0.40836755102040817` is not a valid variable.
General::stop: Further output of General::ivar will be suppressed during this calculation.

Why? What am I doing wrong?

I’m using Mathematica 12.0.0 on Linux x86 (64 bit).

python – Matplot lib : scalling of the axes on bar plot

I am using following script to plot cluster populations using two lists contained x and y data

# calculate clusters using encore method
cluster = encore.cluster(u, select="all", superposition=False, method=encore.DBSCAN(eps=1))

# make list of population of each cluster;
cluster_sizes= (len(c) for c in cluster.clusters)
# make list of the cluster number;
cluster_numbers=(x+1 for x in range(0,len(cluster_sizes)))

# plot data
plt.bar(cluster_numbers, cluster_sizes)
plt.title('Cluster Populations')
plt.grid(True)
#plt.style.use('ggplot')
plt.savefig(f'clusters.png')
plt.close()

The problem that sometimes on the resulted bar plot the values are ranged by 0.5 along both X and Y (see the enclosed picture as the example). How I could plot only integers along the both axes? In my example graph the X should be scalled from 0 to 20 (avoiding 0.5 spacings) and the Y from 0 to 18 (thus enter image description hereavoiding these unused 0.5 spacings)

plotting – plot the tow data in one graph

data={{13, 679.52}, {19, 305.826}, {21, 242.22}, {26, 132.365}, {29,88.782}, {32, 57.2009},
{37,24.5524}, {42, 8.82704}, {46,3.35573}, {48, 1.98509}, {52, 0.72441}, {54, 0.500693},
{58,0.362299}, {62, 0.324838}, {67, 0.243063}, {71, 0.15979}, {78,0.0589129}, {81, 0.0409279},
{88, 0.035613}, {95, 0.0513416}, {104,0.0885481}, {115, 0.152606}, {125, 0.193406}}

X = ListLogPlot(Apply(data & , data, {1}), PlotRange -> {{10, 130}, {0.02, 200}}, Joined -> True, 
Frame -> True, FrameLabel -> {"(Theta)cm", "d(Sigma)/d(CapitalOmega)(mb)"}, 
 LabelStyle -> Directive(Bold, Medium), PlotLegends -> Placed({"(d(Sigma)/d(CapitalOmega))GP"}, 
{0.7, 0.65}), PlotStyle -> Directive(Red, Medium))

 Needs("ErrorBarPlots`")
 B2 = {{{13.952, 364.7}, ErrorBar(36.4)}, {{19.13, 309.11},ErrorBar(30.9)}, {{21, 294.159}, 
 ErrorBar(29.4)}, {{26.2635, 237.26},ErrorBar(23.7)}, {{29.0713, 191.367},ErrorBar(19.1)}, 
 {{32.959, 151.82},ErrorBar(15.1)}, {{37.2786, 118.47}, ErrorBar(11.8)},{{42.246, 86.529}, 
 ErrorBar(8.6)}, {{46.1339, 67.5217},ErrorBar(6.7)}, {{48.9417, 39.7778},ErrorBar(3.9)}, {{52.6134, 
 32.0836},ErrorBar(3.2)}, {{54.7732, 24.2215},ErrorBar(2.4)}, {{58.2289, 14.0352},ErrorBar(1.4)}, 
 {{62.7646, 6.13975},ErrorBar(0.6)}, {{67.5162, 3.617},ErrorBar(0.36)}, {{71.8359, 2.20246}, 
  ErrorBar(0.22)}, {{78.0994, 1.92956},ErrorBar(0.19)}, {{81.987, 1.36348},ErrorBar(0.13)}, 
{{88.4665, 1.34112},ErrorBar(0.13)}, {{95.162, 1.34112},ErrorBar(0.13)}, {{104.665, 1.36348}, 
 ErrorBar(0.13)}, {{115.464, 0.979543},ErrorBar(0.09)}, {{125.616, 0.777114}, ErrorBar(0.55)}};
 ErrorListPlot(B2, PlotRange -> {{10, 135}, {0.1, 400}}, Frame -> True, FrameLabel -> {" 
 (Theta)cm", "d(Sigma)/d(CapitalOmega)(mb)"},LabelStyle -> Directive(Bold, Medium),PlotLegends -> 
 Placed({"(d(Sigma)/d(CapitalOmega))Exp"}, {.7, .65}),PlotStyle -> Directive(Red, Medium), 
 ScalingFunctions -> "Log")

Please I want to Show the two plots in one graph , When Y-Axis is logarithm scale

plotting – How can I plot and indicate when the function is positive or negative?

I would like to study the sign of this function (potential) and show the region (positive-negative)

enter image description here

These are the parameters followed by the code (left figure)

a = 1; c = 1;
b = -1; d = 1;
p = 1; q = -1;   
f1= (Exp(-2 r a) p)/(2 r c) + (Exp(-2 r b) p)/(2 r  d)
f2= ( Exp(-2 r a) q)/(2 r  c) + (Exp(-2 r b) q)/(2 r d)

Plot({ f1,f2 } , {r, -2, 2}, PlotRange -> Automatic) 

As we see for this case, we obtain different signs for f1 and f2. In four different regions
I would like to show them in the plot, A legend it possible only for two regions?

For example, If we change b and d with the same sign (d=-1 and b=-1) (right figure) have only two regions. Please any suggestion and recommendation will be usefull

plotting – Trying to plot a chord with tangential labels

I’m brand new to mathematica and trying to figure it out, my task is to create a chord with labels on each end (currently using a small section of the sin curve).

Currently I’ve just got
Plot(Sin(x), {x, 1, 1.5}, PlotRange -> {0.75, 1.1})

I’ve managed to draw on the points and arrows at either end but I’m struggling to zoom out on the graph to leave space at either end for my annotations

I’m really new to this and struggling to find a good way to do this, can anyone give me any pointers?

calculus and analysis – Plot of the derivative of a function

I have a function functionSL as a function of t (t<0) where I want to find the extremum of the function and also find at which t it occurs. I took the derivative of functionSL with t which I wrote it as the function functionSLD.

d = 3;
torootL(a_?NumericQ, t_?NumericQ, zl_?NumericQ, zh_?NumericQ) := a - NIntegrate((zl y^d)/Sqrt((1 - (zl/zh)^(d + 1) y^(d + 1)) (1 + t^2 (1 - (zl/zh)^(d + 1))^-1 - y^(2 d))), {y, 0, 1}, PrecisionGoal -> 6, Method -> "GlobalAdaptive")
zs(a_?NumericQ, t_?NumericQ, zh_?NumericQ) := zl /. FindRoot(torootL(a, t, zl, zh), {zl, 0.5, 0, 1})
intSL(a_?NumericQ, t_?NumericQ, zh_?NumericQ) := NIntegrate(With({b = zs(a, t, zh)/zh}, (((-1)/(d - 1)) (zs(a, t, zh)^(2 d) (1 + t^2 (1 - (zs(a, t, zh)/zh)^(d + 1))^-1))^-1 zs(a, t, zh)^(2 d)) x^d ((1 - (b x)^(d + 1))/(1 - (zs(a, t, zh)^(2 d) (1 + t^2 (1 - (zs(a, t, zh)/zh)^(d + 1))^-1))^-1 (zs(a, t, zh) x)^(2 d)))^(1/2) - ((b^(d + 1) (d + 1))/(2 (d - 1))) x ((1 - (zs(a, t, zh)^(2 d) (1 + t^2 (1 - (zs(a, t, zh)/zh)^(d + 1))^-1))^-1 (zs(a, t, zh) x)^(2 d))/(1 - (b x)^(d + 1)))^(1/2) + (b^(d + 1)x)/((1 - (b x)^(d + 1)) (1 - (zs(a, t, zh)^(2 d) (1 + t^2 (1 - (zs(a, t, zh)/zh)^(d + 1))^-1))^-1 (zs(a, t, zh) x)^(2 d)))^(1/2)), {x, 0, 1}, MinRecursion -> 20, MaxRecursion -> 20, AccuracyGoal -> 12, PrecisionGoal -> 10, Method -> {"GlobalAdaptive", "SingularityHandler" -> Automatic})
functionSL(a_?NumericQ, t_?NumericQ, zh_?NumericQ) := ((-((1 - (zs(a, t, zh)^(2 d) (1 + t^2 (1 - (zs(a, t, zh)/zh)^(d + 1))^-1))^-1 zs(a, t, zh)^(2 d)) (1 - (zs(a, t, zh)/zh)^(d + 1)))^(1/2)/(d - 1)) + intSL(a, t, zh) + 1)/(4 zs(a, t, zh)^(d - 1))
functionSLD(t_) := Evaluate(Derivative(0, 1, 0)(functionSLL)(0.01, t, 1))

I took some sample values of functionSLD for some t,

In(44):= functionSLD(0)

Out(44)= -3.58024*10^-12

In(48):= functionSLD(-10)

Out(48)= 0.15527

In(90):= functionSLD(-15)

Out(90)= 0.0477369

In(91):= functionSLD(-16)

Out(91)= 0.041289

In(93):= functionSLD(-16.5)

Out(93)= 0.039934

In(59):= functionSLD(-17) // Quiet

Out(59)= 0.0424448

In(60):= functionSLLP(-17.5)

Power::infy: Infinite expression 1/0. encountered.

NIntegrate::izero: Integral and error estimates are 0 on all integration subregions. Try increasing the value of the MinRecursion option. If value of integral may be 0, specify a finite value for the AccuracyGoal option.

NIntegrate::izero: Integral and error estimates are 0 on all integration subregions. Try increasing the value of the MinRecursion option. If value of integral may be 0, specify a finite value for the AccuracyGoal option.

Power::infy: Infinite expression 1/0. encountered.

NIntegrate::izero: Integral and error estimates are 0 on all integration subregions. Try increasing the value of the MinRecursion option. If value of integral may be 0, specify a finite value for the AccuracyGoal option.

General::stop: Further output of NIntegrate::izero will be suppressed during this calculation.

Power::infy: Infinite expression 1/0. encountered.

General::stop: Further output of Power::infy will be suppressed during this calculation.

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::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::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.

General::stop: Further output of FindRoot::lstol will be suppressed during this calculation.

FindRoot::jsing: Encountered a singular Jacobian at the point {zl} = {0.825567}. Try perturbing the initial point(s).

FindRoot::jsing: Encountered a singular Jacobian at the point {zl} = {0.825567}. Try perturbing the initial point(s).

FindRoot::jsing: Encountered a singular Jacobian at the point {zl} = {0.825567}. Try perturbing the initial point(s).

General::stop: Further output of FindRoot::jsing will be suppressed during this calculation.

In(61):= functionSLD(-17.5) // Quiet

Out(61)= $Aborted

Image1

I expect functionSL to have an extremum for at least two values (looking only at t<0) so that functionSLD has at least two roots, I think I got one root at t=0 which is clear in the plot of $frac{dS}{dt}$ and it really confirms my expectations, the other is located somewhere else (it seems clear in the plot).

You can see that at t=0, functionsSLD = -3.58024*10^-12 which is essentially zero, as t goes to lower values functionSLD rises and then goes down again and it looks like it is going to be essentially zero again but as you can see at t=-17.5 I aborted the calculation (in the sample values of functionSLD) because it just takes so long and it seems like there is a problem.

In the end, what I want to see is a plot of functionSLD(t) vs. t ($frac{dS}{dt}$).

I would also like somebody to check my NIntegrate Rules if there is something wrong with it, or can it be improved. I added a singularity handler because an error occurred which I pasted in the above sample values code.

plotting – Draw an exclusion plot using a set of inequalities(make a loglogregionplot)



logLogRegionPlot(rplot_) := 
 Module({pts, pgon},
  pts = Cases(Normal@rplot, Line(a__) :> a, Infinity);
 pgon = {EdgeForm(), 
Directive(RGBColor(0.368417, 0.506779, 0.709798), 
 AbsoluteThickness(1.6), Opacity(0.3)), 
Cases(Normal@rplot, Polygon(_), Infinity)};
ListLogLogPlot(pts,
Joined -> True,
Frame -> True,
PlotRange -> All,
AspectRatio -> 1,
Axes -> False,
PlotStyle -> ColorData(1)(1),
Epilog -> (pgon /. {x_, y_?NumericQ} :> Log@{x, y}))
)
logLogRegionPlot@RegionPlot({y > 8*(10^-10) 
(x)^(1/2)*HeavisideTheta((x)^(-1) - (y)) &&
x > 6*(10^4) && x < 6*(10^10) && 
y < (8*(10^-10))^-1 x^(-5/2)*HeavisideTheta(-(x)^(-1) + 
(y)) && 
 y > 0.6*x^(-3/2)}, {x, 10^2, 10^14}, {y, 10^-16, 10^0}, 
PlotPoints -> 100)

How can I produce an log region plot satisfying those inequalities, I have tried to produce it with the above code an exclusion region is coming, but I need a large plot range (xaxis€(10^0,10^14),yaxis€(10^-17,10^0))for which it is giving a wrong plot.
This was already asked in Wolfram community
Wolfram community asked question

graphics – How to plot a set of complex numbers with given argument and absoulute value bounds

I want to plot the following complex numbers $$z in text{(complex numbers)}:pi/4 < arg (z) leq 5 pi/4, 1 leq |z| < 2 $$

I don’t know how to graph it so that it would look like 2D without any unecessary details. The closest I found how I want it to look is, when I looked at how graphing of parametric function looks. I tried to use contour plot to graph it, but I just can’t seem to do it…

ContourPlot( Im(F(z(x, y))), {3 pi/4 < arg (z) <= 5 pi/4, 1 <= abs (z) < 2}, {x, -.2, .2}, {y, -.2, .2}, PlotRange -> All, Contours -> Range(-5, 5, .5), ContourLabels -> True)

Does anybody know how to graph my set?

plotting – How to plot a schematic plot containing arbitrary smooth curves?

The key is in generating a BezierCurve or some such construct. Here is a version built by hand, just because this was more fun than the actual work I had to do right now 🙂

blue = RGBColor(0.3, 0.45, 1)
green = RGBColor(0.25, 0.35, 0.15);

Show({
  Plot(Style(4 x - 2, Black, Dashed), {x, 0.5, 4}),
  Plot(Style(1/2 x + 4, Black, Dashed), {x, 0, 2.5}, 
   PlotStyle -> Dashed),
  Plot(Style(1/2 x + 1, Black, Dashed), {x, -1, 1.5}, 
   PlotStyle -> Dashed),
  Graphics({
    blue, Thickness(0.01),
    Arrowheads({{0.06, 0.3}, {0.06, 0.95}}),
    Arrow@BezierCurve({{4, 14}, {2, 5.9}, {1.8, 4.8}, {0, 4}})
    }),
  Graphics({
    green, Thickness(0.01),
    Arrowheads({{0.06, 0.97}}),
    Arrow@BezierCurve({{4, 14}, {0.8, 1}, {0.9, 1.3}, {-1, 0.5}})
    }),
  Graphics({
    Inset(Style("Glass", 24), {0.8, 7}),
    Inset(Style("Liquid", 24), {2.7, 12}),
    blue, 
    Inset(Style(StandardForm@"!(*SubscriptBox((q), (1)))", 
      24), {0.5, 5.2}),
    green, 
    Inset(Style(StandardForm@"!(*SubscriptBox((q), (2)))", 
      24), {-0.7, 1.5})
   })
 },
 Frame -> True, Axes -> False,
 FrameLabel -> {"T", "V, H"},
 FrameStyle -> Directive(Black, 24, Thickness(0.01)),
 FrameTicks -> {
   {None, None},
   {
    {
     {12/7, 
      Style(StandardForm@"!(*SubscriptBox((T), (g1)))", blue, 
       Bold),
      {0.03, 0}, Thickness(0.01)},
     {6/7, 
      Style(StandardForm@"!(*SubscriptBox((T), (g2)))", green,
        Bold),
      {0.03, 0}, Thickness(0.01)}},
    None
   }
  },
 PlotRange -> {{-1.5, 4.5}, {-2, 15}},
 AspectRatio -> 0.8, ImageSize -> Large
)

result of code above, resembling desired plot