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.Mon, 22 May 2023 23:51:56 +0200Plotting error message regarding numerical type of function argumentshttps://ask.sagemath.org/question/68663/plotting-error-message-regarding-numerical-type-of-function-arguments/ I am trying to plot the following function:
x = var('x')
def y(x): return RR(len(prime_range(floor(0.95 * x), floor(1.25 * x))) / round(1.25 * x - 0.95 * x))
I am not sure whether it is well-constructed mathematically, but it's trying to check the density of prime numbers around a given value `x` I am using the `floor()` function because I'm not sure that `prime_range()` accepts non-integers.
If I test the function with random real values of `x` I get a plausible output without errors.
However, when I try to plot the function as in:
plot(y(x), (x, 5, 20))
I get the following error message:
TypeError: unable to convert floor(0.950000000000000*x) to an integer
and argument is also not real: unable to simplify to float approximation
I don't understand why this input cannot be understood as real by sagemath, or why the floor is not an integer.toniMon, 22 May 2023 23:51:56 +0200https://ask.sagemath.org/question/68663/