NN function approximation: What's wrong with my code?

U
urta_hill · May 10, 2021 · 2K views
Question
I have just started learning neural networks and have been stuck on a homework question for quite a while. the question is as follows: Design a feed forward multi-layer  neural network to approximate the function y=sin(x1)+cos(x2). Here, -5
Expert Answer
Profile picture of Prashant Kumar
Prashant Kumar PhD Expert
Answered Aug 25, 2026
f you sort your y and ynet based upon input1, then you can see that the error is especially bad towards the right hand side (input1 close to 5). If you sort based upon input2, then there are multiple not-good places but especially towards input2 close to 5.
If you scatter(x1, x2), then at least for the run I did, the number of random samples close to x1 = 5 or x2 = 5 is not high.
I think you need more training data.
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!