Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8066129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:52:57+00:00 2026-06-05T11:52:57+00:00

When i am trying to simulate my sine approximation in matlab i found a

  • 0

When i am trying to simulate my sine approximation in matlab i found a strange problem. The problem is that when i apply my function to an array, it returns one results, whereas applying functions to individual values ​​gives a slightly different result.

I was able to get same behaviour in this example:

z = single(0:0.001:1);
F = @(x) (x.^2 - single(1.2342320e-001)).*x.^2;  %some test function

z(999)        % Returns 9.9800003e-001
F(z(999))     % Returns 8.6909407e-001
temp = F(z);  
temp(999)     % Voila! It returns 8.6909401e-001

Also I found a few things. One is that first result is right (not the latter). Second, is that rearrangement of terms sometimes solves the problem. So i have no idea how to get rid of that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:52:59+00:00Added an answer on June 5, 2026 at 11:52 am

    Using single-precision numbers, both results are "equal" (difference is smaller than the relative accuracy of the single type). The following statement evaluates to true:

    max(abs( arrayfun(F,z) - F(z) )) < eps('single')
    

    EDIT

    If you really want to have control over this, you can try disabling the MATLAB accelerator to force it to use the same execution paths for both regular and vectorized code:

    feature('jit', 'off')
    feature('accel', 'off')
    max(abs( arrayfun(F,z) - F(z) ))
    
    feature('jit', 'on')
    feature('accel', 'on')
    max(abs( arrayfun(F,z) - F(z) ))
    

    The result for the first/second respectively:

    ans =
         0
    ans =
       5.9605e-08
    

    Obviously, by default both the accelerator and the just-in-time compiler are turned on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to simulate a interface from a touchscreen phone, one function of the
I am trying to simulate a scenario where connection to the server of one
I am trying to write a shell script to simulate the following problem: File
I am trying write a function that generates simulated data but if the simulated
I was trying to simulate MATLAB's NN functions before testing my own coded network.
I am trying to simulate a click on one of my tabs if the
Trying to simulate a HTTP POST that needs to combine some INPUT/TEXT fields along
I´m trying to simulate a table using only CSS and DIV. The problem is
I am trying to simulate a problem we have with a particular domain ID
I'm trying to simulate some code that I have working with SQL but using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.