Ask Your Question
0

Difficulty with log and ploting log

asked 2022-11-01 19:32:19 +0200

anonymous user

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 flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2022-11-02 11:00:57 +0200

slelievre gravatar image

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))
edit flag offensive delete link more
0

answered 2022-11-01 23:50:59 +0200

Emmanuel Charpentier gravatar image

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,

edit flag offensive delete link more

Comments

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

CoolAlex gravatar imageCoolAlex ( 2022-11-02 01:15:37 +0200 )edit

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: 2022-11-01 19:06:14 +0200

Seen: 108 times

Last updated: Nov 02 '22