Dear BFJ,
thanks a lot for your answer. It works very nice!
Alternatively, I found that using the rhs() method also works. My idea
was to substitute the algebraic expression of the solution, and inserted
as denominator of a new function:
sage: f(x) = ( 1-e**(t/tau0) )*(e**(-x/tau1)) # this is the origin function
sage: S = solve(derivative(f,x)==0,x) # this is the solution at the peak
sage: tpeak = S[0].rhs() # this is the algebraic solution
sage: ypeak = f(tpeak) # y-value expressed as tau0 and tau1
sage: f_norm(x) = f(x)/ypeak # we nor normalize the function to the
ypeak value
It works like a charm!!! I love Sage!
Best
JOse.
BFJ wrote:
To get the value of 'x' from solve you can use the option
solultion_dict = true as follows:
sage: S = solve(derivative(f,x)==0,x, solution_dict=true)
sage: S[0][x]
tau0*log(tau1/tau0 + 1)
sage: S[0][x].subs(tau0=0.5, tau1=5.0)
1.19894763639919
Also, using the 'N' function will evaluate numerical expressions to a
desired level of accuracy
sage: N(S[0][x].subs(tau0=0.5, tau1=5.0), digits=25)
1.198947636399185334710182
-BFJ
On Mar 16, 5:32 pm, Jose Guzman <[email protected]> wrote:
Hi everybody again.
Does anybody if it is possible to use the result of the function solve
to insert it in a function to resolve it analitically.
For example, I want to get the peak of the following function
>>> var('tau0,tau1')
>>> f(x) = (1-e**(-x/tau0))*(e**(-x/tau1))
For that, I simply derive it and equal to zero
>>> solve(derivative(f,x)==0,x)
>>> [x == tau0*log(tau1/tau0 + 1), e^(-(tau0 + tau1)*x/(tau0*tau1)) == 0]
I would like to take the first expression of that list
>>> xpeak = solve(derivative(f,x)==0,x)[0]
for example, to calculate its value when tau0=0.5 and tau1=5.0
>>> xpeak.subs(tau0=.5, tau1=5.0)
but this returns a symbolic expresion ,
t == 0.500000000000000*log(11.0000000000000)
and not the scalar 1.1989
More importantly, I would like to use this expression to solve
analytically the y value of that equation as a function of tau0 and tau1
Any suggestion would be greatly appreciated!
Best
Jose.
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org