Skip to main content
edited tags
Link
added 3 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

I would like to create the following function: It should approximate a function func[x] by piecewise polynomial interpolations, splitting the approximate function in n different polynomspolynomials, from xMin to xMax.

autoPiecewiseApproximation[func[x],{xMin,xMax,n}]

Example: the square root function

For instance for two subdivisons n = 2 and xMin = 0, xMax = 1, the function would automatically generate this:

m = Piecewise[{{Fit[
     Table[{x, Sqrt[x]}, {x, 0, 0.5, .01}], {1, x, x^2, E^x}, x] , 
    0 <= x <= 0.5}, {Fit[
     Table[{x, Sqrt[x]}, {x, 0.5, 1, .01}], {1, x, x^2, E^x}, x] , 
    0.5 < x <= 1}}]

Anyone knows how to do this correctly ?

I would like to create the following function: It should approximate a function func[x] by piecewise polynomial interpolations, splitting the approximate function in n different polynoms, from xMin to xMax.

autoPiecewiseApproximation[func[x],{xMin,xMax,n}]

Example: the square root function

For instance for two subdivisons n = 2 and xMin = 0, xMax = 1, the function would automatically generate this:

m = Piecewise[{{Fit[
     Table[{x, Sqrt[x]}, {x, 0, 0.5, .01}], {1, x, x^2, E^x}, x] , 
    0 <= x <= 0.5}, {Fit[
     Table[{x, Sqrt[x]}, {x, 0.5, 1, .01}], {1, x, x^2, E^x}, x] , 
    0.5 < x <= 1}}]

Anyone knows how to do this correctly ?

I would like to create the following function: It should approximate a function func[x] by piecewise polynomial interpolations, splitting the approximate function in n different polynomials, from xMin to xMax.

autoPiecewiseApproximation[func[x],{xMin,xMax,n}]

Example: the square root function

For instance for two subdivisons n = 2 and xMin = 0, xMax = 1, the function would automatically generate this:

m = Piecewise[{{Fit[
     Table[{x, Sqrt[x]}, {x, 0, 0.5, .01}], {1, x, x^2, E^x}, x] , 
    0 <= x <= 0.5}, {Fit[
     Table[{x, Sqrt[x]}, {x, 0.5, 1, .01}], {1, x, x^2, E^x}, x] , 
    0.5 < x <= 1}}]

Anyone knows how to do this correctly ?

Tweeted twitter.com/StackMma/status/1036947513318809601
added 8 characters in body; edited title
Source Link
Henrik Schumacher
  • 109.4k
  • 7
  • 186
  • 322

Automatic PicewisePiecewise Approximation

I would like to create the following function: It should approximate a function func[x] by piece-wisepiecewise polynomial interpolations, splitting the approximate function in Nn different polynoms, from xMin to xMax.

autoPiecewiseApproximation[func[x],{xMin,xMax,Nn}]

Example: the square root function

For instance for two subdivisons N =2n = 2 and xMin=0xMin = 0, xMax = 1xMax = 1, the function would automatically generate this:

m = Piecewise[{{Fit[
     Table[{x, Sqrt[x]}, {x, 0, 0.5, .01}], {1, x, x^2, E^x}, x] , 
    0 <= x <= 0.5}, {Fit[
     Table[{x, Sqrt[x]}, {x, 0.5, 1, .01}], {1, x, x^2, E^x}, x] , 
    0.5 < x <= 1}}]

Anyone knows how to do this correctly ?

Automatic Picewise Approximation

I would like to create the following function: It should approximate a function func[x] by piece-wise polynomial interpolations, splitting the approximate function in N different polynoms, from xMin to xMax.

autoPiecewiseApproximation[func[x],{xMin,xMax,N}]

Example: the square root function

For instance for two subdivisons N =2 and xMin=0, xMax = 1, the function would automatically generate this:

m = Piecewise[{{Fit[
     Table[{x, Sqrt[x]}, {x, 0, 0.5, .01}], {1, x, x^2, E^x}, x] , 
    0 <= x <= 0.5}, {Fit[
     Table[{x, Sqrt[x]}, {x, 0.5, 1, .01}], {1, x, x^2, E^x}, x] , 
    0.5 < x <= 1}}]

Anyone knows how to do this correctly ?

Automatic Piecewise Approximation

I would like to create the following function: It should approximate a function func[x] by piecewise polynomial interpolations, splitting the approximate function in n different polynoms, from xMin to xMax.

autoPiecewiseApproximation[func[x],{xMin,xMax,n}]

Example: the square root function

For instance for two subdivisons n = 2 and xMin = 0, xMax = 1, the function would automatically generate this:

m = Piecewise[{{Fit[
     Table[{x, Sqrt[x]}, {x, 0, 0.5, .01}], {1, x, x^2, E^x}, x] , 
    0 <= x <= 0.5}, {Fit[
     Table[{x, Sqrt[x]}, {x, 0.5, 1, .01}], {1, x, x^2, E^x}, x] , 
    0.5 < x <= 1}}]

Anyone knows how to do this correctly ?

Source Link
james
  • 3.1k
  • 14
  • 30
Loading