## 50 Reputation

7 years, 195 days

## Linear spline set constant endpoints...

Maple 2016

I have a set of points. I want to make a linear spline of that points and plot the resulting function:

`function:=CurveFitting[Spline](points_x,points_y,x,degree=1):`

However I need the function to define constant y endpoint values where x is out of points_x range (i.e. first-derivation is zero where x is out of points_x range). Endpoint options does not work for me.

```             constant1   x < xmin
function :=  ..
constant2   otherwise```

How can I define spline function like this?

## Integration of Planck radiation law...

Maple 2016

I'm trying to obtain integral of Planck radiation law in Maple:

with this command:

```f := (2*h*(c)^(2))/((x)^(5))*(1)/(exp((h*c)/(x*k*T))-1);
int(f,x=0..infinity);```

but I get some terrible limit that cannot be solved instead of the correct result:

How to obtain correct integral?

planck.mw

## Numerical integration...

Maple

I have a derivative distribution function f that is defined:

`f:=piecewise(x < .114e-1,0.,x < .129e-1,0.,x < .147e-1,0.,x < .167e-1,0.,x < .189e-1,0.,x < .215e-1,0.,x < .244e-1,0.,x < .278e-1,0.,x < .315e-1,0.,x < .358e-1,0.,x < .407e-1,0.,x < .463e-1,0.,x < .526e-1,0.,x < .597e-1,0.,x < .679e-1,0.,x < .771e-1,0.,x < .876e-1,0.,x < .995e-1,0.,x < .113,0.,x < .128,0.,x < .146,0.,x < .166,0.,x < .188,0.,x < .214,0.,x < .243,0.,x < .276,0.,x < .314,0.,x < .357,0.,x < .405,0.,x < .46,0.,x < .523,0.,x < .594,0.,x < .675,-.8800000000+1.481481481*x,x < .767,-.3935869565+.7608695652*x,x < .872,-.3213333333+.6666666667*x,x < .991,-.2529411765+.5882352941*x,x < 1.13,-.1690647482+.5035971223*x,x < 1.28,-.2026666667+.5333333333*x,x < 1.45,-.1223529412+.4705882353*x,x < 1.65,-.1650000000+.5000000000*x,x < 1.88,-.2726086957+.5652173913*x,x < 2.13,-.5636000000+.7200000000*x,x < 2.42,-.8662068966+.8620689655*x,x < 2.75,-1.200000000+1.000000000*x,x < 3.12,-1.645945946+1.162162162*x,x < 3.55,-1.865581395+1.232558140*x,x < 4.03,-2.075416667+1.291666667*x,x < 4.58,-1.925818182+1.254545455*x,x < 5.21,-1.559682540+1.174603175*x,x < 5.92,-.7967605634+1.028169014*x,x < 6.72,.3320000000+.8375000000*x,x < 7.64,1.942608696+.5978260870*x,x < 8.68,3.791923077+.3557692308*x,x < 9.86,5.850169492+.1186440678*x,x < 11.2,7.902985075-.8955223881e-1*x,x < 12.7,9.737333333-.2533333333*x,x < 14.5,10.82388889-.3388888889*x,x < 16.4,11.78631579-.4052631579*x,x < 18.7,11.34347826-.3782608696*x,x < 21.2,10.85240000-.3520000000*x,x < 24.1,9.311379310-.2793103448*x,x < 27.4,7.619090909-.2090909091*x,x < 31.1,5.814864865-.1432432432*x,x < 35.3,4.025714286-.8571428571e-1*x,x < 40.1,2.544375000-.4375000000e-1*x,x < 45.6,1.519090909-.1818181818e-1*x,x < 51.8,.8370967742-.3225806452e-2*x,x < 58.9,.6700000000,x < 66.9,.5963750000+.1250000000e-2*x,x < 76,.9005494505-.3296703297e-2*x,x < 86.4,1.161538462-.6730769231e-2*x,x < 98.1,1.318461538-.8547008547e-2*x,x < 111,1.544651163-.1085271318e-1*x,x < 127,1.241875000-.8125000000e-2*x,x < 144,1.106470588-.7058823529e-2*x,x < 163,.7721052632-.4736842105e-2*x,x < 186,0,x < 211,0,x < 240,0,x < 272,0,x < 310,0,x < 352,0,x < 400,0,x < 454,0,x < 516,0,x < 586,0,x < 666,0,x < 756,0,x < 859,0,x < 976,0,x < 1110,0,x < 1260,0,x < 1430,0,x < 1630,0,x < 1850,0,x < 2100,0,x < 2390,0,x < 2710,0,0):`

I want to do a simple numerical integration of that function - that means I have k points of independent variable x and together with dependent variable points it looks like:

I was trying to resolve this in Maple:

```f_list:=convert(f,list):

integralbodyx:=[seq(0+((200-0)/100)*i,i=1..100)]:

integralbodyy:=[seq(sum((eval(f_list[0+((200-0)/100)*j],x=(0+((200-0)/100)*j)))*2,j=1..i),i=1..100)]:```

but I get an error

`Error, (in limit/mrv/limsimpl) too many levels of recursion`

Can you help me with the syntax? Thank you.

## Plot points in CIE 1976 color space...

Maple 2016

I want to plot some color points in CIE 1976 color space with SpatterPlot command exactly as showed on the help page. When I try:

```restart:with(ColorTools):with(ImageTools):
barvy:=Color("Lab",[80.38,13.50,7.96]);
SpatterPlot(barvy,symbol="box");
```

I got the error:

`Error, invalid input: ColorTools:-SpatterPlot expects its 1st argument, colors, to be of type list({ColorTools:-Color, name, string, list({float, nonnegint}), specfunc({COLOR, COLOUR})}), but received _m2194815429568`

Where is the problem?

## Nonlinear fit of difficult function...

Maple 2016

I have a data point set:

```x_val:=<250,300,350,397,451,497,547,593,647,691,745,788,840,897>:
y_val:=<0,0.5,2,6.3,23.2,48.7,71.2,83.4,90.1,92.8,94.7,95.7,96.9,97.8>:```

I want to make a least square fit using this difficult function:

`function:=x->1-exp(-(k*exp(-(E/(8.314*873.15))*((873.15/x)-1)))*(0.026/350))`

but both Statistics[Fit]:

```with(Statistics):fit_nelog:=Fit(1-exp(-(k*exp(-(E/(8.314*873.15))*((873.15/x)-1)))*(0.026/350)),<x_val|y_val>,x,parameternames=[k,E],output=[parametervector,residualsumofsquares]);
```

and DirectSearch[DataFit]:

`with(DirectSearch):fit_nelog2:=DataFit(1-exp(-(k*exp(-(E/(8.314*873.15))*((873.15/x)-1)))*(0.026/350)),x_val,y_val,x,method=cdos);`

give wrong k,E parameters. The correct parameter values were obtained with Excel Solver:

```k=27843.3551042397

E=68.4```

The approximately correct parameters were fitted when using logarithm form of the function.
How can I obtain correct parameter values in Maple using given form of the function?

 1 2 3 Page 1 of 3
﻿