Difficulty with log and ploting log

Anonymous

x >= 0

x <= 2

g(x) = ln(x)

h(x) = (x - 2 ) ^ 2

f(x) = g(x) - h(x)

print(f)

show(plot(f))

i want to combine the funtions g(x) and h(x) but instead of giving me ln(x) - ( x - 2)^2, it gives me log(x) - (x-2)^2 for some reason after that, when i try to plot the funtion it is zoomed in too much(it only shows me form -1 to 1) and is also incorrect i would like to know if there is any simple ways to fix these problems

edit retag close merge delete

Sort by ยป oldest newest most voted

The plot command accepts a plotting range, which defaults to (-1, 1).

With a logarithm involved, only the positive part produces a plot.

To plot from 0 to 2:

sage: plot(f, (0, 2))

more

instead of giving me ln(x) - ( x - 2)^2, it gives me log(x) - (x-2)^2 for some reason

lnis a synonym oflog :

sage: ln
log


when i try to plot

On what range ?

the funtion it is zoomed in too much(it only shows me form -1 to 1)

Well... f is real-valued but for x>0 :

sage: f(x).limit(x=0)
Infinity
sage: f(-1)
I*pi - 9
`

HTH,

more

since the base for the log is e, i modified my code and now i want to know how to make my graph extend from x = 0 to x = 2 now it is only from 0 to 1

( 2022-11-02 01:15:37 +0100 )edit