Ask Your Question
0

Problem with solve

asked 2011-10-27 23:19:28 +0100

saradocbrandi gravatar image

updated 2011-10-27 23:44:34 +0100

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

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2011-10-27 23:32:05 +0100

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

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 ( 2011-10-28 00:51:45 +0100 )edit

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

kcrisman gravatar imagekcrisman ( 2011-10-28 10:00:02 +0100 )edit
0

answered 2011-10-29 16:43:46 +0100

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.

edit flag offensive delete link more

Comments

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

kcrisman gravatar imagekcrisman ( 2011-10-29 21:23:52 +0100 )edit
0

answered 2011-10-28 23:46:08 +0100

saradocbrandi gravatar image

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

edit flag offensive delete link more

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: 2011-10-27 23:19:28 +0100

Seen: 1,808 times

Last updated: Oct 29 '11