ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 29 Oct 2011 14:23:52 -0500Problem with solvehttp://ask.sagemath.org/question/8414/problem-with-solve/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
Thu, 27 Oct 2011 16:19:28 -0500http://ask.sagemath.org/question/8414/problem-with-solve/Answer by saradocbrandi for <p>Hi, I'm very very new in Sage. I have a problem trying this:</p>
<pre><code>x=var('x')
f=10*(1-exp(-0.23*(x)))^2
g=20*(1-exp(0.23*(x-14)))^2-10
</code></pre>
<p>I'm want to get the intersection point(s). From Maple, I know there is three, but when I try to solve for x:</p>
<pre><code>solve(f==g,x)
[ ]
</code></pre>
<p>Sage gives me that [ ]! What does it mean?
Thanks in advance</p>
http://ask.sagemath.org/question/8414/problem-with-solve/?answer=12837#post-id-12837My 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.Sat, 29 Oct 2011 09:43:46 -0500http://ask.sagemath.org/question/8414/problem-with-solve/?answer=12837#post-id-12837Comment by kcrisman for <p>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.</p>
<p>Bye bye.</p>
http://ask.sagemath.org/question/8414/problem-with-solve/?comment=20998#post-id-20998Great, glad we could help. Also, appreciate the Tolkien reference in the username. Sat, 29 Oct 2011 14:23:52 -0500http://ask.sagemath.org/question/8414/problem-with-solve/?comment=20998#post-id-20998Answer by kcrisman for <p>Hi, I'm very very new in Sage. I have a problem trying this:</p>
<pre><code>x=var('x')
f=10*(1-exp(-0.23*(x)))^2
g=20*(1-exp(0.23*(x-14)))^2-10
</code></pre>
<p>I'm want to get the intersection point(s). From Maple, I know there is three, but when I try to solve for x:</p>
<pre><code>solve(f==g,x)
[ ]
</code></pre>
<p>Sage gives me that [ ]! What does it mean?
Thanks in advance</p>
http://ask.sagemath.org/question/8414/problem-with-solve/?answer=12828#post-id-12828Just 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
Thu, 27 Oct 2011 16:32:05 -0500http://ask.sagemath.org/question/8414/problem-with-solve/?answer=12828#post-id-12828Comment by DSM for <p>Just putting this in standard syntax:</p>
<pre><code>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)
[]
</code></pre>
<p>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.</p>
<pre><code>sage: solve(f==g,x,to_poly_solve=True) # invokes another type of solver, but one which doesn't always return exact answers
[]
</code></pre>
<p>But there is another issue, which is that <code>solve</code> (which is from Maxima's solve) seeks <em>exact</em> solutions, in general. If it can't solve it exactly, it may indeed return no answers, even if there are some. </p>
<p>Now, a little playing with <code>find_root</code> discovers something interesting.</p>
<pre><code>sage: f.subs(x=1000)
10.0000000000000
sage: g.subs(x=1000)
10.0000000000000
</code></pre>
<p>Well, maybe Maxima's solve capabilities should have found that... but apparently it didn't. However, you may find <code>find_root</code> is what you are actually interested in.</p>
<pre><code>sage: find_root(f-g,0,20)
11.070582936901683
</code></pre>
http://ask.sagemath.org/question/8414/problem-with-solve/?comment=21015#post-id-21015I 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.Thu, 27 Oct 2011 17:51:45 -0500http://ask.sagemath.org/question/8414/problem-with-solve/?comment=21015#post-id-21015Comment by kcrisman for <p>Just putting this in standard syntax:</p>
<pre><code>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)
[]
</code></pre>
<p>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.</p>
<pre><code>sage: solve(f==g,x,to_poly_solve=True) # invokes another type of solver, but one which doesn't always return exact answers
[]
</code></pre>
<p>But there is another issue, which is that <code>solve</code> (which is from Maxima's solve) seeks <em>exact</em> solutions, in general. If it can't solve it exactly, it may indeed return no answers, even if there are some. </p>
<p>Now, a little playing with <code>find_root</code> discovers something interesting.</p>
<pre><code>sage: f.subs(x=1000)
10.0000000000000
sage: g.subs(x=1000)
10.0000000000000
</code></pre>
<p>Well, maybe Maxima's solve capabilities should have found that... but apparently it didn't. However, you may find <code>find_root</code> is what you are actually interested in.</p>
<pre><code>sage: find_root(f-g,0,20)
11.070582936901683
</code></pre>
http://ask.sagemath.org/question/8414/problem-with-solve/?comment=21012#post-id-21012Yup, you're right. Does that mean x=10 is not a solution? ;-)Fri, 28 Oct 2011 03:00:02 -0500http://ask.sagemath.org/question/8414/problem-with-solve/?comment=21012#post-id-21012Answer by saradocbrandi for <p>Hi, I'm very very new in Sage. I have a problem trying this:</p>
<pre><code>x=var('x')
f=10*(1-exp(-0.23*(x)))^2
g=20*(1-exp(0.23*(x-14)))^2-10
</code></pre>
<p>I'm want to get the intersection point(s). From Maple, I know there is three, but when I try to solve for x:</p>
<pre><code>solve(f==g,x)
[ ]
</code></pre>
<p>Sage gives me that [ ]! What does it mean?
Thanks in advance</p>
http://ask.sagemath.org/question/8414/problem-with-solve/?answer=12833#post-id-12833Thank you for spend your time answering my question. Finally I used Maple in the solving of my problem.
Greetings.Fri, 28 Oct 2011 16:46:08 -0500http://ask.sagemath.org/question/8414/problem-with-solve/?answer=12833#post-id-12833