# Solving for an unknown function in a logarithmic expression Anonymous

Hello,

k=var('k')
f=function('f')(x)
solve(-1/3*log(f(x) + 1) + 1/3*log(f(x) - 2) == -k+x, f,to_poly_solve=True)


even if I call the solve function as

solve(-1/3*log(f(x) + 1) + 1/3*log(f(x) - 2) == -k+x, f(x),to_poly_solve=True)


or

solve(-1/3*log(f + 1) + 1/3*log(f - 2) == -k+x, f,to_poly_solve=True)


or

solve(-1/3*log(f+ 1) + 1/3*log(f - 2) == -k+x, f(x),to_poly_solve=True)


This always throws back [] at me.

However, if I substitue the function f with the variable z as shown below

k=var('k')
f=function('f')(x)
z=var('z')
solve((-1/3*log(f(x) + 1) + 1/3*log(f(x) - 2) == -k+x).subs(f(x)==z), z,to_poly_solve=True)


[z == (2*e^(3*k) + e^(3*x))/(e^(3*k) - e^(3*x))]


Under normal circumstances (where I don't need to use to_poly_solve=True) solve solves for the function.

Is there anyway to solve for a function (without the need to substitute it with a variable) when to_poly_solve=True is enabled?

edit retag close merge delete

Sort by » oldest newest most voted

solve solves for variables, not for functions. But, noting that you do not use the function per se but only function value, you can get (approximately) what you want by substituting a temporary variable to this unknown function value. Executing :

k,z=var('k,z')
f=function('f')(x)
S=solve((-1/3*log(f(x) + 1) + 1/3*log(f(x) - 2) == -k+x).subs(f(x)==z), f(x).subs(f(x)==z), to_poly_solve=True)
f(x)=S.rhs()


gives you a warning:

/usr/local/sage-9/local/lib/python3.7/site-packages/sage/repl/load.py:272: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...) See http://trac.sagemath.org/5930 for details.

But, nonetheless :

sage: f
x |--> (2*e^(3*k) + e^(3*x))/(e^(3*k) - e^(3*x))


My preferences would rather go to :

k,z=var('k,z')
S=solve((-1/3*log(z + 1) + 1/3*log(z - 2) == -k+x), z, to_poly_solve=True)
f(x)=S.rhs()


which doesn't declare f only to redefine it two lines down...

HTH,

more