Thanks a lot! Berend Hasselman <bhh at xs4all.nl>, 20 Kas 2018 Sal, 12:02 tarihinde ?unu yazd?:> > > R package Ryacas may be what you want. > > Berend > > > > On 20 Nov 2018, at 09:42, Engin Y?lmaz <ispanyolcom at gmail.com> wrote: > > > > Dea(R) > > > > Do you know any system solver in R ? > > > > For example, in matlab, is very easy > > > > syms a b c x eqn = a*x^2 + b*x + c == 0; sol = solve(eqn) > > > > How can I find this type code in R (or directly solver)? > > > > *Since(R)ely* > > Engin YILMAZ > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > >-- *Sayg?lar?mla* Engin YILMAZ [[alternative HTML version deleted]]
Dea(R)
I try to solve one equation but this program did not give me real roots
for example
yacas("Solve( 5/((1+x)^1) + 5/((1+x)^2) + 5/((1+x)^3) + 105/((1+x)^4) -105
==0, x)")
gave me following results
How can I find real roots?
expression(list(x == complex_cartesian((1/42 - ((1/63 -
((root(7339451281/3087580356,
2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356,
2))^(1/3)))/21 - -2/21)/(4 * root(((root(7339451281/3087580356,
2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356,
2))^(1/3) - 1/63)^2/4 + 1, 2)))/2 - 1, root(4 *
(((root(7339451281/3087580356,
2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356,
2))^(1/3) - 1/63)/2 + root(((root(7339451281/3087580356,
2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356,
2))^(1/3) - 1/63)^2/4 + 1, 2)) - (((1/63 -
((root(7339451281/3087580356,
2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356,
2))^(1/3)))/21 - -2/21)/(4 * root(((root(7339451281/3087580356,
2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356,
2))^(1/3) - 1/63)^2/4 + 1, 2)) - 1/42)^2, 2)/2),...more
Engin Y?lmaz <ispanyolcom at gmail.com>, 20 Kas 2018 Sal, 12:53 tarihinde
?unu
yazd?:
> Thanks a lot!
>
> Berend Hasselman <bhh at xs4all.nl>, 20 Kas 2018 Sal, 12:02 tarihinde
?unu
> yazd?:
>
>>
>>
>> R package Ryacas may be what you want.
>>
>> Berend
>>
>>
>> > On 20 Nov 2018, at 09:42, Engin Y?lmaz <ispanyolcom at
gmail.com> wrote:
>> >
>> > Dea(R)
>> >
>> > Do you know any system solver in R ?
>> >
>> > For example, in matlab, is very easy
>> >
>> > syms a b c x eqn = a*x^2 + b*x + c == 0; sol = solve(eqn)
>> >
>> > How can I find this type code in R (or directly solver)?
>> >
>> > *Since(R)ely*
>> > Engin YILMAZ
>> >
>> > [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more,
see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
> --
> *Sayg?lar?mla*
> Engin YILMAZ
>
--
*Sayg?lar?mla*
Engin YILMAZ
[[alternative HTML version deleted]]
A bit pedestrian, but you might try
pf <- function(x){5/((1+x)^1) + 5/((1+x)^2) + 5/((1+x)^3) + 105/((1+x)^4)
-105}
uniroot(pf,c(-10,10))
curve(pf, c(-10,10))
require(pracma)
tryn <- newton(pf, 0)
tryn
pf(0)
pf(0.03634399)
yc <- c(-105, 5,5,5,105)
rooty <- polyroot(yc)
rooty
rootx <- 1/rooty - 1
rootx
There are lots of rootfinders, and the histoRicalg project
(https://gitlab.com/nashjc/histoRicalg)
that is supported by the R Consortium to look into older codes has quite a bit
on rootfinders.
JN
On 2018-11-20 7:09 a.m., Engin Y?lmaz wrote:>
>
> Dea(R)
> I try to solve one equation but this program did not give me real roots
> for example
> yacas("Solve( 5/((1+x)^1) + 5/((1+x)^2) + 5/((1+x)^3) + 105/((1+x)^4)
-105
> ==0, x)")
> gave me following results
> How can I find real roots?
>
> expression(list(x == complex_cartesian((1/42 - ((1/63 -
> ((root(7339451281/3087580356,
> 2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356,
> 2))^(1/3)))/21 - -2/21)/(4 * root(((root(7339451281/3087580356,
> 2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356,
> 2))^(1/3) - 1/63)^2/4 + 1, 2)))/2 - 1, root(4 *
> (((root(7339451281/3087580356,
> 2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356,
> 2))^(1/3) - 1/63)/2 + root(((root(7339451281/3087580356,
> 2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356,
> 2))^(1/3) - 1/63)^2/4 + 1, 2)) - (((1/63 -
> ((root(7339451281/3087580356,
> 2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356,
> 2))^(1/3)))/21 - -2/21)/(4 * root(((root(7339451281/3087580356,
> 2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356,
> 2))^(1/3) - 1/63)^2/4 + 1, 2)) - 1/42)^2, 2)/2),...more
>
>
>
>
> Engin Y?lmaz <ispanyolcom at gmail.com>, 20 Kas 2018 Sal, 12:53
tarihinde ?unu
> yazd?:
>
>> Thanks a lot!
>>
>> Berend Hasselman <bhh at xs4all.nl>, 20 Kas 2018 Sal, 12:02
tarihinde ?unu
>> yazd?:
>>
>>>
>>>
>>> R package Ryacas may be what you want.
>>>
>>> Berend
>>>
>>>
>>>> On 20 Nov 2018, at 09:42, Engin Y?lmaz <ispanyolcom at
gmail.com> wrote:
>>>>
>>>> Dea(R)
>>>>
>>>> Do you know any system solver in R ?
>>>>
>>>> For example, in matlab, is very easy
>>>>
>>>> syms a b c x eqn = a*x^2 + b*x + c == 0; sol = solve(eqn)
>>>>
>>>> How can I find this type code in R (or directly solver)?
>>>>
>>>> *Since(R)ely*
>>>> Engin YILMAZ
>>>>
>>>> [[alternative HTML version deleted]]
>>>>
>>>> ______________________________________________
>>>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and
more, see
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>>> and provide commented, minimal, self-contained, reproducible
code.
>>>
>>>
>>
>> --
>> *Sayg?lar?mla*
>> Engin YILMAZ
>>
>
>
> --
> *Sayg?lar?mla*
> Engin YILMAZ
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
How about this: library(rootSolve) f1<-function(x)5/((1+x)^1) + 5/((1+x)^2) + 5/((1+x)^3) + 105/((1+x)^4) -105 uniroot.all( f1,c(-1e6,1e6)) [1] -1.9881665 0.0363435 Cheers Am 20.11.2018 um 13:09 schrieb Engin Y?lmaz:> Dea(R) > I try to solve one equation but this program did not give me real roots > for example > yacas("Solve( 5/((1+x)^1) + 5/((1+x)^2) + 5/((1+x)^3) + 105/((1+x)^4) -105 > ==0, x)") > gave me following results > How can I find real roots? > > expression(list(x == complex_cartesian((1/42 - ((1/63 - > ((root(7339451281/3087580356, > 2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356, > 2))^(1/3)))/21 - -2/21)/(4 * root(((root(7339451281/3087580356, > 2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356, > 2))^(1/3) - 1/63)^2/4 + 1, 2)))/2 - 1, root(4 * > (((root(7339451281/3087580356, > 2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356, > 2))^(1/3) - 1/63)/2 + root(((root(7339451281/3087580356, > 2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356, > 2))^(1/3) - 1/63)^2/4 + 1, 2)) - (((1/63 - > ((root(7339451281/3087580356, > 2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356, > 2))^(1/3)))/21 - -2/21)/(4 * root(((root(7339451281/3087580356, > 2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356, > 2))^(1/3) - 1/63)^2/4 + 1, 2)) - 1/42)^2, 2)/2),...more > > > > > Engin Y?lmaz <ispanyolcom at gmail.com>, 20 Kas 2018 Sal, 12:53 tarihinde ?unu > yazd?: > >> Thanks a lot! >> >> Berend Hasselman <bhh at xs4all.nl>, 20 Kas 2018 Sal, 12:02 tarihinde ?unu >> yazd?: >> >>> >>> >>> R package Ryacas may be what you want. >>> >>> Berend >>> >>> >>>> On 20 Nov 2018, at 09:42, Engin Y?lmaz <ispanyolcom at gmail.com> wrote: >>>> >>>> Dea(R) >>>> >>>> Do you know any system solver in R ? >>>> >>>> For example, in matlab, is very easy >>>> >>>> syms a b c x eqn = a*x^2 + b*x + c == 0; sol = solve(eqn) >>>> >>>> How can I find this type code in R (or directly solver)? >>>> >>>> *Since(R)ely* >>>> Engin YILMAZ >>>> >>>> [[alternative HTML version deleted]] >>>> >>>> ______________________________________________ >>>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >>>> https://stat.ethz.ch/mailman/listinfo/r-help >>>> PLEASE do read the posting guide >>> http://www.R-project.org/posting-guide.html >>>> and provide commented, minimal, self-contained, reproducible code. >>> >>> >> >> -- >> *Sayg?lar?mla* >> Engin YILMAZ >> > >-- Eik Vettorazzi Universit?tsklinikum Hamburg-Eppendorf Institut f?r Medizinische Biometrie und Epidemiologie Martinistra?e 52 Geb?ude W 34 20246 Hamburg Telefon: +49 (0) 40 7410 - 58243 Fax: +49 (0) 40 7410 - 57790 Web: www.uke.de/imbe -- _____________________________________________________________________ Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des ?ffentlichen Rechts; Gerichtsstand: Hamburg | www.uke.de Vorstandsmitglieder: Prof. Dr. Burkhard G?ke (Vorsitzender), Prof. Dr. Dr. Uwe Koch-Gromus, Joachim Pr?l?, Marya Verdel _____________________________________________________________________ SAVE PAPER - THINK BEFORE PRINTING
Once you figure out how to decipher the output, you realise that it actually does give you all 4 roots, including the two real ones: ...> a <- .Last.value > complex_cartesian <- function(x,y) x+(0+1i)*y > eval(a$text[[1]][[2]][[3]])[1] -1.00028+0.988174i> eval(a$text[[1]][[3]][[3]])[1] -1.00028-0.988174i> eval(a$text[[1]][[4]][[3]])[1] 0.03634399> eval(a$text[[1]][[5]][[3]])[1] -1.988165 (No, I don't quite know what I am doing either...) -pd> On 20 Nov 2018, at 13:09 , Engin Y?lmaz <ispanyolcom at gmail.com> wrote: > > Dea(R) > I try to solve one equation but this program did not give me real roots > for example > yacas("Solve( 5/((1+x)^1) + 5/((1+x)^2) + 5/((1+x)^3) + 105/((1+x)^4) -105 > ==0, x)") > gave me following results > How can I find real roots? > > expression(list(x == complex_cartesian((1/42 - ((1/63 - > ((root(7339451281/3087580356, > 2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356, > 2))^(1/3)))/21 - -2/21)/(4 * root(((root(7339451281/3087580356, > 2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356, > 2))^(1/3) - 1/63)^2/4 + 1, 2)))/2 - 1, root(4 * > (((root(7339451281/3087580356, > 2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356, > 2))^(1/3) - 1/63)/2 + root(((root(7339451281/3087580356, > 2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356, > 2))^(1/3) - 1/63)^2/4 + 1, 2)) - (((1/63 - > ((root(7339451281/3087580356, > 2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356, > 2))^(1/3)))/21 - -2/21)/(4 * root(((root(7339451281/3087580356, > 2) - 4535/71442)^(1/3) - (4535/71442 + root(7339451281/3087580356, > 2))^(1/3) - 1/63)^2/4 + 1, 2)) - 1/42)^2, 2)/2),...more > > > > > Engin Y?lmaz <ispanyolcom at gmail.com>, 20 Kas 2018 Sal, 12:53 tarihinde ?unu > yazd?: > >> Thanks a lot! >> >> Berend Hasselman <bhh at xs4all.nl>, 20 Kas 2018 Sal, 12:02 tarihinde ?unu >> yazd?: >> >>> >>> >>> R package Ryacas may be what you want. >>> >>> Berend >>> >>> >>>> On 20 Nov 2018, at 09:42, Engin Y?lmaz <ispanyolcom at gmail.com> wrote: >>>> >>>> Dea(R) >>>> >>>> Do you know any system solver in R ? >>>> >>>> For example, in matlab, is very easy >>>> >>>> syms a b c x eqn = a*x^2 + b*x + c == 0; sol = solve(eqn) >>>> >>>> How can I find this type code in R (or directly solver)? >>>> >>>> *Since(R)ely* >>>> Engin YILMAZ >>>> >>>> [[alternative HTML version deleted]] >>>> >>>> ______________________________________________ >>>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >>>> https://stat.ethz.ch/mailman/listinfo/r-help >>>> PLEASE do read the posting guide >>> http://www.R-project.org/posting-guide.html >>>> and provide commented, minimal, self-contained, reproducible code. >>> >>> >> >> -- >> *Sayg?lar?mla* >> Engin YILMAZ >> > > > -- > *Sayg?lar?mla* > Engin YILMAZ > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com