Student Support Forum: 'Slve mathematica code' topicStudent Support Forum > General > Archives > "Slve mathematica code"

 < Previous Comment Help | Reply To Comment | Reply To Topic
 Author Comment/Response Bill Simpson 01/24/13 00:03am If you multiply to remove the denominators in your NSolve you may have fewer problems. Example eqsolution = NSolve[{urn - 1/urn^3 - P/(urn^3 uzn) ((1 + 16 \[CurlyEpsilon]0 \[CurlyEpsilon]1^(3/2\) A0) == 0, \[Lambda]^2 uzn - 1/(uzn^3) - P/(urn^2 uzn^2) (1 + 16 \[CurlyEpsilon]0 \[CurlyEpsilon]1^(3/2) A1)}, {urn, uzn}]; becomes eqsolution = NSolve[{urn^4 uzn - uzn - P (1 + 16 \[CurlyEpsilon]0 \[CurlyEpsilon]1^(3/2\) A0) == 0, \[Lambda]^2 urn^2 uzn^4 - urn\^2 - uzn P (1 + 16 \[CurlyEpsilon]0 \[CurlyEpsilon]1^(3/2) A1)}, {urn, uzn}]; Sometimes that can allow solutions that would otherwise not be valid, but for what you are doing your original method was giving me divide by zero errors at times. Next you can greatly simplify your looking for real positive solutions by replacing this ll = Length[eqsolution]; For[i = 1, i ≤ ll, i++, {urn, uzn} = {urn, uzn} /. eqsolution[[i]]; If[(urn ∈ Reals) && (uzn ∈ Reals), If[(urn > 0) && (uzn > 0),(*Print[N[urn], " ", N[uzn]];*)mem = i;]]; Clear[urn, uzn]; ]; {ur, uz} = {urn, uzn} /. eqsolution[[mem]] with this {ur, uz} = Cases[{urn,uzn} /. eqsolution, {r_Real, z_Real} /; r > 0 && z > 0][[-1]] Finally, there are several different ways you could plot your result. Here is one urtable = Table[{B0,First[F1[P, Δ, λ, Bres, ε0, ε1, H, B0]]}, {B0, 0.015, 0.016, .001}]; uztable = Table[{B0, Last[F1[P, Δ, λ, Bres, ε0, ε1, H, B0]]}, {B0, 0.015, 0.016, .001}]; Show[{ ListPlot[urtable, Joined -> True], ListPlot[uztable, Joined -> True] }] You will need to choose the range and step size for B0 that you want to use. Using Table will let you carefully control exactly what B0 you wish to see and ListPlot with Joined will give you some indication of how ur and uz behave. There are more complicated ways of doing this, but hopefully this is simple enough that you can see how it was done and be able to adapt it to your needs. URL: ,

 Subject (listing for 'Slve mathematica code') Author Date Posted Slve mathematica code sassari 01/23/13 3:22pm Re: Slve mathematica code Bill Simpson 01/24/13 00:03am
 < Previous Comment Help | Reply To Comment | Reply To Topic