## Problem with plotting

So I need to plot this function:

``Y(x) = 170 *sin⁡[2 *arctan [[[-x^[4] + 340*x^[3] - 35150*x^[2] + 1062500*x + 3194375]^[1/2] - 2400]/[x^[2] - 290* x + 20525]]] + 20 ``

and i tried to do it like this

``Plot    [170 * sin⁡[2 * arctan [[[-x^[4] + 340*x^[3] - 35150*x^[2] + 1062500*x + 3194375]^[1/2] - 2400]/[x^[2] - 290* x + 20525]]] + 20, {x, 0, 10}] ``

but i keep getting syntax error:

Syntax::sntxb: Expression cannot begin with "[[x^[4]+340x^[3]-35150x^[2]+1062500x+3194375]^[1/2]-2400]/[x^[2]-290x+20525]"

## Scientific notations with negative powers for plotting

``Plot[x^2, {x, 0, 100},Ticks -> {{#, ScientificForm@#} & /@ Range[0., 100., 30.], {#, ScientificForm@#} & /@ Range[0., 100^2, 1000.]}, PlotRange -> All];  PowerTicks[label_][min_, max_] :=Block[{min10, max10}, min10 = Floor[Log10[min]];  max10 = Ceiling[Log10[max]]; Join[Table[{10^i,If[label, Superscript[10, i], Spacer[{0, 0}]]}, {i, min10, max10}], Flatten[Table[{k 10^i,Spacer[{0, 0}], {0.005, 0.`},{Thickness[0.001`]}}, {i, min10,max10}, {k, 9}], 1]]] ListLogLogPlot[Range[20]^3, Frame -> True, FrameTicks -> {{PowerTicks[True],PowerTicks[False]}, {PowerTicks[True], PowerTicks[False]}}] ``

The above code very well for the positive powers. Could some one please check it how does it change for the negative powers. More specific, on both axes the scales should be rangeing `{10^-5, 10^-4....10^0, 10^1, 10^2,...10^5}`. Thanks!

## log plot not plotting correctly

I am trying to get the following function, to plot with a log y axis. However, when I replace `Plot` with `LogPlot`, the plot is not computed correctly. Instead, a plot with incorrect x-axis is returned.

``Constants  au = QuantityMagnitude[UnitConvert[Quantity[1, "AstronomicalUnit"], "Meters"]];  c = QuantityMagnitude[UnitConvert[Quantity[1, "SpeedOfLight"], "MetersPerSecond"]];  Qpr = 1;  Lsun = QuantityMagnitude[UnitConvert[Quantity[1, "SolarLuminosity"], "Watts"]];  Rsun = QuantityMagnitude[UnitConvert[Quantity[1, "SolarRadius"], "Meters"]];  Msun = QuantityMagnitude[UnitConvert[Quantity[1, "SolarMass"], "Kilograms"]];  G = QuantityMagnitude[UnitConvert[Quantity[1, "GravitationalConstant"], ("Meters"^2*"Newtons")/"Kilograms"^2]];  year = QuantityMagnitude[UnitConvert[Quantity[1, "Years"], "Seconds"]];  Myr = year*10^6;  Gyr = year*10^9;  Mwd = 0.6*Msun;  Cst = 1.27;  U = 1*10^17;   Functions  L[t_] := (3.26*Lsun*(Mwd/(0.6*Msun)))/(0.1 + t/Myr)^1.18;  Roche[dens_] := (0.65*Cst*Rsun*(Mwd/(0.6*Msun))^(1/3))/(dens/3000)^3^(-1);  Papsis[t_] := a[t]*(1 - e[t]);   Radiative Drag  RDdadtR\[Rho]a = -((3*L[t]*Qpr*(2 + 3*e[t]^2))/(c^2*(16*Pi*\[Rho]*Rast*a[t]*(1 - e[t]^2)^(3/2))));  RDdedtR\[Rho]a = -((15*L[t]*e[t])/(c^2*(32*Pi*Rast*\[Rho]*a[t]^2*Sqrt[1 - e[t]^2])));   RDsolR\[Rho]a = ParametricNDSolveValue[{Derivative[1][a][t] == RDdadtR\[Rho]a, Derivative[1][e][t] == RDdedtR\[Rho]a, a[0] == a0, e[0] == 0.3}, {a, e}, {t, 0, 9*Gyr},      {Rast, \[Rho], a0}];   fRDticks = {{Automatic, Automatic}, {Charting`FindTicks[{0, 1}, {0, 1/Myr}], Automatic}};   Manipulate[Column[{Style["Radiative Drag Working Plot", Bold], Plot[fun[func, t]/scale[func], {t, 0, 9*Gyr}, FrameTicks -> fRDticks,       Epilog -> {Red, Dashed, InfiniteLine[{{0, Roche[\[Rho]]}, {10, Roche[\[Rho]]}}]}, PlotStyle -> {Directive[Blue, Thickness[0.01]]}], Style["Compiled Plot", Bold],      If[comp === {}, Plot[fun[func, t]/scale[func], {t, 0, 9*Gyr}, FrameTicks -> fRDticks, Epilog -> {Red, Dashed, InfiniteLine[{{0, Roche[\[Rho]]}, {10, Roche[\[Rho]]}}]},        PlotStyle -> {Directive[Blue, Thickness[0.01]]}], Plot[comp/scale[func], {t, 0, 9*Gyr}, FrameTicks -> fRDticks,        Epilog -> {Red, Dashed, InfiniteLine[{{0, Roche[\[Rho]]}, {10, Roche[\[Rho]]}}]}, PlotStyle -> {Directive[Blue, Thickness[0.01]]}]]}],    {{func, 1}, {1 -> "a", 2 -> "e", 3 -> "q"}}, {{Rast, 0.005}, 0.0001, 0.1, 0.001, Appearance -> "Labeled"}, {{\[Rho], 3000}, 1000, 7000, 50, Appearance -> "Labeled"},    {{a0, 10, "a0 (au)"}, 1, 20, 0.2, Appearance -> "Labeled"}, Button["Append", AppendTo[comp, fun[func, t]]], Button["Reset", comp = {}],    TrackedSymbols -> {func, Rast, \[Rho], a0}, Initialization :> {comp = {}, fun[sel_, t_] := Switch[sel, 1, RDsolR\[Rho]a[Rast, \[Rho], a0*au][[1]][t], 2,        RDsolR\[Rho]a[Rast, \[Rho], a0*au][[2]][t], 3, RDsolR\[Rho]a[Rast, \[Rho], a0*au][[1]][t]*(1 - RDsolR\[Rho]a[Rast, \[Rho], a0*au][[2]][t])],      scale[sel_] := Switch[sel, 1 | 3, au, 2, 1]}] ``

The question is- how do I get this plot to have a logarithmic y axis?

## Plotting horizontal line on Manipulate Plot

I have the following code, which outputs a `Manipulate` style plot. I want to draw a horizontal line on the plot related to `q`, with equation: `y = Roche[\[rho]]`.

My code is as follows:

``Constants  au = QuantityMagnitude[UnitConvert[Quantity[1, "AstronomicalUnit"], "Meters"]];  c = QuantityMagnitude[UnitConvert[Quantity[1, "SpeedOfLight"], "MetersPerSecond"]];  Qpr = 1;  Lsun = QuantityMagnitude[UnitConvert[Quantity[1, "SolarLuminosity"], "Watts"]];  Rsun = QuantityMagnitude[UnitConvert[Quantity[1, "SolarRadius"], "Meters"]];  Msun = QuantityMagnitude[UnitConvert[Quantity[1, "SolarMass"], "Kilograms"]];  G = QuantityMagnitude[UnitConvert[Quantity[1, "GravitationalConstant"], ("Meters"^2*"Newtons")/"Kilograms"^2]];  year = QuantityMagnitude[UnitConvert[Quantity[1, "Years"], "Seconds"]];  Myr = year*10^6;  Gyr = year*10^9;  Mwd = 0.6*Msun;  Cst = 1.27;  U = 1*10^17;   Functions  L[t_] := (3.26*Lsun*(Mwd/(0.6*Msun)))/(0.1 + t/Myr)^1.18;  Roche[dens_] := (0.65*Cst*Rsun*(Mwd/(0.6*Msun))^(1/3))/(dens/3000)^3^(-1);  Papsis[t_] := a[t]*(1 - e[t]);   Radiative Drag  RDdadtR\[Rho]a = -((3*L[t]*Qpr*(2 + 3*e[t]^2))/(c^2*(16*Pi*2000*Rast*a[t]*(1 - e[t]^2)^(3/2))));  RDdedtR\[Rho]a = -((15*L[t]*e[t])/(c^2*(32*Pi*Rast*2000*a[t]^2*Sqrt[1 - e[t]^2])));   Null  RDsolR\[Rho]a = ParametricNDSolveValue[{Derivative[1][a][t] == RDdadtR\[Rho]a, Derivative[1][e][t] == RDdedtR\[Rho]a, a[0] == a0, e[0] == 3/10}, {a, e}, {t, 0, 9*Gyr},      {Rast, \[Rho], a0}];   fRDticks = {{Automatic, Automatic}, {Charting`FindTicks[{0, 1}, {0, 1/Myr}], Automatic}};   Manipulate[Column[{Style["Working Plot", Bold], Plot[fun[func, t]/scale[func], {t, 0, 9*Gyr}, FrameTicks -> fRDticks,       PlotStyle -> {Directive[Blue, Thickness[0.01]]}], Style["Compiled Plot", Bold],      If[comp === {}, Plot[fun[func, t]/scale[func], {t, 0, 9*Gyr}, FrameTicks -> fRDticks, PlotStyle -> {Directive[Blue, Thickness[0.01]]}],       Plot[comp, {t, 0, 9*Gyr}, FrameTicks -> fRDticks, PlotStyle -> {Directive[Blue, Thickness[0.01]]}]]}], {{func, 1}, {1 -> "a", 2 -> "e", 3 -> "q"}},    {{Rast, 0.005}, 0.0001, 0.1, 0.001, Appearance -> "Labeled"}, {{\[Rho], 3000}, 1000, 7000, 50, Appearance -> "Labeled"},    {{a0, 10, "a0 (au)"}, 2, 20, 0.2, Appearance -> "Labeled"}, Button["Append", AppendTo[comp, fun[func, t]]], Button["Reset", comp = {}],    TrackedSymbols -> {func, Rast, \[Rho], a0}, Initialization :> {comp = {}, fun[sel_, t_] := Switch[sel, 1, RDsolR\[Rho]a[Rast, \[Rho], a0*au][[1]][t], 2,        RDsolR\[Rho]a[Rast, \[Rho], a0*au][[2]][t], 3, RDsolR\[Rho]a[Rast, \[Rho], a0*au][[1]][t]*(1 - RDsolR\[Rho]a[Rast, \[Rho], a0*au][[2]][t])],      scale[sel_] := Switch[sel, 1 | 3, au, 2, 1]}]  ``

I have tried to use `Epilog` but no line was displayed.

Any help would be appreciated.

## Plotting a small gaussian | Small values and dealing with Machine Precision

I’ve defined the following:

``k := 1.38*10^-16 kev := 6.242*10^8 q := 4.8*10^-10 g := 1.66*10^-24 h := 6.63*10^-27 ``

and

``b = ((2^(3/2)) (\[Pi]^2)*1*6*(q^2)*(((1*g*12*g)/(1*g + 12*g))^(   1/2)) )/h  T6 := 20 T := T6*10^6 e0 := ((b k T6 *10^6)/2)^(2/3)  \[CapitalDelta] := 4/\[Sqrt]3 (e0 k T6 *10^6)^(1/2)  \[CapitalDelta]kev = \[CapitalDelta]*kev e0kev = e0*kev bkev = b*kev^(1/2) ``

Then, I want to plot these functions:

``fexp1[x_] = E^(-bkev *(x*kev)^(-1/2)) fexp2[x_] = E^(-x/(k*T)) fexp3[x_] = fexp1[x]*fexp2[x] ``

and check that this Taylor expansion works:

``fgauss[x_] =   Exp[(-3 (bkev^2/(4 k T*kev ))^(1/3))]*   Exp[(-((x*kev - e0kev)^2/(\[CapitalDelta]kev/2)^2))] ``

which should, e.g., as expected:

This plot came from "Stellar Astrophysics notes" of Edward Brown (also it is a known approximation).

I used this line of command to Plot:

``Plot[{fexp1[x],fexp2[x],fexp3[x],fgauss[x]}, {x, 0, 50},   PlotStyle -> {{Blue, Dashed}, {Dashed, Green}, {Thick, Red}, {Thick,      Black, Dashed}}, PlotRange -> Automatic, PlotTheme -> "Detailed",   GridLines -> {{{-1, Blue}, 0, 1}, {-1, 0, 1}},   AxesLabel -> {Automatic}, Frame -> True,   FrameLabel -> {Style["Energía E", FontSize -> 25, Black],     Style["f(E)", FontSize -> 25, Black]}, ImageSize -> Large,   PlotLegends ->    Placed[LineLegend[{"","","",""}, Background -> Directive[White, Opacity[.9]],      LabelStyle -> {15}, LegendLayout -> {"Column", 1}], {0.35, 0.75}]] ``

but it seems that Mathematica doesn’t like huge negative exponentials. I know I can compute this using Python but it’s a surprise to think that Mathematica can’t deal with the problem somehow. Could you help me?

## Plotting a normal curve over a histogram

I am teaching a basic introduction to normal curves, and the textbook introduces the topic with the idea of rolling five dice and recording the sum. Do this many times and create a histogram of the results. (which looks more and more like the normal curve as the number of trials increases) My "code" to simulate this for 10000 rolls is below.

``rolls = Table[Table[RandomChoice[Range[6]], {5}], {10000}]; sums = Total /@ rolls; Histogram[sums, {0.5, 31.5, 1}] ``

I am way out of my depth here, but wondered if anyone could help with how to plot the "perfect" normal curve that would match the histogram?

I have the following to plot a normal curve, but for it to match the dice example, I need the mean and standard deviation, and how no idea what that would be.

``Plot[PDF[NormalDistribution[0, 1], x], {x, -3, 3}, Ticks -> None,   Axes -> None] ``

Any help is appreciated.

## Problem Lotka Volterra Model – Modelling & Plotting in Python

I urgently need your help. Currently I’m conducting a research in regards of the revenue calculation and the dynamics within revenue calculation for my masters. I thought of revenue/profit margin as of a dynamical system – Lotka Volterra differential equations. I thought of a contribution margin calculation as within this simple formula:

In consequence my idea was the following, but I receive an error:

• Can anyone help me?
• Do you think it’s a bad idea to use Lotka Volterra equations for this nonlinear purpose of Sales/Cost/Margin Simulation?
• How would you model it and why? Am I missing equations or does the simple system already fit the requirements?
• How do I generate a valid plot out of these results (Phase Portrait etc.)?

## Plotting a well defined function displays nothing for two-thirds of the range required

The plot in question concerns the second derivative of an inverse Laplace transform (ILT) of a function with five parameters. Here is the ILT

``ClearAll["Global`*"] prod = (s - cr1) (s - cr2) (s - cr3) (s - cr4); LW = (1 + s)^2/(si prod); Print["symbolic W'=", Wp = D[InverseLaplaceTransform[LW, s, x], x]] ``

Four parameters are functions of the fifth parameter "si", defined as the roots of a fourth order equation

``cr = {cr1, cr2, cr3, cr4} =     s /. Solve[si s^2 + 107 s/5 + 10 ((1 + s)^(-2) - 1) - 1/10 == 0,       s]; ``

Plotting the first derivative of the ILT takes .64

``lx = 13; Timing[  pd = Plot[Evaluate[Wp /. si -> 1], {x, 0, lx},     PlotRange -> {{0, lx}, {0.0225, .0275}}]] ``

Plotting of the second derivative of the ILT takes 14.84 and displays nothing for two-thirds of the range lx

``    Wd = D[Wp, x]; Timing[Plot[(Wd /. si -> 1), {x, 0, lx},   PlotRange -> {{0, lx}, {-0.002, .002}}]] ``

## Recursively plotting specific elements in a list of lists

I am trying to build band structures and am looking to generate a general code that will work regardless of my list size. Here is what I am trying to do: say I have a list like

``list = {{0.0, 1, 2, 3}, {0.1, 4, 5, 6}, {0.2, 7, 8, 9}, {0.3, 10, 11, 12}}; ``

and I want to plot the nth element of each list against the first element of each list. How can I tell Mathematica to automatically produce a set of lists to plot like shown below

``k = {0.0, 0.1, 0.2, 0.3}; band1 = {1, 4, 7, 10}; band2 = {2, 5, 8, 11}; band3 = {3, 6, 9, 12}; Show[ListLinePlot[k, band1], ListLinePlot[k, band2], ListLinePlot[k, band3]] ``

Doing it manually one band at a time is possible but a waste of time when I have n=36+ bands. Any help would be much appreciated!

## Plotting data from a list of rules, infer axis titles from the rules with units

I have data, with units, organized as a list of rules; this is so I can slice the data in different ways based on the variables represented.

I’m trying to find the most direct way to plot this and get axis titles with both the variable from the rule and unit from the values. I don’t want to manually label the plots each time, so if Plot doesn’t have a built-in then how can I write a function to do the inference? I’m looking for the most DRY approach possible.

This gives me the units, but not the variable names, in the labels:

``data = {    y -> {0, 33.2} (Quantity[1, ("KipsForce")/("Inches")^2]),    x -> {0, 6} 10^-4    }; ListLinePlot[Transpose@({x, y} /. data), AxesLabel -> Automatic] ``

On the same example, is it possible to retain units like "in/in"? I’ve done this by manually specifying the labels and using `HoldForm` to avoid evaluating the cancellation, but I can’t get that to work with automatic labels as above.