Newton's Method utilizing Mathcad

Click For Summary

Discussion Overview

The discussion revolves around implementing Newton's Method in Mathcad, specifically addressing a programming error encountered while trying to find the root of the function x^3-5*x^2+3*x+4 within a specified tolerance. The conversation includes troubleshooting coding issues and exploring Boolean operations in Mathcad.

Discussion Character

  • Homework-related
  • Technical explanation

Main Points Raised

  • One participant describes an error message in Mathcad related to scalar values when implementing Newton's Method.
  • Another participant suggests removing unnecessary assignments in the code to resolve the error, indicating that Mathcad may not recognize the function properly.
  • A later reply confirms that the suggested change fixed the error and introduces a new question about implementing Boolean OR in Mathcad.
  • Further, a participant provides guidance on accessing Boolean operators in Mathcad, specifically mentioning a menu feature.
  • Finally, the original poster expresses gratitude for the clarification regarding the Boolean operator representation.

Areas of Agreement / Disagreement

Participants generally agree on the solution to the initial programming error, but the discussion about Boolean operations indicates a lack of clarity on Mathcad's features, which remains unresolved.

Contextual Notes

The discussion does not address potential limitations of Mathcad's handling of functions or the specific context of the Boolean operations, leaving some assumptions and dependencies unexamined.

sandy.bridge
Messages
797
Reaction score
1

Homework Statement


I am writing a simple program in Mathcad for Newton's Method. The function is x^3-5*x^2+3*x+4. The root is between 0 and 3, and we want a tolerance of 0.00001. My code is the exact same as a program I made in Matlab that works, but since I am new to Mathcad, I am getting an error that I do not know how to fix.

The error I receive is "This value must be a scalar"; it is referring to my function f(x). Here is the code:

upload_2015-1-21_8-21-53.png
 
Physics news on Phys.org
I don't see why you're making the assignments g(x) ← f and dg(x) ← df. I figure that this is where Mathcad is tripping up because it can't tell at the outset what f is and decides that it's a scalar.

If you get rid of those two assignments and just use f(x) and df(x) inside your function you should be fine.
 
  • Like
Likes   Reactions: sandy.bridge
That certainly fixed it! It definitely was redundant and unnecessary. Thanks!

One other question: do you know a way of implementing Boolean OR in Mathcad? I want to remain in a while loop if any of 3 statements are true. This is rather easy in Matlab, but I am finding it difficult in Mathcad. I am uncertain as to why Mathcad did not include this.
 
Open the "< ≠ ≥" menu by clicking the icon with the same designation (I have Mathcad 11.2, but presumably the same feature exists in whatever version you are using). You'll find boolean operators there.
 
Ah, I didn't realize that the V represented OR. Thanks a bunch!
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
18
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
2
Views
3K
Replies
7
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
2K