Ask Your Question
0

Problem with solve

asked 13 years ago

saradocbrandi gravatar image

updated 13 years ago

Hi, I'm very very new in Sage. I have a problem trying this:

x=var('x')

f=10*(1-exp(-0.23*(x)))^2

g=20*(1-exp(0.23*(x-14)))^2-10

I'm want to get the intersection point(s). From Maple, I know there is three, but when I try to solve for x:

solve(f==g,x)

[ ]

Sage gives me that [ ]! What does it mean? Thanks in advance

Preview: (hide)

3 Answers

Sort by » oldest newest most voted
1

answered 13 years ago

kcrisman gravatar image

Just putting this in standard syntax:

sage: f = 10*(1-exp(-.23*x))^2
sage: g = 20*(1-exp(-.23*(x-14)))^2-10
sage: g
20*(e^(-0.230000000000000*x + 3.22000000000000) - 1)^2 - 10
sage: f
10*(e^(-0.230000000000000*x) - 1)^2
sage: solve(f==g,x)
[]

Sage gives solutions in list form by default. Python (which Sage is largely based upon) lists are in square brackets. This one has no items, so it is the empty list.

sage: solve(f==g,x,to_poly_solve=True)  # invokes another type of solver, but one which doesn't always return exact answers
[]

But there is another issue, which is that solve (which is from Maxima's solve) seeks exact solutions, in general. If it can't solve it exactly, it may indeed return no answers, even if there are some.

Now, a little playing with find_root discovers something interesting.

sage: f.subs(x=1000)
10.0000000000000
sage: g.subs(x=1000)
10.0000000000000

Well, maybe Maxima's solve capabilities should have found that... but apparently it didn't. However, you may find find_root is what you are actually interested in.

sage: find_root(f-g,0,20)
11.070582936901683
Preview: (hide)
link

Comments

1

I think you accidentally flipped a sign in the exponent of g, which changes the details a bit, but not the conclusion that (dividing into regions and then) using find_root is probably the way to go.

DSM gravatar imageDSM ( 13 years ago )

Yup, you're right. Does that mean x=10 is not a solution? ;-)

kcrisman gravatar imagekcrisman ( 13 years ago )
0

answered 13 years ago

saradocbrandi gravatar image

My apologies kcrisman, you were right. Maple solves it numerically too. I had to use find_root, that was the correct way. Maple has some advantages manipulating symbols, but I choose Sage. Thanks for your help.

Bye bye.

Preview: (hide)
link

Comments

Great, glad we could help. Also, appreciate the Tolkien reference in the username.

kcrisman gravatar imagekcrisman ( 13 years ago )
0

answered 13 years ago

saradocbrandi gravatar image

Thank you for spend your time answering my question. Finally I used Maple in the solving of my problem. Greetings.

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 13 years ago

Seen: 1,851 times

Last updated: Oct 29 '11