Well if

1= f(x)

then

1 - f (x) = 0

So to find the x that solves the first equation you just need find the root of 1 - f (x) due to the second equation.

That's pretty simple mathematics.

Please check your equation and the values of the parameters you have from your source since I was just copying those from your email. Given those you get what I showed to you.

Frede


Sendt fra Samsung mobil


-------- Oprindelig meddelelse --------
Fra: Andras Farkas
Dato:23/04/2014 12.11 (GMT+01:00)
Til: Frede Aakmann Tøgersen ,r-help@r-project.org
Emne: Re: RE: [R] finding value for a parameter in an equation


Frede

Thank you very much for the help. Indeed, I am trying to do exactly what you wrote the code for. I may have caused some confusion though as a result of a typographic error in my equation: the result of the equation should EQUAL to the value of 1. I see you have inputted the equation into the function as 1 - (minus) D1/... would you be kind to please provide insights on how that may change the the function is written? By using the equation that way the value of E should be between 1.5 and 6, based on data I have available in a plot, if that helps.

Greatly appreciate the help

Thanks

Andras

Sent from Yahoo! Mail on Android


________________________________
From: Frede Aakmann Tøgersen <frtog@vestas.com>;
To: Frede Aakmann Tøgersen <frtog@vestas.com>; Andras Farkas <motyocska@yahoo.com>; r-help@r-project.org <r-help@r-project.org>;
Subject: RE: [R] finding value for a parameter in an equation
Sent: Wed, Apr 23, 2014 9:04:09 AM

Sorry I made a copy and paste error. To get all the details of the curves between 0 and I had to use:

E <- seq(0,10, len = 2000)

Sorry for the inconvenience.

Yours sincerely / Med venlig hilsen


Frede Aakmann Tøgersen
Specialist, M.Sc., Ph.D.
Plant Performance & Modeling

Technology & Service Solutions
T +45 9730 5135
M +45 2547 6050
frtog@vestas.com<javascript:return>
http://www.vestas.com

Company reg. name: Vestas Wind Systems A/S
This e-mail is subject to our e-mail disclaimer statement.
Please refer to www.vestas.com/legal/notice
If you have received this e-mail in error please contact the sender.


> -----Original Message-----
> From: r-help-bounces@r-project.org<javascript:return> [mailto:r-help-bounces@r-project.org<javascript:return>]
> On Behalf Of Frede Aakmann Tøgersen
> Sent: 23. april 2014 10:54
> To: Andras Farkas; r-help@r-project.org<javascript:return>
> Subject: Re: [R] finding value for a parameter in an equation
>
> Hi Andras
>
> I suppose you want to find the real root of your equation if such exists for
> the particular settings of the parameters. For that you can use uniroot().
>
> So define a function based on your equation like this:
>
> f <- function(E, D1, D2, IC501, IC502, ECON, ALPHA, M1, M2){
>    1 - D1/(IC501*((E/(ECON-E))^(1/M1)))+D2/(IC502*((E/(ECON-E))^(1/M2)))
> +
>        (ALPHA*D1*D2)/(IC501*IC502*((E/(ECON-E))^(0.5/M1+0.5/M2)))
> }
>
> Now do some plotting to see how the functions behaves:
>
> ## Parameters
> D1 <-c(0.2,0.6,0.8)
> D2 <-c(114,190,304)
> IC501 <-0.62
> IC502 <-137.8
> ECON <-5.95
> ALPHA <-0.00005
> M1 <-0.84
> M2 <-0.96
>
> # vector for E
> E <- seq(1,15, len = 100)
>
> ## three curves for each set of values of D1 and D2
> plot(E, f(E, D1[1], D2[1], IC501, IC502, ECON, ALPHA, M1, M2), type = "l", col =
> "red")
> lines(E, f(E, D1[2], D2[2], IC501, IC502, ECON, ALPHA, M1, M2), type = "l", col
> = "green")
> lines(E, f(E, D1[3], D2[3], IC501, IC502, ECON, ALPHA, M1, M2), type = "l", col
> = "blue")
>
> f() is only defined on the open interval (0;6).
>
> Attached figure shows that there is real roots for the 3 values of  D1 and D2
> somewhere between 0 and 1.
>
> And those can be found as
>
> > uniroot(f, c(0.0001,1), D1=D1[1], D2=D2[2], IC501=IC501, IC502=IC502,
> ECON=ECON, ALPHA=ALPHA, M1=M1, M2=M2)
> $root
> [1] 0.0003440589
>
> $f.root
> [1] 21.33889
>
> $iter
> [1] 14
>
> $init.it
> [1] NA
>
> $estim.prec
> [1] 6.103516e-05
>
> > uniroot(f, c(0.0001,1), D1=D1[2], D2=D2[2], IC501=IC501, IC502=IC502,
> ECON=ECON, ALPHA=ALPHA, M1=M1, M2=M2)
> $root
> [1] 0.3840484
>
> $f.root
> [1] -9.45929e-05
>
> $iter
> [1] 9
>
> $init.it
> [1] NA
>
> $estim.prec
> [1] 6.103516e-05
>
> > uniroot(f, c(0.0001,1), D1=D1[3], D2=D2[3], IC501=IC501, IC502=IC502,
> ECON=ECON, ALPHA=ALPHA, M1=M1, M2=M2)
> $root
> [1] 0.1476688
>
> $f.root
> [1] -0.001927616
>
> $iter
> [1] 9
>
> $init.it
> [1] NA
>
> $estim.prec
> [1] 6.103516e-05
>
> >
>
>
> > uniroot(f, c(0.0001,1), D1=D1[2], D2=D2[2], IC501=IC501, IC502=IC502,
> ECON=ECON, ALPHA=ALPHA, M1=M1, M2=M2)
> $root
> [1] 0.3840484
>
> $f.root
> [1] -9.45929e-05
>
> $iter
> [1] 9
>
> $init.it
> [1] NA
>
> $estim.prec
> [1] 6.103516e-05
>
> But
>
>
>
>
> Yours sincerely / Med venlig hilsen
>
>
> Frede Aakmann Tøgersen
> Specialist, M.Sc., Ph.D.
> Plant Performance & Modeling
>
> Technology & Service Solutions
> T +45 9730 5135
> M +45 2547 6050
> frtog@vestas.com<javascript:return>
> http://www.vestas.com
>
> Company reg. name: Vestas Wind Systems A/S
> This e-mail is subject to our e-mail disclaimer statement.
> Please refer to www.vestas.com/legal/notice
> If you have received this e-mail in error please contact the sender.
>
>
> > -----Original Message-----
> > From: r-help-bounces@r-project.org<javascript:return> [mailto:r-help-bounces@r-<javascript:return>
> project.org]
> > On Behalf Of Andras Farkas
> > Sent: 22. april 2014 21:33
> > To: r-help@r-project.org<javascript:return>
> > Subject: [R] finding value for a parameter in an equation
> >
> > Dear All,
> >
> > please provide some insights for the following:
> >
> > we have:
> >
> > D1 <-c(0.2,0.6,0.8)
> > D2 <-c(114,190,304)
> > IC501 <-0.62
> > IC502 <-137.8
> > ECON <-5.95
> > ALPHA <-0.00005
> > M1 <-0.84
> > M2 <-0.96
> >
> > and the equation:
> >
> > 1 = D1/(IC501*((E/(ECON-E))^(1/M1)))+D2/(IC502*((E/(ECON-
> > E))^(1/M2)))+(ALPHA*D1*D2)/(IC501*IC502*((E/(ECON-
> > E))^(0.5/M1+0.5/M2)))
> >
> > In this equation the value for parameter "E" is what I am trying to calculate
> > (all other parameters are known) for each pairs of D1 and D2 (ie: input
> D1[1]
> > and D2[1] and the rest of the parameters first then substitute D1[2] and
> > D2[2], then substitute D1[3] and D2[3]). It seems as if the equation can not
> > be re-arranged so that "E" could be directly calculated, so looking to see if
> > you could help me perhaps with a thought on how this could be solved with
> > R,
> >
> > thanks as always,
> >
> > Andras
> >     [[alternative HTML version deleted]]


	[[alternative HTML version deleted]]


