Ask Your Question
2

How do i specify (temporary) values for variables?

asked 2019-02-11 16:41:29 +0100

stockh0lm gravatar image

updated 2019-02-12 23:22:55 +0100

I have a longer symbolic calculation with several variables, e.g.:

var('x d_k d_e d_m r Q e e_Ersatz e_m e_s')

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

e_Ersatz = d_k * ( (e_m/d_m) + (e_s/(d_k-d_m) ) )

p_4 = p(e = e_Ersatz, Q = 1, r = sqrt((2*d_k)^2+(d_e -x)^2))

show(p_4.plot(x))

Now i want to plot p_4 in respect to x, and specify temporary numerical values for d_k d_e d_m r Q e e_Ersatz e_m e_s, to see how that function looks for some example values. But how do I give numeric values for variables at this point? I would like to continue the symbolic calculations after that. Apparently it would work if I specified values for the variables in the beginning, but i am really interested in the symbolic solution to this problem.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-02-11 19:31:02 +0100

rburing gravatar image

You can make a substitution into p_4 and plot the result, e.g.:

plot(p_4.subs(d_e == 0, d_k == 1/2, d_m == 1, e_m == 1, e_s == 1), (x,-5,5))

The substitution into p_4 returns a new expression, and does not alter p_4 itself.

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

2 followers

Stats

Asked: 2019-02-11 16:41:29 +0100

Seen: 341 times

Last updated: Feb 12 '19