Ask Your Question
1

when plot()ing, where can i call .lower() and .upper() in order to get the band of uncertainty?

asked 2019-02-17 23:39:04 +0200

stockh0lm gravatar image

when i plot a function with parameters with and upper and lower value like this:

p1=plot( v_ges_rhs.subs({
                d_e : RIF(.999,1.001),
                x : -.25,
                d_m : RIF(.05,.15),
                e_m : e_0 * RIF(80.5,81.5),
                e_s : e_0 * RIF(3,4)
               }), ( d_k, 0.2, .99 ) )

at what point can i call .lower() or .upper() to get the lower or upper boundary of my function? I would then overlay both into one graph for visualisation of the error.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-02-18 12:52:15 +0200

rburing gravatar image

updated 2019-02-18 13:10:19 +0200

Let's define

idk = v_ges_rhs.subs({
                d_e : RIF(.999,1.001),
                x : -.25,
                d_m : RIF(.05,.15),
                e_m : e_0 * RIF(80.5,81.5),
                e_s : e_0 * RIF(3,4)
               })

This is a symbolic expression containing RIF numbers and the only symbolic variable is d_k.

At any point in the interval we can evaluate it to a symbolic expression which is just a RIF number, e.g.

sage: idk.subs({d_k : 0.2})
-1.?e10

Unfortunately we cannot call .upper() on this directly, because there is still a symbolic wrapper around it:

sage: type(idk.subs({d_k : 0.2}))
<type 'sage.symbolic.expression.Expression'>

To remove the wrapper, we use conversion to RIF:

sage: RIF(idk.subs({d_k : 0.2}))
-1.?e10
sage: RIF(idk.subs({d_k : 0.2})).upper()
-6.57758536841850e9
sage: RIF(idk.subs({d_k : 0.2})).lower()
-8.63461563768822e9

We can define functions which do this at a given point

f = lambda x: idk.subs({d_k: x})
f_lower = lambda x: RIF(idk.subs({d_k : x})).lower()
f_upper = lambda x: RIF(idk.subs({d_k : x})).upper()

and plot them:

plot([f, f_lower, f_upper],(x,0.2,0.99), color=['blue', 'red', 'green'])

RIF plot

edit flag offensive delete link more

Comments

1

awesome, this is an excellent answer and helps me a lot

stockh0lm gravatar imagestockh0lm ( 2019-02-18 22:56:23 +0200 )edit

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-17 23:39:04 +0200

Seen: 371 times

Last updated: Feb 18 '19