ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 31 Mar 2020 16:35:14 +0200Solving for an unknown function in a logarithmic expressionhttps://ask.sagemath.org/question/50445/solving-for-an-unknown-function-in-a-logarithmic-expression/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
curios_mindTue, 31 Mar 2020 16:35:14 +0200https://ask.sagemath.org/question/50445/log_integral gives wrong values for complex argumentshttps://ask.sagemath.org/question/24630/log_integral-gives-wrong-values-for-complex-arguments/Riemann's formula for the number of primes less than a given number requires the calculation of the logarithmic integral (Li(x) or li(x)) for complex values. This function is implemented in Sage as log_integral.
However, it does not seem to give the correct values for complex arguments. When I feed in -4.42464733272289 + 0.649996908475887*I it returns -0.0380977804390431 + 4.49840994945387*I, but -4.41940689179334 - 0.684720910130221*I returns -0.0281163576275170 - 4.50165559913773*I, i.e., there seems to be a discontinuity when the imaginary part turns negative.
This script shows the behaviour:
start = 0
end = 10
steps = 100
args = [(start * (1 - s / steps) + end * (s / steps)) for s in range(steps+1)]
val1 = [20^(1/2+s*i) for s in args]
val2 = [log_integral(s) for s in val1]
for (x,y,z) in zip(args, val1, val2):
print n(x), '\t', n(y), '\t', n(z)
Maybe the problem is that a different branch of the complex logarithm should be used. But the values of the above sequence should converge to pi * i, which doesn't seem to be the case at all.
Has anybody seen this behaviour before or any idea how to fix it?Markus SchepkeSat, 25 Oct 2014 17:15:02 +0200https://ask.sagemath.org/question/24630/Plotting with logarithmic scaling for the 'x' axis?https://ask.sagemath.org/question/9106/plotting-with-logarithmic-scaling-for-the-x-axis/Hey! Would appreciate very much a bit of help:
I have an Array of data of Positions Vs. Time intervals, where Time goes from 0 to 10000, and every slot on the array represents a time interval of 100. The question is - is there any way to plot the data in the array using List_plot...show(), but with a logarithmic scaled 'x' axis ? Meaning - labels running as - 10^(-4), 10^(-3), ..., 10^5?
Thank you! ErezSun, 24 Jun 2012 10:14:21 +0200https://ask.sagemath.org/question/9106/