Jump to content



Photo
- - - - -

Programming Newton- Rhapson's method for numerical integration

nDeriv / dy/dx Programming Newton Rhapson Derivative dy/dx numerical integration University

  • Please log in to reply
7 replies to this topic

#1 Thesebjo

Thesebjo

    Newbie

  • Members
  • Pip
  • 4 posts

  • Calculators:
    Casio fx-7400GIII

Posted 12 December 2023 - 01:20 PM

Hello! I would like help in troubleshooting with programming on my fx-7400GIII. I'm in uni and we are currently working on numerical integration. For our class our professor had us program 4 different methods for this:

 

The rectangle method, the trapezoid method, the bisection method and Newton- Rhapson's method. 

I've gotten everything to work except for Newton- Rhapson. Our teacher is a Texas guy and he couldn't solve how to get the script for this method to work on my calculator so that it actually functions. I have an exam in 2 days and would love if somebody could help me out a little. The issue seems to be with the nDeriv (dy/dx on casio?) function. When i try to run the script i just get an error, and the only difference between this script and the 3 others that i got working no problem is that this one has a derivative function in it. This is the script I'm trying to run:

 

ClrText

"LOSER Y1=0."

"GISSNING: "?→X

"ITERATIONER: "?→N

For 1→I To N

X-Y1(X)/nDeriv(Y1,X,X)→X

Next

"LOSNING: "

X

 

I've traded the "nDeriv" which doesn't seem to exist on Casio for "dy/dx" but something still isn't working. My professor thought it might have something to do with the format of (Y1,X,X) within the parenthesis, but I don't know.

 

Any solution to this problem would be extremely appreciated! Exam is in 2 days... And I can't figure it out!!



#2 pan.gejt

pan.gejt

    Casio Freak

  • Members
  • PipPipPipPip
  • 263 posts
  • Gender:Male
  • Location:CZ

  • Calculators:
    .

Posted 12 December 2023 - 11:22 PM

bisection method and Newton- Rhapson's method are numerical method for solving of equation, these methods are not for numerical integration.

My code

"F(X)"?Y1

"GISSNING: "?→X

1->D

"TOL="?→T

While D>T

X→Y

X-Y1(X)/d/dx(Y1,X,0.05)→X;insert here the output triangle to see the new values or colon to hide them;

Abs(X-Y)→D

WhileEnd

"LOSNING: ";insert here the output triangle;X;insert here the output triangle

"F(X)=";insert here the output triangle;Y1(X)

 

TOL means tolerance between X and Y values

to get Y1: vars-grph-y 

to get d/dx: optn-calc-d/dx

0.05 is tolerance for derivative, you can change this value it or you can omitt this value- in such case the default tolerance 1e-10 is used


Edited by pan.gejt, 12 December 2023 - 11:23 PM.


#3 Thesebjo

Thesebjo

    Newbie

  • Members
  • Pip
  • 4 posts

  • Calculators:
    Casio fx-7400GIII

Posted 13 December 2023 - 12:11 AM

Is it possible to get to select the nummer of iterations as well? Thats one thing i really need in my program. Cause i use the program to check that my hand- done calculations is correct. For example if its supposed to be 3 iterations that im supposed to do by hand i want to be able to check that my answer is the same after 3 iterations on the calc. If you catch my drift. Many thanks!

Edited by Thesebjo, 13 December 2023 - 12:29 AM.

  • Thesebjo likes this

#4 pan.gejt

pan.gejt

    Casio Freak

  • Members
  • PipPipPipPip
  • 263 posts
  • Gender:Male
  • Location:CZ

  • Calculators:
    .

Posted 13 December 2023 - 11:53 AM

MEQT1IH_t.jpg

MEQT1II_t.jpg

MEQT1IJ_t.jpg

MEQT1IN_t.jpg


Edited by pan.gejt, 13 December 2023 - 11:54 AM.


#5 Thesebjo

Thesebjo

    Newbie

  • Members
  • Pip
  • 4 posts

  • Calculators:
    Casio fx-7400GIII

Posted 13 December 2023 - 12:49 PM

Thanks a lot!! But it still doesn't work... When I try to put in a function it gives me the wrong answer. For example n 2√ x - 0,1^ x + 4 is supposed to be around x=4,44 but it gives me -31,4438... with 6 iterations?  :wacko:

I don't think there's something that's wrong with my code input but i couldn't find "rad" and I couldn't find "1E-5". Still should work though, right?


Edited by Thesebjo, 13 December 2023 - 12:50 PM.


#6 pan.gejt

pan.gejt

    Casio Freak

  • Members
  • PipPipPipPip
  • 263 posts
  • Gender:Male
  • Location:CZ

  • Calculators:
    .

Posted 13 December 2023 - 01:52 PM

f(x)=2√ x - 0.1^ x + 4=0 

this function has no real root(s), plot this function in you calc or you can make table in excel

f(4.44)=8.214 

https://www.wolframa...t(x)-0.1^x+4=0)

 

Rad: set the calc to radian mode (shift+menu[setup]-angl-rad), for trig equations

1e-5: press1, press exp, press (-) press 5

 

quick math analysis: 2√ x - 0.1^ x = -4

term 2√ x is always positive, growing and is defined for positive x only

term -0.1^ x has the minimum -1 for x=0 and is growing

combining both terms together cannot reach -4, you can get only -1 for x=0 (2*0 - 1 = -1)



#7 Thesebjo

Thesebjo

    Newbie

  • Members
  • Pip
  • 4 posts

  • Calculators:
    Casio fx-7400GIII

Posted 13 December 2023 - 02:05 PM

Sorry bro. I meant 2sqrtX-0,1e^x+4. Gives me the answer -31,44.... after 3 iterations. By hand i get 4,439 which is roughly 4.4.


Edited by Thesebjo, 13 December 2023 - 02:09 PM.


#8 pan.gejt

pan.gejt

    Casio Freak

  • Members
  • PipPipPipPip
  • 263 posts
  • Gender:Male
  • Location:CZ

  • Calculators:
    .

Posted 13 December 2023 - 11:16 PM

Try several different guess values if initial guess value doesn't converge
Guess=2 n=194 x=4.406516919
Guess=3 n=7 x=4.406516966
Guess=4 n=4 x=4.406516917
Guess=5 n=4 x=4.40651692
Guess=6 n=5 x=4.406517084
Guess=7 n=6 x=4.406517381


Edited by pan.gejt, 14 December 2023 - 08:30 AM.






Also tagged with one or more of these keywords: nDeriv / dy/dx, Programming, Newton, Rhapson, Derivative, dy/dx, numerical integration, University

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users