1 | initial version |
You can subs
titute the expression p(time)
by an expression having the desired value :
sage: p=function("p")
sage: aws(time)=921600*(-1333.33340000000*time + 2000)/(-3.36000004800000e6*p(time) + 3840000)
sage: aws(time).subs(p(time)==(time^0.54))
(-1.22880006144000e9*time + 1843200000)/(-3.36000004800000e6*time^0.540000000000000 + 3840000)
You can also explicitly define your new function, then use the substitute_function
method :
sage: foo(time)=time^0.54
sage: aws(time).substitute_function(p,foo)
(-1.22880006144000e9*time + 1843200000)/(-3.36000004800000e6*time^0.540000000000000 + 3840000)
You can also dispense with explicitly defining foo, and use the function
method of symbolic expressions to create an anonymous function on the fly :
sage: aws(time).substitute_function(p,(time^0.54).function(time))
(-1.22880006144000e9*time + 1843200000)/(-3.36000004800000e6*time^0.540000000000000 + 3840000)
Note : your code may be easier to read if you use either supplementary arguments, symbolic variables or Python variables in place of your numeric constants :
# Python variables :
sage: c1 = -1.22880006144000e9
sage: c2 = 1843200000
sage: c3 = -3.36000004800000e6
sage: c4 = 3840000
sage: aws2(time) = (c1*time + c2)/(c3*p(time) + c4) ; aws2
time |--> (-1.22880006144000e9*time + 1843200000)/(-3.36000004800000e6*p(time) + 3840000)
# Symbolic variables
sage: var("k1, k2, k3, k4")
sage: aws3(time) = (k1*time + k2)/(k3*p(time) + k4) ; aws3(time).subs({k1:-1.22880006144000e9, k2:1843200000, k3:-3.36000004800000e6, k4:3840000})
(-1.22880006144000e9*time + 1843200000)/(-3.36000004800000e6*p(time) + 3840000)
# Symbolic arguments
sage: aws4(time, k1, k2, k3, k4) = (k1*time + k2)/(k3*p(time) + k4) ; aws4(time, -1.22880006144000e9, 1843200000, -3.36000004800000e6, 3840000)
(-1.22880006144000e9*time + 1843200000)/(-3.36000004800000e6*p(time) + 3840000)
I strongly recommend this book and a good Python tutorial (legins of them...).
HTH,
2 | No.2 Revision |
You can subs
titute the expression p(time)
by an expression having the desired value :
sage: p=function("p")
sage: aws(time)=921600*(-1333.33340000000*time + 2000)/(-3.36000004800000e6*p(time) + 3840000)
sage: aws(time).subs(p(time)==(time^0.54))
(-1.22880006144000e9*time + 1843200000)/(-3.36000004800000e6*time^0.540000000000000 + 3840000)
You can also explicitly define your new function, then use the substitute_function
method :
sage: foo(time)=time^0.54
sage: aws(time).substitute_function(p,foo)
(-1.22880006144000e9*time + 1843200000)/(-3.36000004800000e6*time^0.540000000000000 + 3840000)
You can also dispense with explicitly defining foo, and use the function
method of symbolic expressions to create an anonymous function on the fly :
sage: aws(time).substitute_function(p,(time^0.54).function(time))
(-1.22880006144000e9*time + 1843200000)/(-3.36000004800000e6*time^0.540000000000000 + 3840000)
Note : your code may be easier to read if you use either supplementary arguments, symbolic variables or Python variables in place of your numeric constants :
#
I strongly recommend this book and (along a a good Python tutorial (legins tutorial, of them...).which there is legions...) to "get the hang" of Sage...
HTH,
3 | No.3 Revision |
You can subs
titute the expression p(time)
by an expression having the desired value :
sage: p=function("p")
sage: aws(time)=921600*(-1333.33340000000*time + 2000)/(-3.36000004800000e6*p(time) + 3840000)
sage: aws(time).subs(p(time)==(time^0.54))
(-1.22880006144000e9*time + 1843200000)/(-3.36000004800000e6*time^0.540000000000000 + 3840000)
You can also explicitly define your new function, then use the substitute_function
method :
sage: foo(time)=time^0.54
sage: aws(time).substitute_function(p,foo)
(-1.22880006144000e9*time + 1843200000)/(-3.36000004800000e6*time^0.540000000000000 + 3840000)
You can also dispense with explicitly defining foo, and use the function
method of symbolic expressions to create an anonymous function on the fly :
sage: aws(time).substitute_function(p,(time^0.54).function(time))
(-1.22880006144000e9*time + 1843200000)/(-3.36000004800000e6*time^0.540000000000000 + 3840000)
Note : your code may be easier to read if you use either supplementary arguments, symbolic variables or Python variables in place of your numeric constants :
#
Python variables I strongly recommend this book (along a a good Python tutorial, of which there is legions...) to "get the hang" of Sage...
HTH,