Please solve! we use C and visual studio Problem (a) Write a C function called B
ID: 3551295 • Letter: P
Question
Please solve! we use C and visual studio
Problem (a)
Write a C function called Bspline that takes as input a single double precision argument called x. The function returns a double precision value y determined as follows
if -2 <=x<0 then y=(1/4)(x+2)^3
if -1 <=x<0 then y=(1/4)+(3/4)(x+1)+(3/4)(x+1)^2 -(3/4)(x+1)^3
if 0 <=x<1 then y=(1/4)+(3/4)(x-1)+(3/4)(1-x)^2 -(3/4)(1-x)^3
if 1 <=x<=2 then y=(1/4)(2-3)^3
For all other input values, the function returns 0.0. Provide a table of test results for 30 values of x, uniformly spaced between -2.25 and 2.25 inclusive
Problem (b) Write a C function called shiftBspline that uses the function Bspline of Problem (a). This function takes a double precision argument called shift, and a double presision argument called x. The function returns the value at location x of the Bspline function with its centre x-value shifted to the location shift. Provide a table of 20 values of the shifted Bspline with the value of 10 for shift, and the table values uniformly spaced between shift -3.0 and shift +3.0.
Explanation / Answer
Im not sure what part b is asking, but this is what I got for part a#include<stdio.h> #include<math.h> double Bspline(double); double y; double x; int main() { printf("Excercise 5a Joesph Legall "); for(x=-2.25; x<=2.25; x= double (x+4.50/29.00)) { Bspline(x); printf("x= %10.6f y= %10.6f ",x,y); } } double Bspline(double x){ if(x >= -2&&x <-1){ return (y= (1.0/4.0)*(x+2.0)*(x+2.0)*(x+2.0)); } else{ if(x >= -1&&x <0){ return(y=(1.0/4)+ (3.0/4)*(x+1)+(3/4)*(x+1)*(x+1)-(3/4)*(x+1)*(x+1)*(x+1)); } else{ if(0 <= x&&x <1){ return(y=(1.0/4)+ (3/4)*(1-x)+(3/4)*(1-x)*(1-x)-(3/4)*(1-x)*(1-x)*(1-x)); } else{ if(1 <= x && x <2){ return(y= (1.0/4)*(2-x)*(2-x)*(2-x)); } else{ return(y=0.0); }}}} return(0); }