# Plotting issues with n-root function

I've been getting issues with plotting a function I've written to calculate the maximum height a floating body can float in a polytrope atmosphere dependant on a weight, here is the function;

X[ml_] := Power[(v Subscript[\[Rho], h] + 6000 kg + ml)/(
v Subscript[\[Rho], 0]), ((n - 1))^-1]

z[ml_] := -(X[ml] - 1) (n Subscript[h, 0])/(n - 1)


I would like to plot it, but I get an error that regardless of googling I can't seem to find an answer. The error message being:

In:= Plot[z[ml], ml]

Out= SystemProtoPlotDumpiPlot[Plot, \SystemProtoPlotDumpobj\$53256, z[ml], ml]


I found, while googling, this link (Plotting discontinuous functions without spurious vertical segments) with close to the same error message. However, my function shouldn't be discontinuous in its entire range and I don't understand enough of mathematica to apply this example to mine.

I tried plotting the function again within a specific range (1m to 3000m) and this time the graph appears but not actual plot. (see image)

What is the error in my code? Or more accurately, how can I plot this function?

To clarify, my function requires values to be given in kg and returns values in m (metres). Like so

In:= z[300 kg]

Out= 28384.6 m


(albeit the returned value seems a little high...but that is a different issue)

When trying set that range, mathematica just returns the function again.

In:= Plot[z[ml], {ml, 1 kg, 3000 kg}]

Out= Plot[z[ml], {ml, 1 kg, 3000 kg}]


Thank you for the help! Here is a screen shot of mathematica, I'm running version 11. • You're missing a couple of definitions? – Feyre May 7 '17 at 15:54
• Since you are using quantities, look at the documentation for Quantity – Bob Hanlon May 7 '17 at 16:51
• @Feyre Ahh, Sorry I didn't consider posting the entire code. v = 8434 m^3 Roh_h = 0.1785kg/m^3 Roh_0 = 1.225 kg/m^3 h_0 = 8434 n = 1.25 their actual values I suppose for the question arn't important, but they are defined. Sorry if it's unclear to anyone – morbo May 7 '17 at 16:55
• @BobHanlon I will have a read. and return if I don't manage to solve. thanks for the tips. – morbo May 7 '17 at 16:58

const = {v -> Quantity[8434, "Meters"^3],
Subscript[ρ, h] -> Quantity[0.1785, "Kilograms"/"Meters"^3],
Subscript[ρ, 0] -> Quantity[1.225 , "Kilograms"/"Meters"^3],
Subscript[h, 0] -> Quantity[8434, "Meters"],
n -> 1.25};


Note that I made Subscript[h, 0] a quantity ("Meters") rather than the dimensionless constant provided.

X[ml_] := Power[(v Subscript[ρ, h] + Quantity[6000, "Kilograms"] +
ml)/(v Subscript[ρ, 0]), ((n - 1))^-1]

z[ml_] := -(X[ml] - 1) (n Subscript[h, 0])/(n - 1)

z[Quantity[300, "Kilograms"]] /. const

(*  Quantity[28432.1, "Meters"]  *)

Plot[z[Quantity[ml, "Kilograms"]] /. const, {ml, 1, 3000},
Frame -> {{True, False}, {True, False}},
AxesOrigin -> {0, 0},
FrameLabel -> {"ml in kilograms", "z in meters"}] Or to convert to kilometers

Plot[UnitConvert[z[Quantity[ml, "Kilograms"]] /. const, "Kilometers"], {ml, 1,
3000},
Frame -> {{True, False}, {True, False}},
AxesOrigin -> {0, 0},
FrameLabel -> {"ml in kilograms", "z in kilometers"}] • Thank you very much! after reading about quantities I immediately tried to plot without my constants...which worked of course. Just after you posted this, I was in the process of trying to plot with quantities...which didn't work :D, Thanks again for the help! – morbo May 7 '17 at 20:19

In:

v = 8434 ;
Subscript[\[Rho], h] = 0.1785  ;
Subscript[\[Rho], 0] = 1.225  ;
Subscript[h, 0] = 8434 ;
n = 1.25;
X[ml_] :=
Power[(v Subscript[\[Rho], h] + 6000 +
ml)/(v Subscript[\[Rho], 0]), ((n - 1))^-1]
z[ml_] := -(X[ml] - 1) (n Subscript[h, 0])/(n - 1)

Plot[z[ml], {ml, 1 , 3000}]