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 3350840
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:50:09+00:00 2026-05-18T01:50:09+00:00

If I do the following in MATLAB: ppval(mkpp(1:2, [1 0 0 0]),1.5) ans =

  • 0

If I do the following in MATLAB:

ppval(mkpp(1:2, [1 0 0 0]),1.5)
ans =  0.12500

This should construct a polynomial f(x) = x^3 and evaluate it at x = 1.5. So why does it give me the result 1.5^3 = .125? Now, if I change the domain defined in the first argument to mkpp, I get this:

> ppval(mkpp([1 1.5 2], [[1 0 0 0]; [1 0 0 0]]), 1.5)
ans = 0

So without changing the function, I change the answer. Awesome.

Can anyone explain what’s going on here? How does changing the first argument to mkpp change the result I get?

  • 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-05-18T01:50:10+00:00Added an answer on May 18, 2026 at 1:50 am

    The function MKPP will shift the polynomial so that x = 0 will start at the beginning of the corresponding range you give it. In your first example, the polynomial x^3 is shifted to the range [1 2], so if you want to evaluate the polynomial at an unshifted range of [0 1], you would have to do the following:

    >> pp = mkpp(1:2,[1 0 0 0]);   %# Your polynomial
    >> ppval(pp,1.5+pp.breaks(1))  %# Shift evaluation point by the range start
    
    ans =
    
        3.3750                     %# The answer you expect
    

    In your second example, you have one polynomial x^3 shifted to the range [1 1.5] and another polynomial x^3 shifted to the range of [1.5 2]. Evaluating the piecewise polynomial at x = 1.5 gives you a value of zero, occurring at the start of the second polynomial.

    It may help to visualize the polynomials you are making as follows:

    x = linspace(0,3,100);                     %# A vector of x values
    pp1 = mkpp([1 2],[1 0 0 0]);               %# Your first piecewise polynomial
    pp2 = mkpp([1 1.5 2],[1 0 0 0; 1 0 0 0]);  %# Your second piecewise polynomial
    subplot(1,2,1);                            %# Make a subplot
    plot(x,ppval(pp1,x));                      %# Evaluate and plot pp1 at all x
    title('First Example');                    %# Add a title
    subplot(1,2,2);                            %# Make another subplot
    plot(x,ppval(pp2,x));                      %# Evaluate and plot pp2 at all x
    axis([0 3 -1 8])                           %# Adjust the axes ranges
    title('Second Example');                   %# Add a title
    

    alt text

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

Sidebar

Related Questions

I thought that latest Matlab does this automatically. I have tested the following exe
I have written the following algorithm in order to evaluate a function in MatLab
The following MATLAB code does not work. I guess it has something to do
Does anyone know how to make the following Matlab code approximate the exponential function
I normalize a vector V in MATLAB as following: normalized_V = V/norm(V); however, is
I have a problem with Matlab - I need to do the following :
I'm running matlab on my local machine and I'm calling the following function from
I am trying to convert the following code from Trefethen's Spectral Methods in MATLAB
Following code produces a nested array as a result for keys containing three items:
Following are the simple statements in the irb shell. What does nil in the

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.