Re: recursively solve equation and save the values only
- To: mathgroup at smc.vnet.net
- Subject: [mg125793] Re: recursively solve equation and save the values only
- From: Dana DeLouis <dana2010 at me.com>
- Date: Tue, 3 Apr 2012 04:44:25 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
> f = 5.68672 T + 6.46776 T^3
> t = Table[i, {i, 0.2, 3, 0.2}]
> sols = Table[Reduce[f == t[[i]], T, Reals], {i, Length[t]}]
> ... how to remove the T== ,
Hi. There are just a few ideas.
The Capital T looks like a built-in function, so I changed it to x.
f=5.68672 x+6.46776 x^3
sols=Table[Reduce[f==rhs,x,Reals],{rhs,0.2,3,0.2}] [[All,-1]]
{0.0351204,0.06995,0.104221,... etc}
Others...
sols=Flatten[x/.Table[Solve[f==rhs,x,Reals],{rhs,0.2,3,0.2}]]
sols=x/.Table[Solve[f==rhs,x,Reals],{rhs,0.2,3,0.2}][[All,-1]]
Sometimes for simple items, you may be able to get away with calling Solve/Reduce once.
Here, we are assuming (ie caution) that the first solution returns the Real part.
equ=(x/.FullSimplify[Solve[a x+b x^3==rhs,x][[1]]]) /. {a->5.68672,b->6.46776};
Table[equ,{rhs,0.2,3,0.2}]
{0.0351204, 0.06995, 0.104221,...etc}
As a side note, the above let's one do something like this:
Plot[equ,{rhs,-50,50},GridLines->Automatic]
= = = = = = = = = =
HTH :>)
Dana DeLouis
Mac & Math 8
= = = = = = = = = =
On Apr 2, 4:30 am, wyn smjy <wsmjy2... at gmail.com> wrote:
> Dear All,
>
> I am new to Mathematica. I am trying to recursively solve equation and
> saving the values into Table. Since I need the real solutions only so
> I use Reduce.
>
> The following is my code:
>
> f = 5.68672 T + 6.46776 T^3
>
> t = Table[i, {i, 0.2, 3, 0.2}]
>
> sols = Table[Reduce[f == t[[i]], T, Reals], {i, Length[t]}] {T ==
> 0.0351204, T == 0.06995, T == 0.104221, T == 0.137708, T == 0.170237,
> T == 0.201687, T == 0.231988, T == 0.26111, T == 0.289058, T ==
> 0.315857, T == 0.34155, T == 0.366188, T == 0.389828, T == 0.412529, T
> == 0.434347}
>
> The solution is OK as I compared it to other software as well. The
> only thing that matters me is how to remove the T== , i.e. I just need
> the solution and then to copy this into another table, say sols2 that
> contains
>
> sols2 = {0.0351204, 0.06995, 0.104221, T == 0.137708,.., 0.434347}
>
> I tried the following: sols2 = T/.sols but produce the following
> error:
>
> sols2 = ReplaceAll::reps: ... is neither a list of replacement rules
> nor a valid dispatch table, and so cannot be used for replacing. >>
>
> Does anyone know how to remove the T==?
>
> Thank you,
>
> Wayan