Ask Your Question
0

Weired frontend behaviour? Weired User?

asked 2019-02-12 13:32:31 +0100

stockh0lm gravatar image

updated 2019-02-13 07:19:05 +0100

This is my code

var('e', latex_name=r'\varepsilon')
var('x d_k d_e d_m r Q')

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


var('e_s', latex_name=r'\varepsilon_s')
e_s == e_0 * 3.5

var('e_m', latex_name=r'\varepsilon_m')
e_m == e_0 * 81
var('e_Ersatz', latex_name=r'\varepsilon_{Ersatz}')

var ('p', latex_name=r'\varphi')
var('p_ges', latex_name=r'\varphi_{ges}')
var('p_1', latex_name=r'\varphi_1')
var('p_2', latex_name=r'\varphi_2')
var('p_3', latex_name=r'\varphi_3')
var('p_4', latex_name=r'\varphi_4')


e_Ersatz = d_k * ( (e_m/d_m) + (e_s/(d_k-d_m) ) )
show( SR.symbol('e_Ersatz') == e_Ersatz)

print " "
p = 1/(4*pi*e)*Q/r
show( SR.symbol ('p') == p)

print " "
p_1 = p(e = e_m,      Q = 1, r = x)
p_2 = p(e = e_m,      Q =-1, r = d_e-x)
p_3 = p(e = e_Ersatz, Q =-1, r = sqrt((2*d_k)^2+x^2))
p_4 = p(e = e_Ersatz, Q = 1, r = sqrt((2*d_k)^2+(d_e -x)^2))
p_ges = p_1 + p_2 + p_3 + p_4

print " "
show( SR.symbol('p_ges') == p_ges )

plot( p_ges.subs( d_e == 1, d_k == 1, d_m == .05 ), ( x,0.01,.99 ) )

========================================================

I get a very long and confusing error message when i run that work sheet.

Sometimes, if i reload the website and comment out the very first line (var('e' ...) it gives me a plot, but it thinks e is the exp function.

but in fact e is supposed to be the greek epsilon and it should use the epsilons as material constants. p_ges looks good, then.

But in that case, it does not manage to plot the graph. i get this error in that case. How do i fix that?

Error in lines 28-28
Traceback (most recent call last):
  File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute
    flags=compile_flags) in namespace, locals
  File "", line 1, in <module>
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 492, in wrapper
    return func(*args, **options)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/plot/plot.py", line 1941, in plot
    G = funcs.plot(*args, **original_opts)
  File "sage/symbolic/expression.pyx", line 12059, in sage.symbolic.expression.Expression.plot (build/cythonized/sage/symbolic/expression.cpp:63251)
    f = self._plot_fast_callable(param)
  File "sage/symbolic/expression.pyx", line 12105, in sage.symbolic.expression.Expression._plot_fast_callable (build/cythonized/sage/symbolic/expression.cpp:63630)
    return fast_callable(self, vars=vars, expect_one_var=True)
  File "sage/ext/fast_callable.pyx", line 495, in sage.ext.fast_callable.fast_callable (build/cythonized/sage/ext/fast_callable.c:4840)
    et = x._fast_callable_(etb)
  File "sage/symbolic/expression.pyx", line 11942, in sage.symbolic.expression.Expression._fast_callable_ (build/cythonized/sage/symbolic/expression.cpp:62484)
    return fast_callable(self, etb)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1851, in fast_callable
    return FastCallableConverter(ex, etb)()
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 217, in __call__
    return self.arithmetic(ex, operator)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1779, in arithmetic
    return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1779, in <lambda>
    return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
  File "sage/ext/fast_callable.pyx", line 781, in sage.ext.fast_callable.ExpressionTreeBuilder.call (build/cythonized/sage/ext/fast_callable.c:7296)
    return ExpressionCall(self, fn, [self(a) for a in args])
  File "sage/ext/fast_callable.pyx", line 656, in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (build/cythonized/sage/ext/fast_callable.c:6431)
    return fc(self)
  File "sage/symbolic/expression.pyx", line 11942, in sage.symbolic.expression.Expression._fast_callable_ (build/cythonized/sage/symbolic/expression.cpp:62484)
    return fast_callable(self, etb)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1851, in fast_callable
    return FastCallableConverter(ex, etb)()
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 216, in __call__
    return self.arithmetic(div, div.operator())
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1779, in arithmetic
    return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1779, in <lambda>
    return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
  File "sage/ext/fast_callable.pyx", line 781, in sage.ext.fast_callable.ExpressionTreeBuilder.call (build/cythonized/sage/ext/fast_callable.c:7296)
    return ExpressionCall(self, fn, [self(a) for a in args])
  File "sage/ext/fast_callable.pyx", line 656, in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (build/cythonized/sage/ext/fast_callable.c:6431)
    return fc(self)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 124, in _fast_callable_
    return fast_callable(self, etb)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1851, in fast_callable
    return FastCallableConverter(ex, etb)()
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 216, in __call__
    return self.arithmetic(div, div.operator())
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1779, in arithmetic
    return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1779, in <lambda>
    return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
  File "sage/ext/fast_callable.pyx", line 781, in sage.ext.fast_callable.ExpressionTreeBuilder.call (build/cythonized/sage/ext/fast_callable.c:7296)
    return ExpressionCall(self, fn, [self(a) for a in args])
  File "sage/ext/fast_callable.pyx", line 656, in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (build/cythonized/sage/ext/fast_callable.c:6431)
    return fc(self)
  File "sage/symbolic/expression.pyx", line 11942, in sage.symbolic.expression.Expression._fast_callable_ (build/cythonized/sage/symbolic/expression.cpp:62484)
    return fast_callable(self, etb)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1851, in fast_callable
    return FastCallableConverter(ex, etb)()
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 217, in __call__
    return self.arithmetic(ex, operator)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1772, in arithmetic
    return self.etb.call(_operator.truediv, 1, self.etb.call(sqrt, operands[0]))
  File "sage/ext/fast_callable.pyx", line 781, in sage.ext.fast_callable.ExpressionTreeBuilder.call (build/cythonized/sage/ext/fast_callable.c:7296)
    return ExpressionCall(self, fn, [self(a) for a in args])
  File "sage/ext/fast_callable.pyx", line 656, in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (build/cythonized/sage/ext/fast_callable.c:6431)
    return fc(self)
  File "sage/symbolic/expression.pyx", line 11942, in sage.symbolic.expression.Expression._fast_callable_ (build/cythonized/sage/symbolic/expression.cpp:62484)
    return fast_callable(self, etb)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1851, in fast_callable
    return FastCallableConverter(ex, etb)()
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 217, in __call__
    return self.arithmetic(ex, operator)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1779, in arithmetic
    return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1779, in <lambda>
    return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
  File "sage/ext/fast_callable.pyx", line 781, in sage.ext.fast_callable.ExpressionTreeBuilder.call (build/cythonized/sage/ext/fast_callable.c:7296)
    return ExpressionCall(self, fn, [self(a) for a in args])
  File "sage/ext/fast_callable.pyx", line 656, in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (build/cythonized/sage/ext/fast_callable.c:6431)
    return fc(self)
  File "sage/symbolic/expression.pyx", line 11942, in sage.symbolic.expression.Expression._fast_callable_ (build/cythonized/sage/symbolic/expression.cpp:62484)
    return fast_callable(self, etb)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1851, in fast_callable
    return FastCallableConverter(ex, etb)()
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 217, in __call__
    return self.arithmetic(ex, operator)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1779, in arithmetic
    return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1779, in <lambda>
    return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
  File "sage/ext/fast_callable.pyx", line 779, in sage.ext.fast_callable.ExpressionTreeBuilder.call (build/cythonized/sage/ext/fast_callable.c:7242)
    return self(base)**exponent
  File "sage/ext/fast_callable.pyx", line 656, in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (build/cythonized/sage/ext/fast_callable.c:6431)
    return fc(self)
  File "sage/symbolic/expression.pyx", line 11942, in sage.symbolic.expression.Expression._fast_callable_ (build/cythonized/sage/symbolic/expression.cpp:62484)
    return fast_callable(self, etb)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1851, in fast_callable
    return FastCallableConverter(ex, etb)()
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 217, in __call__
    return self.arithmetic(ex, operator)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1779, in arithmetic
    return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1779, in <lambda>
    return reduce(lambda x,y: self.etb.call(operator, x,y), operands)
  File "sage/ext/fast_callable.pyx", line 781, in sage.ext.fast_callable.ExpressionTreeBuilder.call (build/cythonized/sage/ext/fast_callable.c:7296)
    return ExpressionCall(self, fn, [self(a) for a in args])
  File "sage/ext/fast_callable.pyx", line 656, in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (build/cythonized/sage/ext/fast_callable.c:6431)
    return fc(self)
  File "sage/symbolic/expression.pyx", line 11942, in sage.symbolic.expression.Expression._fast_callable_ (build/cythonized/sage/symbolic/expression.cpp:62484)
    return fast_callable(self, etb)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1851, in fast_callable
    return FastCallableConverter(ex, etb)()
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 211, in __call__
    return self.symbol(ex)
  File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1800, in symbol
    return self.etb.var(SR(ex))
  File "sage/ext/fast_callable.pyx", line 728, in sage.ext.fast_callable.ExpressionTreeBuilder.var (build/cythonized/sage/ext/fast_callable.c:6893)
    raise ValueError("Variable '%s' not found" % var_name)
ValueError: Variable 'x' not found

​
edit retag flag offensive close merge delete

Comments

Please edit your post and mark the code/error sections as code (select a block of text and press the 101010 button).

rburing gravatar imagerburing ( 2019-02-12 13:40:22 +0100 )edit

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

you can observe and the error in this worksheet.

Thank you. I will also edit my code. i was looking for that markup option and was confused because i expected it to exist and could not identify it.

stockh0lm gravatar imagestockh0lm ( 2019-02-12 23:18:57 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2019-02-13 09:41:56 +0100

eric_g gravatar image

Replace the == by = in the lines

e_0 == 8.854 * 10^-12
e_s == e_0 * 3.5
e_m == e_0 * 81

and your code will work. Indeed == is the comparison operator, not the assignment one, which is .

Besides, you may redefine p as a callable symbolic variable:

p(e, Q, r) = 1/(4*pi*e)*Q/r

so that the definitions of p_1,...,p_4 become simpler:

p_1 = p(e_m, 1, x)
p_2 = p(e_m, -1, d_e-x)
p_3 = p(e_Ersatz, -1, sqrt((2*d_k)^2+x^2))
p_4 = p(e_Ersatz, 1, sqrt((2*d_k)^2+(d_e -x)^2))
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-02-12 13:32:31 +0100

Seen: 530 times

Last updated: Feb 13 '19