Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #16684 > unrolled thread
| Started by | Ray Koopman <koopman@sfu.ca> |
|---|---|
| First post | 2014-03-23 08:59 +0000 |
| Last post | 2014-03-30 08:42 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Re: Problems with Solve Ray Koopman <koopman@sfu.ca> - 2014-03-23 08:59 +0000
Re: Problems with Solve Unknown <dog@gmail.com> - 2014-03-30 08:42 +0000
| From | Ray Koopman <koopman@sfu.ca> |
|---|---|
| Date | 2014-03-23 08:59 +0000 |
| Subject | Re: Problems with Solve |
| Message-ID | <lgm7pn$14$1@smc.vnet.net> |
1. Use NRoots[z + 5 (z^2 - 1) + 1 z^3 == 1, z], then pick the root you want.
2. B[s_?NumericQ] := Piecewise[{{Erfc[-x]+Erfc[y]-Erfc[z], s >= .5}}, Erfc[-x]]
----- 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
>
>
[toc] | [next] | [standalone]
| From | Unknown <dog@gmail.com> |
|---|---|
| Date | 2014-03-30 08:42 +0000 |
| Message-ID | <lh8ldk$bed$1@smc.vnet.net> |
| In reply to | #16684 |
On Sun, 23 Mar 2014 08:59:35 +0000, Ray Koopman wrote:
> 1. Use NRoots[z + 5 (z^2 - 1) + 1 z^3 == 1, z], then pick the root you
> want.
>
> 2. B[s_?NumericQ] := Piecewise[{{Erfc[-x]+Erfc[y]-Erfc[z], s >= .5}},
> Erfc[-x]]
>
> ----- Samuel Mark Young <sy81@sussex.ac.uk> wrote:
>> 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...
Wow, I manually entered <1> to the rPi <creditCardSized computer>.
Amazing: but where's the syntax [without TOO much commercials] for my
free version of mathematica?
Why did the OP use "Solve"?
And how did the look-ma-no-hands-demo respondent [whithout any
elaboration/explanation to add value] know to use a different syntax?
And, within the context of <solutions of cubic equations>, what is
the meaning of "== 1, z"?
== TIA.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web