Ask Your Question

# How do i specify (temporary) values for variables?

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 close merge delete

## 1 Answer

Sort by » oldest newest most voted 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.

more

## 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-11 16:41:29 +0200

Seen: 91 times

Last updated: Feb 12 '19