473,233 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,233 software developers and data experts.

Solving equation phi(x) = k in C++, how?

11
Hi again guys :)

Ok i have this problem, i need to solve the equation phi(x) = 0.1

(where phi is the area under the gaussian normal distribution function)

apparently im supposed to solve it as f(x)=0 , ( phi(x) - 0.1 =0 ) , which can be solved by iteration, for example by using newton-raphson. But i have no idea how to do this. NR needs f(x), f'(x), how can i get that from phi? :s since that function cant be differentiated or integrated.. i can construct a taylor polynomial for the function, not sure if thats what im supposed to.. any tips ? :) Thx all!
Aug 21 '07 #1
5 2575
ahoyer
14
Hi again guys :)

Ok i have this problem, i need to solve the equation phi(x) = 0.1
(where phi is the area under the gaussian normal distribution function)
apparently im supposed to solve it as f(x)=0 , ( phi(x) - 0.1 =0 ) , which can be solved by iteration, for example by using newton-raphson. But i have no idea how to do this. NR needs f(x), f'(x), how can i get that from phi? :s since that function cant be differentiated or integrated.. i can construct a taylor polynomial for the function, not sure if thats what im supposed to.. any tips ? :) Thx all!

if you set phi(x) -0.1 = 0 then all youre doing is root finding right? For that you dont need to do newton-raphson (its sometimes unstable anyways), you could just use the bisection method or even go up to doing the secant method.

the wiki page for the secant method is pretty good, the same goes for bisection method.

if youre looking for speed, you should probably do the secant method, but if you just want to get it done use the bisection.

hope that helps.
Aug 21 '07 #2
2wycked
14
Hi again guys :)

Ok i have this problem, i need to solve the equation phi(x) = 0.1

(where phi is the area under the gaussian normal distribution function)

apparently im supposed to solve it as f(x)=0 , ( phi(x) - 0.1 =0 ) , which can be solved by iteration, for example by using newton-raphson. But i have no idea how to do this. NR needs f(x), f'(x), how can i get that from phi? :s since that function cant be differentiated or integrated.. i can construct a taylor polynomial for the function, not sure if thats what im supposed to.. any tips ? :) Thx all!
Actually you can differentiate the function. The function is an integral, so differentiation will simply be removing the integral (and hence return to the Gaussian curve). Knowing that, if you already have a function that gives you the function value of phi, the Newton method can be used. If you don't have a function that returns the value of phi, then you may need to construct a Taylor series approximation to evaluate phi. I'm not sure the rate of convergence for that function though, so it may take quite a few iterations just to get a reliable value for phi.
Aug 21 '07 #3
Deviate
11
Hi, thanks for the reply! :)

Well i realize i can use the secant method, but dont i also have to calculate phi(x)? I mean, what should i set f(x) to be in this case?

Suppose start out choosing x0 and x1 to start the secant method, i would the have to calculate f(x) to be phi(x)-0.1 .. how do i calculate phi(x)? I could either use simpsons rule or create a taylor polynomial ...am i correct? So it would look something like this to start out with:

x2 = x1 - (( x1 - x0 ) / (phi(x1)-0.1) - (phi(x0)-0.1)) * f(x1)

where x1 and x0 are initial values that are chosen by the user, and where phi of these 2 values are calculated using e.g. simpsons rule ?

Thx to anyone who can confirm this for me :)
Aug 21 '07 #4
Deviate
11
hey 2wycked, thx for ur reply :) u just got it in while i was typing mine above, thx for pointing out that in fact u differentiate it by removing the integral, i had sort of overlooked that :p but i think i will just go for the secant method now, since it wont really change alot for me.. the thing is i just have to recode a fuction that can calculate the value of phi for me.. i have done this previously, but unfortunately i have lost the code somewhere.. and i think i will go for using simpsons rule to calculate it, since its a 4th order approximation it should be faster that taylor approx.. also taylor will spin out of control for larger values of x .. do you guys agree? :)

Thx to all for the help!
Aug 21 '07 #5
2wycked
14
hey 2wycked, thx for ur reply :) u just got it in while i was typing mine above, thx for pointing out that in fact u differentiate it by removing the integral, i had sort of overlooked that :p but i think i will just go for the secant method now, since it wont really change alot for me.. the thing is i just have to recode a fuction that can calculate the value of phi for me.. i have done this previously, but unfortunately i have lost the code somewhere.. and i think i will go for using simpsons rule to calculate it, since its a 4th order approximation it should be faster that taylor approx.. also taylor will spin out of control for larger values of x .. do you guys agree? :)

Thx to all for the help!

Certainly. Taylor series aren't the greatest for genral approximations and Simpon's rule has pretty good convergance. Also, because of the symetry and knowing the area under the enitre curve, you get a few places to make some simplifications.
Aug 21 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Stud Muffin | last post by:
Hey Basically, I'm trying to take objects created in microsoft word using equation editor (for creating clean looking math/physics equations) and putting them into some sort of webpage format....
3
by: greg.smith | last post by:
Hi there, I've been trying to solve this different via numerical methods(C programming) and it's driving me crazy.... I can't post my code because it's simply one big mess and doesn't work. ...
2
by: Anatoly | last post by:
Hi All !!! Can anyone give me link to the C++ source or to the compiled program unit (compatible with Microsoft VC++), designed for the solving of the algebraic linear systems with rare matrices...
7
by: 116Rohan | last post by:
I have been trying to figure out how to solve uneqaulity problems I have two equations which I am trying to figure out What values of n will make 8n^2 < 64 * n * Lg n What I am trying to find...
9
by: TG | last post by:
Hi there. Anyone knows how to use numpy / scipy in order to solve this ? * A is an array of shape (n,) * X is a positive float number * B is an array of shape (n,) * O is an array of shape...
4
by: Thomas | last post by:
Hi, I've to solve a system of linear equations and inequations in C++. Are there (free) librarys for that topic? Regards, Thomas
6
by: mismis | last post by:
HELP!..PLEASE..i have a project that asks to write a C++ program solving for the root of the equation (x*x*x)-(x*x)-(9x)+(9) ........huhuhu..please help..i really need to pass..please..
6
by: Trev17 | last post by:
Hello, I am new to C++ and i have tried for several hours to make a program my teacher has given me as a lab. Here is the Lab question: the roots of the quadratic equation ax^2 + bx + c = 0, a...
10
by: Constantine AI | last post by:
Hi i am having a little problem with an equation function that was created from all your help previously. The function works fine itself but with a small glitch within it. Here is the function...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.