Ask Your Question
0

Solving for an unknown function in a logarithmic expression

asked 2020-03-31 16:35:14 +0100

anonymous user

Anonymous

Hello,

Please consider the following code:

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)

I get an answer

[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?

Thanks in advance

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-04-02 11:51:25 +0100

Emmanuel Charpentier gravatar image

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[0].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[0].rhs()

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

HTH,

edit flag offensive delete link more

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: 2020-03-31 16:35:14 +0100

Seen: 397 times

Last updated: Apr 02 '20