Ask Your Question

# plot3d gives me a blank canvas, no plot

This is my function that i want to plot:

v_ges_rhs == -1/((d_e - x)*e_m) + 1/(e_m*x) + 1/(sqrt((d_e - x)^2 + 4*d_k^2)*d_k*(e_m/d_m + e_s/(d_k - d_m))) - 1/(sqrt(4*d_k^2 + x^2)*d_k*(e_m/d_m + e_s/(d_k - d_m)))


and this is my code for inserting values and finally plotting.

print v_ges_rhs
a=v_ges_rhs.diff(x).diff(d_k)
b=a.subs({
d_e : 1,
d_m : .15,
e_m : e_0 * 81,
e_s : e_0 * 3.5
})
b.show()

W = plot3d(b,(x,-1,-0.01),(d_k,.2,2))
W.show()


As you can see, I avoid the poles at x == 0 and x == d_e by not plotting that part. (But actually i would like to plot from x = -1 to 2, including both poles, but limiting the range. I understand that is tricky... I will cross that bridge once I crossed this one.)

But the result I get is an empty canvas.

This is my worksheet. (Feel free to fix any issues you see, preferably with a comment. :-)

https://cocalc.com/share/f7766c5e-2f4...

edit retag close merge delete

## Comments

Dear stockh0lm

perusing the worksheet you referred us to demonstratse that you have not taken the time to understand what you are trying to do.

For example, your first two code lines

e_0 = var('e_0', latex_name=r'\varepsilon_0')
e_0 = 8.854 * 10^-12


are contradictory:

• The first line creates an object representing a symbolic variable, whose name is e_0 and affects it to the Python variable e_0

• The second line affects the numerical value 8.854*10^-12 to the same Python variable e_0, thus losing any access to your symbolic variable.

1

Dear Emmanuel, you are right, I am far from understanding what I do. I do use Computational Mathematics with Sagemath, and I look for stuff in there before i come here. I like the index and look up topics in the book. The book does not answer many of the questions, like my "== vs =" question, for example. I do not think you seriously require people to read and understand a book before asking here, though. I did code a little python, but it is not my favourit programming language.

I use sagemath because I need it as a tool. It would be more useful to me if I could learn just parts of it in order to solve my math problems. I am very willing to learn, and I feel I got a lot better in the week since I started.

There are plenty of questions I do have, but ...(more)

1

I would love constructive critizism. You point out that I use the variable e_0 incorrectly.Thanks. According to my understanding, the first line is for formating when showing the variable in latex fashion. the reason I write e_0 = var ... is that then there is no output from the var directive. I don't really care for that in the output below. How else could i achive that? I didn't see any "silent" option. The second line is for the numerical value. I do find that back and forth a little weired, but there are more things wired to me here, so who am I to judge? I know I still suck at this, and if you would please tell me how to do it correctly it would be great and I would gladly adopt your ways. My main problems are the error/uncertainty propagation and RIF numbers and the solve thing.

You have first to think what you want from Sage. Let's take the case of your symbolic constant e0. You can either :

• keep it symbolic during your symbolic work (e.g. system solving in your case), and substitute its numeric value when computing numerics (e. g. plotting); or

• define it as a numerical contant : you won't get e_0 in the output, but the numerical value.

You can't do both.

Getting a "nice" printed output is yet another problem. Peek at LatexExpr and string formatting. In your case, I'd be tempted by

var("e_0", latex_name="\varepsilon_0")
e_0_val={e_0:8.854 * 10^-12}


Print with, e. g. :

show(LatexExpr(r"\varepsilon_0={}".format(latex(e_0))))


and use the numerical value with, e. g. :

plot(SomeExpression.subs(e_0_val), (...)...)


HTH

1

@Emmanuel Charpentier, the purpose of this site is for users to ask questions. I don't think berating them for doing so and telling them to (effectively) RTFD is helpful. I have edited your earlier answer to cut down somewhat on the hostility.

## 1 Answer

Sort by » oldest newest most voted

plotting does work when run locally. I assume cocalc does not provide the computing power for the rendering on the free plan or the local javascript renderer does not mesh well with my browser (chrome) or my OS (linux).

more

## Comments

Respectfully, this is not true (and I am saying so only so that no othe readers get confused). While I have not looked at your specific worksheet, 3D plotting works quite well in Sage Worksheets on CoCalc (better actually than on Jupyter Notebooks, generally), including on a free plan, on Chrome, on Linux. Have you tried starting with a more simple example to get that working first? If it still doesn't work--which for you it apparently isn't--there could still be some issue with your configuration to be sure. But in general there is no issue about "computing power" or anything like that.

The exact same code running locally on my debian stable opens a java app and shows a 3d plot. I am happy I have a result. If you say cocalc limiting the free tire is not the issue I belive you. The rest of my conclusion is still valid. I run this on worksheet on several boxes, and it works in none of them. One of the machines is highly controlled (a chromebook). I guess the downvote is ok because its not a constructive answer, but it is a true answer.

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2019-02-16 12:20:32 +0200

Seen: 194 times

Last updated: Feb 17 '19