I cannot solve the system of equations, using the solve function?

f[x_]:=a*Sin[b*(x+c)]+d;
g[x_]:=-1/10125*Exp[4]*x^3+17/1350*Exp[4]*x^2-79/135*Exp[4]*x+90+Exp[1]+(1343/162+Log[2]-Log[3])*Exp[4];
h:=38;
Solve[{f[h]==g[h], f'[h]==g'[h], f''[h]==g''[h], f'''[h]==g'''[h]},{a,b,c,d}]


I want to use the functions defined at the top and evaluate it so that the derivatives match for both functions. I want to use those evaluated functions to solve for a,b,c and d in f(x).

It does not work, says something about being protected, and h:=38, doesn't work because it is "not a variable" apparently.

Could you please help me, I'm a beginner, and am supposed to use Wolfram Language for the assignment.

I'm using WolframCloud, could that be a problem?

• It works for me as it is. Try to quit kernel and run the command again. Maybe you had defined something previously that messes up the computation
– user49048
Feb 21, 2020 at 0:07

First, you should simply type Quit[] and execute, then copy and paste the code you gave us in a new notepad. Generaly when you're getting "protected errors" a variable has been definied already as something else.

If all else fails and you're not sure what's going on, try restarting :)

f[x_] := a*Sin[b*(x + c)] + d;
g[x_] := -1/10125*Exp[4]*x^3 + 17/1350*Exp[4]*x^2 - 79/135*Exp[4]*x +
90 + Exp[1] + (1343/162 + Log[2] - Log[3])*Exp[4];
h := 38;
Solve[{f[h] == g[h], f'[h] == g'[h], f''[h] == g''[h],
f'''[h] == g'''[h]}, {a, b, c, d}]


Using this code exactly gives me a solution....albeit a huge one with conditionals.

$$\left\{\left\{a\to \text{ConditionalExpression}\left[\frac{1}{250} (-21) i \sqrt{33} e^4,c_1\in \mathbb{Z}\right],b\to \text{ConditionalExpression}\left[-\frac{1}{3} i \sqrt{\frac{2}{21}},c_1\in \mathbb{Z}\right],c\to \text{ConditionalExpression}\left[\frac{126 i \pi c_1-38 \sqrt{42}-126 \tanh ^{-1}\left(\frac{1}{3} \left(\sqrt{42}-\sqrt{33}\right)\right)}{\sqrt{42}},c_1\in \mathbb{Z}\right],d\to \text{ConditionalExpression}\left[\frac{21}{250} e^4 \sqrt{33} \sinh \left(\frac{1}{3} \sqrt{\frac{2}{21}} \left(38+\frac{126 i \pi c_1-38 \sqrt{42}-126 \tanh ^{-1}\left(\frac{1}{3} \left(\sqrt{42}-\sqrt{33}\right)\right)}{\sqrt{42}}\right)\right)-\frac{887 e^4}{750}+e+90+e^4 \log (2)-e^4 \log (3),c_1\in \mathbb{Z}\right]\right\},\left\{a\to \text{ConditionalExpression}\left[\frac{1}{250} (-21) i \sqrt{33} e^4,c_1\in \mathbb{Z}\right],b\to \text{ConditionalExpression}\left[\frac{1}{3} i \sqrt{\frac{2}{21}},c_1\in \mathbb{Z}\right],c\to \text{ConditionalExpression}\left[\frac{-126 i \pi c_1-38 \sqrt{42}+126 \tanh ^{-1}\left(\frac{1}{3} \left(-\sqrt{33}-\sqrt{42}\right)\right)}{\sqrt{42}},c_1\in \mathbb{Z}\right],d\to \text{ConditionalExpression}\left[-\frac{21}{250} \sqrt{33} e^4 \sinh \left(\frac{1}{3} \sqrt{\frac{2}{21}} \left(38+\frac{-126 i \pi c_1-38 \sqrt{42}+126 \tanh ^{-1}\left(\frac{1}{3} \left(-\sqrt{33}-\sqrt{42}\right)\right)}{\sqrt{42}}\right)\right)-\frac{887 e^4}{750}+e+90+e^4 \log (2)-e^4 \log (3),c_1\in \mathbb{Z}\right]\right\},\left\{a\to \text{ConditionalExpression}\left[\frac{21}{250} i \sqrt{33} e^4,c_1\in \mathbb{Z}\right],b\to \text{ConditionalExpression}\left[-\frac{1}{3} i \sqrt{\frac{2}{21}},c_1\in \mathbb{Z}\right],c\to \text{ConditionalExpression}\left[\frac{126 i \pi c_1-38 \sqrt{42}-126 \tanh ^{-1}\left(\frac{1}{3} \left(\sqrt{33}+\sqrt{42}\right)\right)}{\sqrt{42}},c_1\in \mathbb{Z}\right],d\to \text{ConditionalExpression}\left[-\frac{21}{250} \sqrt{33} e^4 \sinh \left(\frac{1}{3} \sqrt{\frac{2}{21}} \left(38+\frac{126 i \pi c_1-38 \sqrt{42}-126 \tanh ^{-1}\left(\frac{1}{3} \left(\sqrt{33}+\sqrt{42}\right)\right)}{\sqrt{42}}\right)\right)-\frac{887 e^4}{750}+e+90+e^4 \log (2)-e^4 \log (3),c_1\in \mathbb{Z}\right]\right\},\left\{a\to \text{ConditionalExpression}\left[\frac{21}{250} i \sqrt{33} e^4,c_1\in \mathbb{Z}\right],b\to \text{ConditionalExpression}\left[\frac{1}{3} i \sqrt{\frac{2}{21}},c_1\in \mathbb{Z}\right],c\to \text{ConditionalExpression}\left[\frac{-126 i \pi c_1-38 \sqrt{42}+126 \tanh ^{-1}\left(\frac{1}{3} \left(\sqrt{33}-\sqrt{42}\right)\right)}{\sqrt{42}},c_1\in \mathbb{Z}\right],d\to \text{ConditionalExpression}\left[\frac{21}{250} e^4 \sqrt{33} \sinh \left(\frac{1}{3} \sqrt{\frac{2}{21}} \left(38+\frac{-126 i \pi c_1-38 \sqrt{42}+126 \tanh ^{-1}\left(\frac{1}{3} \left(\sqrt{33}-\sqrt{42}\right)\right)}{\sqrt{42}}\right)\right)-\frac{887 e^4}{750}+e+90+e^4 \log (2)-e^4 \log (3),c_1\in \mathbb{Z}\right]\right\}\right\}$$

It seems you have already defined function f[x] or g[x] somewhere. The "protected error" comes in set delayed form when it is already defined. The simplest solution is to Clear the variable you want to use in your code. You can simply use ClearAll["Global*"] to clear all the variables. After that, your code will run. Updated code will be:

ClearAll["Global*"]
f[x_] := a*Sin[b (x + c)] + d
g[x_] := -1/10125*Exp[4]*x^3 + 17/1350*Exp[4]*x^2 - 79/135*Exp[4]*x +
90 + Exp[1] + (1343/162 + Log[2] - Log[3])*Exp[4];
h := 38;
Solve[{f[h] == g[h], f'[h] == g'[h], f''[h] == g''[h],
f'''[h] == g'''[h]}, {a, b, c, d}];