Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Problems with Solve
Replies: 3   Last Post: Mar 26, 2014 3:23 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Murray Eisenberg

Posts: 2,105
Registered: 12/6/04
Re: Problems with Solve
Posted: Mar 23, 2014 5:00 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

For first problem: Yes, indeed, it's the inherent limitation of finite
precision that's giving this non-real "fuzz" when you take N of the
exact solutions. Two cures are as follows:

solns = Solve[z + 5 (z^2 - 1) + 1 z^3 == 1, z];
Chop @ N[solns]
(* {{z->0.925423},{z->-4.47735},{z->-1.44807}} *)

NSolve[z + 5 (z^2 - 1) + 1 z^3 == 1, z]
(* {{z->-4.47735},{z->-1.44807},{z->0.925423}} *)


For second problem: What are x, y, and z? What equation are you trying
to solve for s?


On Mar 22, 2014, at 12:06 AM, Samuel Mark Young <sy81@sussex.ac.uk> wrote:

>
> Hello everyone,
> I'm trying to use the solutions of Solve from solving a cubic equation - however, it keeps returning complex answers when there are real solutions. For example:
>
> Solve[z + 5 (z^2 - 1) + 1 z^3 == 1, z]
>
> This equation has 3 real solutions. However, the answers returned when I ask mathematica for a decimal answer are complex (which I need to do later on when an integration needs solving numerically):
> {{z -> 0.925423 + 0. I}, {z -> -4.47735 +
> 2.22045*10^-16 I}, {z -> -1.44807 - 4.44089*10^-16 I}}
>
> I'm guessing this is to do with the finite precision that is used in the calculations as the imaginary components are very small, but am unsure how to deal with them and they shouldn't be there. Any suggestions?
>
>
> The second problem I am having is that I need to solve for s in a function B[s] == 10^-5, where B is some (complicated) function of s.
>
> The form of the function depends on s - and this is handled by If[] commands in the function B. For example, the s dependance might be:
>
> B[s]:=If[s<0.5,Erfc[-x],Erfc[-x]+Erfc[y]-Erfc[z]]
>
> B[s] is a smooth function of s.
>
> The problem seems to arise because, before it has found a solution for s, it can't decide which form of the function to use - and so just returns an error message (I've tried using Solve, NSolve, and FindRoot with different methods). However, since I'm only looking for a numerical solution it is easily possible to solve this manually using trial and improvement - which seems to be something that Mathematica should be able to do? But I can't figure out how.
>
> Please feel free to contact me directly at sy81@sussex.ac.uk with advice. Thank you in advance for any help!
>
> Regards,
> Sam
>
>


Murray Eisenberg murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 240 246-7240 (H)
University of Massachusetts
710 North Pleasant Street
Amherst, MA 01003-9305










Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.