2

I have a problem which is explained by the figure below

enter image description here

My query is how can I plot the function (%i5) using something like

wxplot2d([%],[T2,100,200],[ylabel,"Polytropic co-eff"])$

such that I don't have to copy/paste (or re-write) the f(n) for the last plot

2 Answers 2

2

You can index into the expression with the part function. I also have a suggestion for your substitution usage:

(%i1) f(n) := T2/T1=(P2/P1)^((n-1)/n)$

(%i2) s : [T1=100, P1=1, P2=8]$

(%i3) solve(f(n), n), s;

(%o4) [n = - log(8) / ( log(0.01 T2) - log(8) ) ]

(%i4) plot2d(part(%o4, 1, 2), [T2, 100, 200], [ylabel, "Polytropic co-eff"])$

Output:

Plot of T2 from 100 to 200

Sign up to request clarification or add additional context in comments.

2 Comments

That's good, but I think a clearer way to get the required part of the expression is just rhs(%o4[1]). Note lhs and rhs are the left and right hand sides of an equation or some other two-sided expressions; see ? lhs and ? rhs.
Why I have to write rhs(%[1]) instead of just rhs(%) as is done here: stackoverflow.com/questions/18343054/… ..Plus can you tell be a suitable way to add gridlines (& any customization I can do with them)
0

I find it easier to use substto get the result given by solve:

(%i2) f(n) := T2/T1=(P2/P1)^((n-1)/n)$

(%i3) s : [T1=100, P1=1, P2=8]$

(%i4) solve(f(n), n), s;

(%o4) [n = -log(8)/(log(T2/100)-log(8))]

(%i5) plot2d(subst(%,n), [T2, 100, 200], [ylabel, "Polytropic co-eff"])$

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.